commit 57f23f2159ac2481e1071146d003dc79c81ce2e5
parent 22f8b060235980ba77ffe1ebecaafae07b57d304
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date: Fri, 27 Dec 2019 08:44:00 +1300
Fix: Movement filtering.\nFiltering was including allied pieces, and the predicate logic was incorrect.
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -88,7 +88,6 @@ impl EventHandler for Game {
moved,
}) = self.board.0[y as usize][x as usize].take()
{
- println!("{:?} {:?}", unit, player);
self.board.0[row as usize][col as usize] = Some(Piece {
unit: unit,
player: player,
@@ -343,7 +342,7 @@ impl Game {
None => vec![],
}
.into_iter()
- .filter(|(x, y)| self.contains_ally((*x, *y)))
+ .filter(|(x, y)| !self.contains_ally((*x, *y)))
.collect()
}
/// Contains enemy if the specified position is occupied by a piece owned
@@ -366,7 +365,7 @@ impl Game {
if x > -1 && y > -1 && x - 1 < 7 && y - 1 < 7 {
match &self.board.0[y as usize][x as usize] {
Some(Piece { player, .. }) => *player == self.turn,
- None => true,
+ None => false,
}
} else {
false