lib_efo/stats/implementations/
symb_impl.rs

1//! All symbol implementations
2//!
3use crate::{
4    entity::{EffectApplication, EffectBounds, EntityDuration},
5    stats::{
6        CharacterId, EntityType, FactionId, ListStats, OverallStats, Position, Role, Symbols,
7        TownId,
8    },
9};
10use colored::Colorize;
11
12impl Symbols for Role {
13    fn to_symbol(&self) -> String {
14        match self {
15            Role::Govern => " ".to_string(),
16            Role::Capital => " ".to_string(),
17            Role::Undefined => "󱣩".to_string(),
18        }
19    }
20}
21
22impl Symbols for EntityType {
23    fn to_shortest(&self) -> String {
24        match self {
25            EntityType::Character => "[C]".to_string(),
26            EntityType::Player => "[P]".to_string(),
27            EntityType::Town => "[T]".to_string(),
28            EntityType::Monster => "[M]".to_string(),
29            EntityType::Blocker => "[B]".to_string(),
30            EntityType::Event => "[E]".to_string(),
31        }
32    }
33    fn to_symbol(&self) -> String {
34        match self {
35            EntityType::Character => "".to_string(),
36            EntityType::Player => " ".to_string(),
37            EntityType::Town => "󱡵 ".to_string(),
38            EntityType::Monster => " ".to_string(),
39            EntityType::Blocker => " ".to_string(),
40            EntityType::Event => "".to_string(),
41        }
42    }
43}
44
45impl Symbols for EffectApplication {
46    fn to_symbol(&self) -> String {
47        match self {
48            EffectApplication::Recurring => "⟳".to_string(),
49            EffectApplication::WhenPresent => "⥯".to_string(),
50            EffectApplication::PermanentEffectToApply => "☈".to_string(),
51            EffectApplication::PermanentEffectApplied => "✓".to_string(),
52        }
53    }
54}
55
56impl Symbols for Position {
57    fn to_symbol(&self) -> String {
58        format!("({:4},{:4})⚓", self.0, self.1)
59    }
60    fn to_shortest(&self) -> String {
61        format!("{},{}", self.0, self.1)
62    }
63}
64
65impl Symbols for EntityDuration {
66    fn to_symbol(&self) -> String {
67        match self {
68            EntityDuration::Permanent => "∞".to_string(),
69            EntityDuration::Duration(t) => format!("⧗{}", t),
70            EntityDuration::Done => "✔".to_string(),
71        }
72    }
73}
74
75impl Symbols for EffectBounds {
76    fn to_symbol(&self) -> String {
77        format!("({} ⭾ {})", self.min, self.max)
78    }
79}
80
81impl Symbols for OverallStats {
82    fn to_symbol(&self) -> String {
83        format!(
84            "{:2}{} {:2}{} {:2}{} {:2}{}",
85            self.demographics,
86            " ".green(),
87            self.economy,
88            "💰".yellow(),
89            self.military,
90            " ".red(),
91            self.infrastructure,
92            "󰡢".cyan(),
93        )
94    }
95}
96
97impl Symbols for ListStats {
98    fn to_shortest(&self) -> String {
99        match self {
100            ListStats::Demographics => "Dem".blue(),
101            ListStats::Population => "Pop".green(),
102            ListStats::Growthrate => "Gro".green(),
103            ListStats::Crime => "Cri".green(),
104            ListStats::Happiness => "Hap".green(),
105            ListStats::Economy => "Eco".blue(),
106            ListStats::Food => "Foo".yellow(),
107            ListStats::Industry => "Ind".yellow(),
108            ListStats::Science => "Sci".yellow(),
109            ListStats::Trade => "Tra".yellow(),
110            ListStats::Social => "Soc".blue(),
111            ListStats::Culture => "Cul".purple(),
112            ListStats::Education => "Edu".purple(),
113            ListStats::Tourism => "Tou".purple(),
114            ListStats::Influence => "Inf".purple(),
115            ListStats::Military => "Mil".blue(),
116            ListStats::Army => "Arm".red(),
117            ListStats::Strength => "Str".red(),
118            ListStats::Fortification => "For".red(),
119            ListStats::Threat => "Thr".red(),
120            ListStats::Infrastructure => "Inf".blue(),
121            ListStats::Bureaucracy => "Bur".cyan(),
122            ListStats::Transportation => "Tra".cyan(),
123            ListStats::Sprawl => "Spr".cyan(),
124            ListStats::Health => "Hea".cyan(),
125        }
126        .to_string()
127    }
128    fn to_symbol(&self) -> String {
129        match self {
130            ListStats::Demographics => " ".blue(),
131            ListStats::Population => " ".green(),
132            ListStats::Growthrate => " ".green(),
133            ListStats::Crime => "󱀣".green(),
134            ListStats::Happiness => " ".green(),
135            ListStats::Economy => "💰".blue(),
136            ListStats::Food => "󰔬".yellow(),
137            ListStats::Industry => "🏭".yellow(),
138            ListStats::Science => "󰧑 ".yellow(),
139            ListStats::Trade => " ".yellow(),
140            ListStats::Social => "󱕹 ".blue(),
141            ListStats::Culture => "🎭".purple(),
142            ListStats::Education => "📚".purple(),
143            ListStats::Tourism => "🏖️".purple(),
144            ListStats::Influence => "🌍".purple(),
145            ListStats::Military => "🪖".blue(),
146            ListStats::Army => " ".red(),
147            ListStats::Strength => "󰞇 ".red(),
148            ListStats::Fortification => "🔒".red(),
149            ListStats::Threat => "⚡".red(),
150            ListStats::Infrastructure => "🏗️ ".blue(),
151            ListStats::Bureaucracy => "🏛️ ".cyan(),
152            ListStats::Transportation => "󰔬 ".cyan(),
153            ListStats::Sprawl => "🏙️".cyan(),
154            ListStats::Health => "".cyan(),
155        }
156        .to_string()
157    }
158}
159
160impl Symbols for Option<FactionId> {
161    fn to_symbol(&self) -> String {
162        if let Some(faction) = self {
163            format!("{faction}")
164        } else {
165            "Ø".to_string()
166        }
167    }
168}
169
170impl Symbols for TownId {
171    fn to_symbol(&self) -> String {
172        self.0.to_symbol()
173    }
174
175    fn to_shortest(&self) -> String {
176        self.0.to_shortest()
177    }
178}
179
180impl Symbols for CharacterId {
181    fn to_symbol(&self) -> String {
182        self.0.to_symbol()
183    }
184
185    fn to_shortest(&self) -> String {
186        self.0.to_shortest()
187    }
188}