made bot in four hours
can run roll and random
This commit is contained in:
17
src/util/junk.rs
Normal file
17
src/util/junk.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
pub fn get_random_insult() -> String {
|
||||
let insults = get_insults();
|
||||
let result = insults.choose(&mut rand::thread_rng()).unwrap();
|
||||
result.to_owned().to_string()
|
||||
}
|
||||
|
||||
fn get_insults<'a>() -> Vec<&'a str> {
|
||||
Vec::from([
|
||||
"You're the type to use Limit Break on trash mobs.",
|
||||
"Your DPS is lower than a healer who only casts Medica II.",
|
||||
"Your glamour looks like you raided a NPC vendor in Limsa Lominsa.",
|
||||
"I've seen Lalafells with better threat generation than you.",
|
||||
"Your gear is more broken than the Dragonsong War timeline.",
|
||||
])
|
||||
}
|
3
src/util/mod.rs
Normal file
3
src/util/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod junk;
|
||||
pub mod random;
|
||||
pub mod validate;
|
13
src/util/random.rs
Normal file
13
src/util/random.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use rand::rngs::ThreadRng;
|
||||
|
||||
pub struct RandomGen {
|
||||
pub rng: ThreadRng,
|
||||
}
|
||||
|
||||
impl RandomGen {
|
||||
pub fn new() -> Self {
|
||||
RandomGen {
|
||||
rng: rand::thread_rng(),
|
||||
}
|
||||
}
|
||||
}
|
8
src/util/validate.rs
Normal file
8
src/util/validate.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
pub fn parse_str_into_num<T: FromStr>(input: &str) -> Option<T> {
|
||||
match input.parse::<T>() {
|
||||
Ok(n) => Some(n),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user