diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-07-01 22:24:49 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-07-01 22:24:49 +0200 |
commit | c4fe897b41f90a53e0629e2444d3e7f2121cddde (patch) | |
tree | d98ef1163aa8ac6c18e9607a4808661449a818be /src/engine | |
parent | 945ae96707f6b4065c89463047979a18ad8181aa (diff) |
JSON parsing of bitwise buildings
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/bitwise_engine.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/engine/bitwise_engine.rs b/src/engine/bitwise_engine.rs index 4fad36f..04e4f85 100644 --- a/src/engine/bitwise_engine.rs +++ b/src/engine/bitwise_engine.rs @@ -40,7 +40,7 @@ pub struct UnconstructedBuilding { pub building_type: BuildingType } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct TeslaCooldown { pub active: bool, pub pos: Point, @@ -82,4 +82,25 @@ impl PlayerBuildings { pub fn count_teslas(&self) -> usize { self.tesla_cooldowns.iter().filter(|t| t.active).count() } + + pub fn empty() -> PlayerBuildings { + PlayerBuildings { + unconstructed: Vec::with_capacity(4), + buildings: [0; 4], + energy_towers: 0, + missile_towers: [0; 4], + missiles: [(0,0); 4], + tesla_cooldowns: [TeslaCooldown::empty(); 2] + } + } +} + +impl TeslaCooldown { + pub fn empty() -> TeslaCooldown { + TeslaCooldown { + active: false, + pos: Point::new(0,0), + cooldown: 0 + } + } } |