summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-08-07 13:58:16 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-08-07 13:58:16 +0200
commit096091af6a3a4d16da133037321c81a51e1bb4b2 (patch)
tree1e1ba49f6c292c0af7273f7e4518a8a370313812
parent952c8653115483163ce0df38e6c8c1a0d31a84fd (diff)
Lava assertions
-rw-r--r--src/game.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/game.rs b/src/game.rs
index 6b7897d..c47d4b8 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -199,7 +199,22 @@ impl GameBoard {
.map(|w| w.position)
.collect();
- // TODO: Do some asssertions about the state of lava
+ if cfg!(debug_assertions) {
+ // This checks if my lava map is the same as the game
+ // engine's lava map. It's off by one because the game
+ // engine will update its one at the beginning of
+ // processing the round.
+ let lava = LAVA_MAP[self.round as usize - 1];
+ for cell in json.map.iter().flatten() {
+ let lava_at = lava.at(Point2d::new(cell.x, cell.y));
+ match cell.cell_type {
+ json::CellType::Air => assert!(lava_at == Some(false)),
+ json::CellType::Lava => assert!(lava_at == Some(true)),
+ json::CellType::DeepSpace => assert!(lava_at == None),
+ json::CellType::Dirt => assert!(lava_at.is_some()),
+ };
+ }
+ }
}
pub fn simulate(&mut self, moves: [Command; 2]) {