diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-07-01 22:28:14 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-07-01 22:28:14 +0200 |
commit | 709bd0b9be0eeed4ad204c121fcadef505d5336d (patch) | |
tree | ef4ef802e5ef0fcd26306b8aa270e91a816ec419 /src | |
parent | c4fe897b41f90a53e0629e2444d3e7f2121cddde (diff) |
Read missiles from the json into bitfields
Diffstat (limited to 'src')
-rw-r--r-- | src/input/json.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/input/json.rs b/src/input/json.rs index 0c0ed48..b509926 100644 --- a/src/input/json.rs +++ b/src/input/json.rs @@ -198,8 +198,19 @@ impl State { } } for missile in &cell.missiles { - if missile.player_type == 'A' { + let mut bitwise_buildings = if missile.player_type == 'A' { + &mut player_buildings } else { + &mut opponent_buildings + }; + let (mut left, mut right) = point.to_bitfield(8); + + for mut tier in bitwise_buildings.missiles.iter_mut() { + let setting = (!tier.0 & left, !tier.1 & right); + tier.0 |= setting.0; + tier.1 |= setting.1; + left &= !setting.0; + right &= !setting.1; } } } |