use crate::{Character, domain::Ability};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SavingThrow {
pub proficient: bool,
pub modifier: i16,
}
#[derive(Debug, Clone, Copy)]
pub struct CharacterSheet<'a> {
character: &'a Character,
}
impl<'a> CharacterSheet<'a> {
pub(crate) const fn new(character: &'a Character) -> Self {
Self { character }
}
#[must_use]
pub fn hit_die(self) -> u8 {
self.character.class_hit_die()
}
#[must_use]
pub fn saving_throw(self, ability: Ability) -> SavingThrow {
let proficient = self
.character
.class_saving_throws()
.contains(&ability.as_str());
let modifier = self.character.abilities.modifier(ability)
+ if proficient {
i16::from(self.character.proficiency_bonus())
} else {
0
};
SavingThrow {
proficient,
modifier,
}
}
}