fix: replace item parameter with player in check_win
This commit is contained in:
+3
-2
@@ -141,7 +141,8 @@ impl Board {
|
||||
}
|
||||
|
||||
/// instead of scanning all the board, checks input "win" combinaison
|
||||
fn check_win(&self, item: Item, idx: usize) -> bool {
|
||||
fn check_win(&self, player: Player, idx: usize) -> bool {
|
||||
let item = player.item;
|
||||
match idx {
|
||||
0 => {
|
||||
self.check_first_col(item)
|
||||
@@ -451,7 +452,7 @@ impl TicTacToe {
|
||||
}
|
||||
|
||||
// check after the 5th round if there's a winner
|
||||
if self.turn > 4 && self.board.check_win(player.item, item_position - 1) {
|
||||
if self.turn > 4 && self.board.check_win(player, item_position - 1) {
|
||||
info(format!("{} wins!", item_icon));
|
||||
self.board.show();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user