fix: replace item parameter with player in check_win
This commit is contained in:
parent
4dff19228d
commit
5f5f34a52f
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user