summaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-07-01 18:06:05 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-07-01 18:06:05 +0200
commit26aefe70fa11f209726e5b8a15bd05303726396e (patch)
treee8ab0ae5fa230e0e1ea6b51b240305d59d59d662 /src/input
parent1ac0449bd0313ad01da0d253f7b45b45287314b7 (diff)
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.
Diffstat (limited to 'src/input')
-rw-r--r--src/input/json.rs51
1 files changed, 49 insertions, 2 deletions
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<Error>> {
+pub fn read_expressive_state_from_file(filename: &str) -> Result<(engine::settings::GameSettings, expressive_engine::ExpressiveGameState), Box<Error>> {
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<bitwise_engine::BitwiseGameState, Box<Error>> {
+ //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 {