From 920fd897161699b69eabee573ab1ed7aabd48feb Mon Sep 17 00:00:00 2001 From: HeNine <> Date: Tue, 30 May 2023 20:22:30 +0200 Subject: [PATCH] horned bear --- examples/vs_horned_bear.rs | 78 ++++++++++++++++++++++++++++++++++++++ src/premade/mod.rs | 39 +++++++++++++++++-- 2 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 examples/vs_horned_bear.rs diff --git a/examples/vs_horned_bear.rs b/examples/vs_horned_bear.rs new file mode 100644 index 0000000..153267b --- /dev/null +++ b/examples/vs_horned_bear.rs @@ -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::>(); + + 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::>(); + + 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::>(); + + 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::>(); + + 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::>(); + + 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::>(); + + 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::>(); + + 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 + ) +} diff --git a/src/premade/mod.rs b/src/premade/mod.rs index c67edab..6d8b899 100644 --- a/src/premade/mod.rs +++ b/src/premade/mod.rs @@ -61,7 +61,7 @@ pub fn get_drub() -> Character { * Just an average bandit. */ pub fn get_bandit() -> Character { - let mut drub = create_character( + let mut bandit = create_character( String::from("Bandit"), Class::NPC, Class::NPC, @@ -71,15 +71,39 @@ pub fn get_bandit() -> Character { WeaponType::BladedWeapon.create_weapon(String::from("Shortsword")), ); - drub.proficiencies.bladed_weapons = true; - drub.proficiencies.medium_armor = true; + bandit.proficiencies.bladed_weapons = 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)] mod premade_tests { + use crate::premade::get_horned_bear; + use super::{get_bandit, get_bob, get_drub, get_george}; #[test] @@ -109,4 +133,11 @@ mod premade_tests { println!("{}", bandit); } + + #[test] + fn print_horned_bear() { + let horned_bear = get_horned_bear(); + + println!("{}", horned_bear); + } }