44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
use super::{characteristic::Characteristic, dice::DiceThrow, skill::Skill};
|
|
use std::collections::HashMap;
|
|
|
|
pub struct Hero<'a> {
|
|
pub characteristics: HashMap<&'static str, Characteristic>,
|
|
pub skills: HashMap<&'static str, Skill<'a>>,
|
|
}
|
|
|
|
impl Hero {
|
|
pub fn new() -> Hero {
|
|
Hero {
|
|
characteristics: HashMap::new(),
|
|
skills: HashMap::new(),
|
|
}
|
|
}
|
|
|
|
pub fn add_characteristic(&mut self, identifier: &'static str, value: i8) {
|
|
match self.characteristics
|
|
.insert(identifier, Characteristic { identifier, value })
|
|
{
|
|
_ => {} //TODO: handle whatever this returns
|
|
};
|
|
}
|
|
|
|
pub fn add_skill(
|
|
&mut self,
|
|
identifier: &'static str,
|
|
value: i8,
|
|
characteristics: [&'static str; 3],
|
|
) {
|
|
match self.skills.insert(
|
|
identifier,
|
|
Skill {
|
|
identifier,
|
|
value,
|
|
characteristics,
|
|
hero: self,
|
|
},
|
|
) {
|
|
_ => {} //TODO: handle whatever this returns
|
|
};
|
|
}
|
|
}
|