summaryrefslogtreecommitdiff
path: root/src/rules/npcs.rs
blob: c3fc86ab67ef5dc97dac73bf4ecd23840566bd8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::rules::ability_scores::AbilityScoreCollection;
use crate::rules::classes::Class;
// use std::fmt;

pub struct Npc {
    pub alignment: Option<String>,
    pub race: Option<String>,
    pub class: Option<&'static Class>,
    pub ability_scores: Option<AbilityScoreCollection>,
}

impl Npc {
    pub fn new(
        alignment: Option<String>,
        race: Option<String>,
        class: Option<&'static Class>,
        ability_scores: Option<AbilityScoreCollection>,
    ) -> Self {
        Npc {
            alignment,
            race,
            class,
            ability_scores,
        }
    }
}

// impl fmt::Display for Npc {
//     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//         let values: Vec<&str> = vec![
//             self.alignment.as_deref().unwrap_or(""),
//             self.race.as_deref().unwrap_or(""),
//             self.class.as_ref().map_or("", |class| &class.name),
//         ]
//         .into_iter()
//         .filter(|&s| !s.is_empty())
//         .collect();
//
//         let formatted_string = values.join(" ");
//         write!(f, "{}", formatted_string)
//     }
// }