attribute exercising

This commit is contained in:
Llywelwyn 2023-09-27 22:12:53 +01:00
parent 4d614daad5
commit c757466df1
3 changed files with 33 additions and 2 deletions

View file

@ -354,6 +354,17 @@ impl Attributes {
charisma: Attribute::new(cha),
}
}
pub fn attr_from_index(&self, attr: i32) -> &Attribute {
match attr {
Self::STR => &self.strength,
Self::DEX => &self.dexterity,
Self::CON => &self.constitution,
Self::INT => &self.intelligence,
Self::WIS => &self.wisdom,
Self::CHA => &self.charisma,
_ => unreachable!("Tried to get an attribute that doesn't exist."),
}
}
pub fn exercise(&mut self, attr: i32, improve: bool) {
match attr {
Self::STR => {