From 26aefe70fa11f209726e5b8a15bd05303726396e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 1 Jul 2018 18:06:05 +0200 Subject: Set up (failing) property test for working of new game state Unfortunately, for this test to work, I still need to implement the function that reads the game state and goes from one to the other. --- src/input/json.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'src/input') diff --git a/src/input/json.rs b/src/input/json.rs index 6f7cda1..fb88bf0 100644 --- a/src/input/json.rs +++ b/src/input/json.rs @@ -5,9 +5,9 @@ use std::error::Error; use engine; use engine::expressive_engine; +use engine::bitwise_engine; - -pub fn read_state_from_file(filename: &str) -> Result<(engine::settings::GameSettings, expressive_engine::ExpressiveGameState), Box> { +pub fn read_expressive_state_from_file(filename: &str) -> Result<(engine::settings::GameSettings, expressive_engine::ExpressiveGameState), Box> { let mut file = File::open(filename)?; let mut content = String::new(); file.read_to_string(&mut content)?; @@ -18,6 +18,53 @@ pub fn read_state_from_file(filename: &str) -> Result<(engine::settings::GameSet Ok((engine_settings, engine_state)) } +pub fn read_bitwise_state_from_file(filename: &str) -> Result> { + //TODO + Ok(bitwise_engine::BitwiseGameState { + status: engine::GameStatus::Continue, + player: engine::Player { + energy: 0, health: 0, energy_generated: 0 + }, + opponent: engine::Player { + energy: 0, health: 0, energy_generated: 0 + }, + player_buildings: bitwise_engine::PlayerBuildings { + unconstructed: Vec::new(), + buildings: [0,0,0,0], + energy_towers: 0, + missile_towers: [0,0,0], + missiles: [(0,0),(0,0),(0,0),(0,0)], + tesla_cooldowns: [bitwise_engine::TeslaCooldown { + active: false, + pos: engine::geometry::Point::new(0,0), + cooldown: 0 + }, bitwise_engine::TeslaCooldown { + active: false, + pos: engine::geometry::Point::new(0,0), + cooldown: 0 + }], + unoccupied: Vec::new() + }, + opponent_buildings: bitwise_engine::PlayerBuildings { + unconstructed: Vec::new(), + buildings: [0,0,0,0], + energy_towers: 0, + missile_towers: [0,0,0], + missiles: [(0,0),(0,0),(0,0),(0,0)], + tesla_cooldowns: [bitwise_engine::TeslaCooldown { + active: false, + pos: engine::geometry::Point::new(0,0), + cooldown: 0 + }, bitwise_engine::TeslaCooldown { + active: false, + pos: engine::geometry::Point::new(0,0), + cooldown: 0 + }], + unoccupied: Vec::new() + } + }) +} + #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct State { -- cgit v1.2.3