//! Room environment use serde_derive::Deserialize; /// Type of environment for the room #[derive(Debug, Deserialize)] pub enum Environment { /// Inside a building Inside, /// Out in the wild Wilderness, /// On a road Road, /// Horse load Horse, /// In a swamp Swamp, /// In the water Water, /// A drinking source Drink, /// Weapon shop Weaponsmith, /// Armor shop Armorer, /// Master blacksmith Blacksmith, /// Bank Bank, /// Stables Stables, /// Place to rent Rent, /// Grocer Grocer, /// Warrior practice Warrior, /// Rogue practice Rogue, /// Hunter practice Hunter, /// Possible PK objective Pk, /// Other Other, } impl From for Environment { fn from(num: i64) -> Self { match num { 20 => Self::Inside, 21 => Self::Wilderness, 22 => Self::Road, 23 => Self::Horse, 24 => Self::Swamp, 25 => Self::Water, 26 => Self::Drink, 27 => Self::Weaponsmith, 28 => Self::Armorer, 29 => Self::Blacksmith, 30 => Self::Bank, 31 => Self::Stables, 32 => Self::Rent, 33 => Self::Grocer, 34 => Self::Warrior, 35 => Self::Rogue, 36 => Self::Hunter, 37 => Self::Pk, _ => Self::Other, } } } impl Environment { /// Some room environments have a symbol to put in the room on the map pub fn symbol(&self) -> String { match self { Self::Horse => "H", Self::Drink => "D", Self::Weaponsmith => "W", Self::Armorer => "A", Self::Blacksmith => "B", Self::Bank => "$", Self::Stables => "S", Self::Rent => "R", Self::Grocer => "G", Self::Warrior => "W", Self::Rogue => "R", Self::Hunter => "H", Self::Pk => "P", _ => "", } .to_string() } /// Color of the room pub fn color(&self) -> String { match self { Self::Inside => "", Self::Wilderness => "", Self::Road => "", Self::Swamp => "", Self::Water => "", _ => "", } .to_string() } }