enhanced printing logic
This commit is contained in:
parent
fce6c7bd67
commit
bc2beb1a87
|
@ -3,7 +3,7 @@
|
||||||
pkgname=rustmon-git
|
pkgname=rustmon-git
|
||||||
pkgdesc="Pokemon Colorscripts written in Rust"
|
pkgdesc="Pokemon Colorscripts written in Rust"
|
||||||
_gitname=rustmon
|
_gitname=rustmon
|
||||||
pkgver=r27.a575677
|
pkgver=r40.fce6c7b
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
url="https://github.com/Vomitblood/$_gitname"
|
url="https://github.com/Vomitblood/$_gitname"
|
||||||
|
|
27
src/print.rs
27
src/print.rs
|
@ -1,4 +1,5 @@
|
||||||
use rand::prelude::SliceRandom;
|
use rand::prelude::SliceRandom;
|
||||||
|
use rand::Rng;
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
@ -41,6 +42,11 @@ pub fn print(
|
||||||
pokedexes.clone()
|
pokedexes.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// process the pokedexes list
|
||||||
|
// iterate through the pokedexes list, if value is 0, then generate a random number between 1 and 905
|
||||||
|
// if the value is not 0, then use the value as is
|
||||||
|
let pokedexes = process_pokedexes_list(pokedexes);
|
||||||
|
|
||||||
// process the forms list
|
// process the forms list
|
||||||
// the length of the forms list should be the same as the pokedexes list, resize with `regular` if different length
|
// the length of the forms list should be the same as the pokedexes list, resize with `regular` if different length
|
||||||
// if the form is not available for the pokemon then print the available forms and exit
|
// if the form is not available for the pokemon then print the available forms and exit
|
||||||
|
@ -49,11 +55,11 @@ pub fn print(
|
||||||
// generate a list of slugs
|
// generate a list of slugs
|
||||||
let slugs = generate_slug_list(big, forms, &pokedexes, shiny_rate);
|
let slugs = generate_slug_list(big, forms, &pokedexes, shiny_rate);
|
||||||
|
|
||||||
println!("{:?}", slugs);
|
// print the names of the slugs, separated by comma
|
||||||
|
|
||||||
print_name(&slugs);
|
print_name(&slugs);
|
||||||
|
|
||||||
print_ascii_side_by_side(&slugs, spacing).unwrap();
|
// print the actual thing
|
||||||
|
print_colorscripts(&slugs, spacing).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +177,19 @@ fn is_shiny(shiny_rate: f32) -> bool {
|
||||||
return random_number < shiny_rate;
|
return random_number < shiny_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn process_pokedexes_list(pokedexes: Vec<u16>) -> Vec<u16> {
|
||||||
|
let mut pokedexes_processed: Vec<u16> = pokedexes.clone();
|
||||||
|
|
||||||
|
for i in 0..pokedexes.len() {
|
||||||
|
if pokedexes[i] == 0 {
|
||||||
|
let random_pokedex = rand::thread_rng().gen_range(1..906);
|
||||||
|
pokedexes_processed[i] = random_pokedex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pokedexes_processed;
|
||||||
|
}
|
||||||
|
|
||||||
fn process_forms_list(pokedexes: &Vec<u16>, forms: Vec<&String>) -> Vec<String> {
|
fn process_forms_list(pokedexes: &Vec<u16>, forms: Vec<&String>) -> Vec<String> {
|
||||||
let mut forms_processed: Vec<String> = forms.iter().map(|s| s.to_string()).collect();
|
let mut forms_processed: Vec<String> = forms.iter().map(|s| s.to_string()).collect();
|
||||||
|
|
||||||
|
@ -263,7 +282,7 @@ fn print_name(paths: &Vec<std::path::PathBuf>) {
|
||||||
println!("{}", output);
|
println!("{}", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_ascii_side_by_side(paths: &Vec<std::path::PathBuf>, spacing: u8) -> std::io::Result<()> {
|
fn print_colorscripts(paths: &Vec<std::path::PathBuf>, spacing: u8) -> std::io::Result<()> {
|
||||||
// open all files and create BufReaders
|
// open all files and create BufReaders
|
||||||
let mut readers: Vec<_> = paths
|
let mut readers: Vec<_> = paths
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Reference in a new issue