diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2020-04-20 20:03:48 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2020-04-20 20:03:48 +0200 |
commit | 52ade984643c6482ccf0deeea98f7f63fa74045d (patch) | |
tree | 7fdac25e3f5cae097d7053f2d8dd284d6d49b4ee /src/json.rs | |
parent | 7f2d82e15459fc3d365674e3772aed6c3d443ca2 (diff) |
Split oils and muds into their own lists
Now memory for one isn't affected by memory usage of the other!
Diffstat (limited to 'src/json.rs')
-rw-r--r-- | src/json.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/json.rs b/src/json.rs index a7d7759..82fc9fc 100644 --- a/src/json.rs +++ b/src/json.rs @@ -104,14 +104,19 @@ impl JsonState { Ok(GameState { status: GameStatus::Continue, players: [self.player.to_player()?, self.opponent.to_player()], - obstacles: Rc::new( + muds: Rc::new( self.world_map .iter() .flatten() - .filter(|cell| { - cell.surface_object == JsonSurfaceObject::Mud - || cell.surface_object == JsonSurfaceObject::OilSpill - }) + .filter(|cell| cell.surface_object == JsonSurfaceObject::Mud) + .map(|cell| cell.position.to_position()) + .collect(), + ), + oil_spills: Rc::new( + self.world_map + .iter() + .flatten() + .filter(|cell| cell.surface_object == JsonSurfaceObject::OilSpill) .map(|cell| cell.position.to_position()) .collect(), ), |