From c4fe897b41f90a53e0629e2444d3e7f2121cddde Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 1 Jul 2018 22:24:49 +0200 Subject: JSON parsing of bitwise buildings --- src/engine/bitwise_engine.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/engine') 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 + } + } } -- cgit v1.2.3