From daa60184c6e52c82008ed375c7a2d4f7e65dfab0 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 12 Jul 2018 23:41:58 +0200 Subject: Changed other bitwise stuff to use constants --- src/engine/bitwise_engine.rs | 1 + src/input/json.rs | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/engine/bitwise_engine.rs b/src/engine/bitwise_engine.rs index db4ad9a..87b7f0f 100644 --- a/src/engine/bitwise_engine.rs +++ b/src/engine/bitwise_engine.rs @@ -306,6 +306,7 @@ impl BitwiseGameState { for _ in 0..(if tesla.pos.y == 0 || tesla.pos.y == MAP_HEIGHT-1 { 2 } else { 3 }) { let hits = destroy_mask & opponent_buildings.buildings[0]; destroy_mask &= !hits; + //TODO: This can probably be pulled out of the loop BitwiseGameState::destroy_buildings(opponent_buildings, hits); destroy_mask = destroy_mask << SINGLE_MAP_WIDTH; } diff --git a/src/input/json.rs b/src/input/json.rs index c032f48..72c964d 100644 --- a/src/input/json.rs +++ b/src/input/json.rs @@ -7,6 +7,7 @@ use engine; use engine::command; use engine::expressive_engine; use engine::bitwise_engine; +use engine::constants::*; pub fn read_expressive_state_from_file(filename: &str) -> Result<(engine::settings::GameSettings, expressive_engine::ExpressiveGameState), Box> { let mut file = File::open(filename)?; @@ -171,9 +172,9 @@ impl State { if building.construction_time_left >= 0 { bitwise_buildings.unconstructed.push(building.to_bitwise_engine_unconstructed()); } else { - for health_tier in 0..4 { - if building.health > health_tier*5 { - bitwise_buildings.buildings[health_tier as usize] |= bitfield; + for health_tier in 0..DEFENCE_HEALTH { + if building.health > health_tier as u8 * MISSILE_DAMAGE { + bitwise_buildings.buildings[health_tier] |= bitfield; } } if building_type == command::BuildingType::Energy { @@ -181,9 +182,9 @@ impl State { engine_player.energy_generated += building.energy_generated_per_turn; } if building_type == command::BuildingType::Attack { - for cooldown_tier in 0..4 { - if building.weapon_cooldown_time_left == cooldown_tier { - bitwise_buildings.missile_towers[cooldown_tier as usize] |= bitfield; + for cooldown_tier in 0..MISSILE_COOLDOWN + 1 { + if building.weapon_cooldown_time_left == cooldown_tier as u8 { + bitwise_buildings.missile_towers[cooldown_tier] |= bitfield; } } } @@ -296,7 +297,7 @@ impl Player { engine::Player { energy: self.energy, health: self.health, - energy_generated: 5 + energy_generated: ENERGY_GENERATED_BASE } } } -- cgit v1.2.3