ed_journals/modules/civilization/models/
faction_state.rs

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use std::fmt::{Display, Formatter};

use serde::{Deserialize, Serialize};

/// The state a faction can be in. The primary faction for a system also dictates the state of the
/// system as a whole.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum FactionState {
    Blight,
    Boom,
    Bust,
    CivilLiberty,
    CivilUnrest,
    CivilWar,
    Drought,
    Election,
    Exiled,
    Expansion,
    Famine,
    InfrastructureFailure,
    Investment,
    Lockdown,
    NaturalDisaster,
    Outbreak,
    PirateAttack,
    PublicHoliday,
    Retreat,
    Terrorism,
    War,
    None,

    #[cfg(feature = "allow-unknown")]
    #[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
    #[serde(untagged)]
    Unknown(String),
}

impl Display for FactionState {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                FactionState::Blight => "Blight",
                FactionState::Boom => "Boom",
                FactionState::Bust => "Bust",
                FactionState::CivilLiberty => "Civil Liberty",
                FactionState::CivilUnrest => "Civil Unrest",
                FactionState::CivilWar => "Civil War",
                FactionState::Drought => "Drought",
                FactionState::Election => "Election",
                FactionState::Exiled => "Exiled",
                FactionState::Expansion => "Expansion",
                FactionState::Famine => "Famine",
                FactionState::InfrastructureFailure => "Infrastructure Failure",
                FactionState::Investment => "Investment",
                FactionState::Lockdown => "Lockdown",
                FactionState::NaturalDisaster => "Natural Disaster",
                FactionState::Outbreak => "Outbreak",
                FactionState::PirateAttack => "Pirate Attack",
                FactionState::PublicHoliday => "Public Holiday",
                FactionState::Retreat => "Retreat",
                FactionState::Terrorism => "Terrorism",
                FactionState::War => "War",
                FactionState::None => "None",

                #[cfg(feature = "allow-unknown")]
                FactionState::Unknown(unknown) =>
                    return write!(f, "Unknown faction state: {}", unknown),
            }
        )
    }
}