cleaned up print.rs

This commit is contained in:
Vomitblood 2024-04-22 08:49:17 +08:00
parent bc2beb1a87
commit ae45871a57
2 changed files with 4 additions and 27 deletions

View file

@ -3,12 +3,12 @@
pkgname=rustmon-git
pkgdesc="Pokemon Colorscripts written in Rust"
_gitname=rustmon
pkgver=r40.fce6c7b
pkgver=r41.bc2beb1
pkgrel=1
arch=('x86_64')
url="https://github.com/Vomitblood/$_gitname"
license=('GPL')
depends=('glibc' 'gcc-libs')
depends=('glibc' 'gcc-libs' 'base-devel')
makedepends=('git' 'cargo')
provides=("$_gitname")
source=("git+$url.git")
@ -24,13 +24,13 @@ pkgver() {
build() {
cd "$srcdir/$_gitname"
# build main program
cargo build --release
cargo build --release --bin rustmon
# build mini program
cargo build --release --bin minimon
}
package() {
cd "$srcdir/$_gitname"
install -Dm755 target/release/$_gitname "$pkgdir/usr/bin/$_gitname"
install -Dm755 target/release/rustmon "$pkgdir/usr/bin/rustmon"
install -Dm755 target/release/minimon "$pkgdir/usr/bin/minimon"
}

View file

@ -120,29 +120,6 @@ fn get_pokemon_data(pokedex_number: u16) -> crate::structs::Pokemon {
return pokemon_data;
}
fn find_pokemon_by_pokedex(
pokedex_number_string: &str,
) -> Result<String, Box<dyn std::error::Error>> {
// handle random
if pokedex_number_string == "0" {
return Ok("random".to_string());
} else {
// read the file
let mut file = std::fs::File::open(crate::constants::DATA_DIRECTORY.join("pokemon.json"))?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
// deserialize into the struct
let pokemons: Vec<crate::structs::Pokemon> = serde_json::from_str(&contents)?;
let pokedex_number = pokedex_number_string.parse::<usize>().unwrap();
let pokemon_data = pokemons.get(pokedex_number).unwrap();
return Ok(pokemon_data.name.clone());
}
}
fn find_pokedex_by_pokemon(pokemon_name: &str) -> Result<String, Box<dyn std::error::Error>> {
// handle random
if pokemon_name == "random" {