summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-06-28 22:46:39 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-06-28 22:46:39 +0200
commit4c5331b9b5633fd500c79ada42fc08b3cb986631 (patch)
tree60c50ff32a285a4e99eb651032b03e731d1dca3c /src
parenta07cbfd67849b98a881f930e12e07c429e604ac4 (diff)
Fixed issues identified through comparison with the official engine
Diffstat (limited to 'src')
-rw-r--r--src/constants.rs176
-rw-r--r--src/game.rs16
2 files changed, 145 insertions, 47 deletions
diff --git a/src/constants.rs b/src/constants.rs
index fd1263a..2d5d161 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -2,46 +2,145 @@ use crate::geometry::Vec2d;
pub const MAP_SIZE: usize = 33;
pub const MAP_ROW_SIZE: [MapRow; MAP_SIZE] = [
- MapRow { start_bit: 0, x_offset: 11 },
- MapRow { start_bit: 11, x_offset: 8 },
- MapRow { start_bit: 28, x_offset: 7 },
- MapRow { start_bit: 47, x_offset: 6 },
- MapRow { start_bit: 68, x_offset: 4 },
- MapRow { start_bit: 93, x_offset: 4 },
- MapRow { start_bit: 118, x_offset: 3 },
- MapRow { start_bit: 145, x_offset: 2 },
- MapRow { start_bit: 174, x_offset: 1 },
- MapRow { start_bit: 205, x_offset: 1 },
- MapRow { start_bit: 236, x_offset: 1 },
- MapRow { start_bit: 267, x_offset: 0 },
- MapRow { start_bit: 300, x_offset: 0 },
- MapRow { start_bit: 333, x_offset: 0 },
- MapRow { start_bit: 366, x_offset: 0 },
- MapRow { start_bit: 399, x_offset: 0 },
- MapRow { start_bit: 432, x_offset: 0 },
- MapRow { start_bit: 465, x_offset: 0 },
- MapRow { start_bit: 498, x_offset: 0 },
- MapRow { start_bit: 531, x_offset: 0 },
- MapRow { start_bit: 564, x_offset: 0 },
- MapRow { start_bit: 597, x_offset: 0 },
- MapRow { start_bit: 630, x_offset: 1 },
- MapRow { start_bit: 661, x_offset: 1 },
- MapRow { start_bit: 692, x_offset: 1 },
- MapRow { start_bit: 723, x_offset: 2 },
- MapRow { start_bit: 752, x_offset: 3 },
- MapRow { start_bit: 779, x_offset: 4 },
- MapRow { start_bit: 804, x_offset: 4 },
- MapRow { start_bit: 829, x_offset: 6 },
- MapRow { start_bit: 850, x_offset: 7 },
- MapRow { start_bit: 869, x_offset: 8 },
- MapRow { start_bit: 886, x_offset: 11 },
+ MapRow {
+ start_bit: 0,
+ x_offset: 11,
+ },
+ MapRow {
+ start_bit: 11,
+ x_offset: 8,
+ },
+ MapRow {
+ start_bit: 28,
+ x_offset: 7,
+ },
+ MapRow {
+ start_bit: 47,
+ x_offset: 6,
+ },
+ MapRow {
+ start_bit: 68,
+ x_offset: 4,
+ },
+ MapRow {
+ start_bit: 93,
+ x_offset: 4,
+ },
+ MapRow {
+ start_bit: 118,
+ x_offset: 3,
+ },
+ MapRow {
+ start_bit: 145,
+ x_offset: 2,
+ },
+ MapRow {
+ start_bit: 174,
+ x_offset: 1,
+ },
+ MapRow {
+ start_bit: 205,
+ x_offset: 1,
+ },
+ MapRow {
+ start_bit: 236,
+ x_offset: 1,
+ },
+ MapRow {
+ start_bit: 267,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 300,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 333,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 366,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 399,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 432,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 465,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 498,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 531,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 564,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 597,
+ x_offset: 0,
+ },
+ MapRow {
+ start_bit: 630,
+ x_offset: 1,
+ },
+ MapRow {
+ start_bit: 661,
+ x_offset: 1,
+ },
+ MapRow {
+ start_bit: 692,
+ x_offset: 1,
+ },
+ MapRow {
+ start_bit: 723,
+ x_offset: 2,
+ },
+ MapRow {
+ start_bit: 752,
+ x_offset: 3,
+ },
+ MapRow {
+ start_bit: 779,
+ x_offset: 4,
+ },
+ MapRow {
+ start_bit: 804,
+ x_offset: 4,
+ },
+ MapRow {
+ start_bit: 829,
+ x_offset: 6,
+ },
+ MapRow {
+ start_bit: 850,
+ x_offset: 7,
+ },
+ MapRow {
+ start_bit: 869,
+ x_offset: 8,
+ },
+ MapRow {
+ start_bit: 886,
+ x_offset: 11,
+ },
];
pub const MAP_BITSIZE: usize = 897;
pub const MAP_U64S: usize = 15;
pub struct MapRow {
pub start_bit: usize,
- pub x_offset: usize
+ pub x_offset: usize,
}
impl MapRow {
@@ -54,7 +153,6 @@ impl MapRow {
}
}
-
pub const BOMB_DAMAGED_SPACES: usize = 13;
pub const BOMB_DAMAGES: [(Vec2d<i8>, i32); BOMB_DAMAGED_SPACES] = [
(Vec2d::new(0, -2), 7),
@@ -66,8 +164,8 @@ pub const BOMB_DAMAGES: [(Vec2d<i8>, i32); BOMB_DAMAGED_SPACES] = [
(Vec2d::new(-1, 1), 11),
(Vec2d::new(-1, -1), 11),
(Vec2d::new(0, -1), 13),
- (Vec2d::new(0, -1), 13),
- (Vec2d::new(0, -1), 13),
- (Vec2d::new(0, -1), 13),
- (Vec2d::new(0, 0), 20)
+ (Vec2d::new(1, 0), 13),
+ (Vec2d::new(0, 1), 13),
+ (Vec2d::new(-1, 0), 13),
+ (Vec2d::new(0, 0), 20),
];
diff --git a/src/game.rs b/src/game.rs
index e3caf4e..2f7e5de 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -306,6 +306,8 @@ impl GameBoard {
fn simulate_bombs(&mut self, actions: [Action; 2]) {
// NB: Damage radius has the cell distance rounded UP, throwing range has the cell distance rounded DOWN
+ // TODO: Destroy health packs
+
for player_index in 0..actions.len() {
if let Action::Bomb(p) = actions[player_index] {
if self.map.at(p).is_some() {
@@ -323,6 +325,7 @@ impl GameBoard {
if self.map.at(target) == Some(true) {
self.map.clear(target);
// TODO: How does this score get assigned if both players lobbed a banana?
+ // (answer, currently all to A, but watch https://forum.entelect.co.za/t/scoring-with-simultaneous-banana-digs/766/1
self.players[player_index].moves_score += 7;
}
@@ -333,11 +336,10 @@ impl GameBoard {
if let Some(target_worm) = target_own_worm {
target_worm.health -= weapon_damage;
+ self.players[player_index].moves_score -= weapon_damage * 2;
if target_worm.health <= 0 {
self.players[player_index].moves_score -= 40;
self.occupied_cells.remove(&target_worm.position);
- } else {
- self.players[player_index].moves_score -= weapon_damage * 2;
}
}
@@ -348,11 +350,10 @@ impl GameBoard {
.find(|w| w.position == target);
if let Some(target_worm) = target_opponent_worm {
target_worm.health -= weapon_damage;
+ self.players[player_index].moves_score += weapon_damage * 2;
if target_worm.health <= 0 {
self.players[player_index].moves_score += 40;
self.occupied_cells.remove(&target_worm.position);
- } else {
- self.players[player_index].moves_score += weapon_damage * 2;
}
}
}
@@ -387,11 +388,10 @@ impl GameBoard {
if let Some(target_worm) = target_own_worm {
target_worm.health -= weapon_damage;
+ self.players[player_index].moves_score -= weapon_damage * 2;
if target_worm.health <= 0 {
self.players[player_index].moves_score -= 40;
self.occupied_cells.remove(&target_worm.position);
- } else {
- self.players[player_index].moves_score -= weapon_damage * 2;
}
continue 'players_loop;
}
@@ -401,13 +401,13 @@ impl GameBoard {
.worms
.iter_mut()
.find(|w| w.position == target);
+
if let Some(target_worm) = target_opponent_worm {
target_worm.health -= weapon_damage;
+ self.players[player_index].moves_score += weapon_damage * 2;
if target_worm.health <= 0 {
self.players[player_index].moves_score += 40;
self.occupied_cells.remove(&target_worm.position);
- } else {
- self.players[player_index].moves_score += weapon_damage * 2;
}
continue 'players_loop;