Skip to content

Commit

Permalink
en passant fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubBraz committed Sep 18, 2024
1 parent d0e24f2 commit 83762ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion game_logic/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ impl Board {
self.squares[move_to.0][move_to.1] = Some(Piece { color: Black, kind: PieceType::Queen });
}
else if move_from.1 + 1 == move_to.1 || move_to.1 + 1 == move_from.1 {
self.squares[move_from.0][move_to.1] = None;
if self.squares[move_from.0][move_to.1].is_some_and(|x| x.kind == PieceType::Pawn && x.color != piece.color) {
self.squares[move_from.0][move_to.1] = None;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions game_logic/src/game_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ pub fn handle_game(receiver: Receiver<ChannelMsg>) {
White
}
};
board.color_to_play() == player_color && allowed_moves(board, move_from.0, move_from.1, player_color).contains(&move_to)
// allowed_moves(board, move_from.0, move_from.1, player_color).contains(&move_to)
// board.color_to_play() == player_color && allowed_moves(board, move_from.0, move_from.1, player_color).contains(&move_to)
allowed_moves(board, move_from.0, move_from.1, player_color).contains(&move_to)
}
_ => false
};
Expand Down

0 comments on commit 83762ad

Please sign in to comment.