summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-07-01 22:28:14 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-07-01 22:28:14 +0200
commit709bd0b9be0eeed4ad204c121fcadef505d5336d (patch)
treeef4ef802e5ef0fcd26306b8aa270e91a816ec419 /src
parentc4fe897b41f90a53e0629e2444d3e7f2121cddde (diff)
Read missiles from the json into bitfields
Diffstat (limited to 'src')
-rw-r--r--src/input/json.rs13
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;
}
}
}