diff options
author | tom barrett <spalf0@gmail.com> | 2019-02-03 05:45:35 -0600 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2019-02-03 05:45:35 -0600 |
commit | 46fa862e04bc43311ba79ef3db70abf9014b9104 (patch) | |
tree | 3507873ec788af1f1e0885bbb676dbb4a373d48e /src/modules/construction.rs | |
parent | 828f0d83dcb258a8e5efd55a7775592c6e5f77bc (diff) |
bringing to 2018
Diffstat (limited to 'src/modules/construction.rs')
-rw-r--r-- | src/modules/construction.rs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/modules/construction.rs b/src/modules/construction.rs index 46ddbb1..f55a2fb 100644 --- a/src/modules/construction.rs +++ b/src/modules/construction.rs @@ -1,5 +1,5 @@ +use crate::modules::types::ModuleType; use std::time::SystemTime; -use modules::types::ModuleType; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub enum ConstructionStatus { @@ -8,26 +8,32 @@ pub enum ConstructionStatus { Constructed, } -#[derive(Serialize, Deserialize, Debug, Clone)] +impl Default for ConstructionStatus { + fn default() -> Self { + ConstructionStatus::None + } +} + +#[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct Construction { - pub status : ConstructionStatus, - construction : Option<ModuleType>, - time : u64, - start : Option<SystemTime>, + pub status: ConstructionStatus, + construction: Option<ModuleType>, + time: u64, + start: Option<SystemTime>, } impl Construction { pub fn new() -> Construction { Construction { - status : ConstructionStatus::None, - construction : None, - time : 5, - start : None, + status: ConstructionStatus::None, + construction: None, + time: 5, + start: None, } } pub fn process(&mut self) { - if let Some(timer) = self.start.clone() { + if let Some(timer) = self.start { if timer.elapsed().unwrap().as_secs() > self.time { self.start = Some(SystemTime::now()); self.status = ConstructionStatus::Constructed; |