use gametools::{Die, dice::DieResult};
fn main() -> DieResult<()> {
let d6_rolls = Die::new(6)?.roll_n(4);
println!("Ability score roll (4d6): {:?}", d6_rolls.as_slice());
println!("Sum of top three: {}", d6_rolls.highest(3).sum());
println!();
let d20_rolls = Die::new(20)?.roll_n(10);
println!("Attack rolls (>13 to hit): {:?}", d20_rolls.as_slice());
println!(
"{}/10 squads hit their targets.",
d20_rolls.count_where(|r| r > 13)
);
println!(
"{}/10 captured their objectives.",
d20_rolls.count_where(|r| r == 20)
);
println!("{}/10 were wiped out.", d20_rolls.count_where(|r| r == 1));
println!();
let yahtzee_roll = Die::new(6)?.roll_n(5);
let histogram = yahtzee_roll.histogram();
println! {"Yahtzee Roll (5d6): {:?}", yahtzee_roll.as_slice()};
println! {"Histogram: {:#?}", histogram};
if histogram.len() == 2 && histogram.values().any(|count| *count == 3) {
println!("Full House!");
}
if histogram.len() == 1 {
println!("Yahtzee!");
}
println!();
let damage_roll = Die::exploding(4, 4)?.roll_n(10);
println!("Damage Roll: {:?}", damage_roll.as_slice());
println!("Total: {}", damage_roll.sum());
println!();
Ok(())
}