fix: replace item parameter with player in check_win

This commit is contained in:
landrigun 2022-11-15 08:47:48 +00:00
parent 4dff19228d
commit 5f5f34a52f

View File

@ -141,7 +141,8 @@ impl Board {
} }
/// instead of scanning all the board, checks input "win" combinaison /// 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 { match idx {
0 => { 0 => {
self.check_first_col(item) self.check_first_col(item)
@ -451,7 +452,7 @@ impl TicTacToe {
} }
// check after the 5th round if there's a winner // 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)); info(format!("{} wins!", item_icon));
self.board.show(); self.board.show();
break; break;