horned bear

main
HeNine 1 year ago
parent f0c556833c
commit 920fd89716

@ -0,0 +1,78 @@
use kartsimrust::{
premade::{get_bob, get_george, get_horned_bear},
test_util::battle_stats::battle_stats,
};
fn main() {
env_logger::init();
let mut characters = vec![get_bob()];
let mut enemies = (0..1).map(|_| get_horned_bear()).collect::<Vec<_>>();
let (p, mu_t) = battle_stats(characters, enemies);
println!(
"Bob won {:.2}% of battles in an average of {:.1} turns.",
p, mu_t
);
characters = vec![get_george()];
enemies = (0..1).map(|_| get_horned_bear()).collect::<Vec<_>>();
let (p, mu_t) = battle_stats(characters, enemies);
println!(
"George won {:.2}% of battles in an average of {:.1} turns.",
p, mu_t
);
characters = vec![get_bob()];
enemies = (0..2).map(|_| get_horned_bear()).collect::<Vec<_>>();
let (p, mu_t) = battle_stats(characters, enemies);
println!(
"Bob won {:.2}% of battles against 2 Horned Bears in an average of {:.1} turns.",
p, mu_t
);
characters = vec![get_bob(), get_george()];
enemies = (0..1).map(|_| get_horned_bear()).collect::<Vec<_>>();
let (p, mu_t) = battle_stats(characters, enemies);
println!(
"Bob and George won {:.2}% of battles against 1 Horned Bear in an average of {:.1} turns.",
p, mu_t
);
characters = vec![get_bob(), get_george(), get_bob()];
enemies = (0..1).map(|_| get_horned_bear()).collect::<Vec<_>>();
let (p, mu_t) = battle_stats(characters, enemies);
println!(
"Bob and George and Bob won {:.2}% of battles against 1 Horned Bear in an average of {:.1} turns.",
p, mu_t
);
characters = vec![get_bob(), get_george(), get_bob()];
enemies = (0..2).map(|_| get_horned_bear()).collect::<Vec<_>>();
let (p, mu_t) = battle_stats(characters, enemies);
println!(
"Bob and George won {:.2}% of battles against 2 Horned Bears in an average of {:.1} turns.",
p, mu_t
);
characters = vec![get_bob(), get_george(), get_bob()];
enemies = (0..3).map(|_| get_horned_bear()).collect::<Vec<_>>();
let (p, mu_t) = battle_stats(characters, enemies);
println!(
"Bob and George won {:.2}% of battles against 3 Horned Bears in an average of {:.1} turns.",
p, mu_t
)
}

@ -61,7 +61,7 @@ pub fn get_drub() -> Character {
* Just an average bandit. * Just an average bandit.
*/ */
pub fn get_bandit() -> Character { pub fn get_bandit() -> Character {
let mut drub = create_character( let mut bandit = create_character(
String::from("Bandit"), String::from("Bandit"),
Class::NPC, Class::NPC,
Class::NPC, Class::NPC,
@ -71,15 +71,39 @@ pub fn get_bandit() -> Character {
WeaponType::BladedWeapon.create_weapon(String::from("Shortsword")), WeaponType::BladedWeapon.create_weapon(String::from("Shortsword")),
); );
drub.proficiencies.bladed_weapons = true; bandit.proficiencies.bladed_weapons = true;
drub.proficiencies.medium_armor = true; bandit.proficiencies.medium_armor = true;
return drub; return bandit;
}
/*
* A bear... with horns!
*/
pub fn get_horned_bear() -> Character {
let mut horned_bear = create_character(
String::from("Horned Bear"),
Class::NPC,
Class::NPC,
StatBlock::from((3, 1, 2, 2, -1, -3, 1, -1)),
StatBlock::default(),
Armor::Medium,
WeaponType::SimpleWeapon.create_weapon(String::from("Horns and claws")),
);
horned_bear.proficiency = 2;
horned_bear.proficiencies.simple_weapons = true;
horned_bear.proficiencies.medium_armor = true;
return horned_bear;
} }
#[cfg(test)] #[cfg(test)]
mod premade_tests { mod premade_tests {
use crate::premade::get_horned_bear;
use super::{get_bandit, get_bob, get_drub, get_george}; use super::{get_bandit, get_bob, get_drub, get_george};
#[test] #[test]
@ -109,4 +133,11 @@ mod premade_tests {
println!("{}", bandit); println!("{}", bandit);
} }
#[test]
fn print_horned_bear() {
let horned_bear = get_horned_bear();
println!("{}", horned_bear);
}
} }

Loading…
Cancel
Save