From 4457ade7072d5ff910c8bdd4bf51b05e181c469e Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 23 Mar 2024 23:27:14 -0400 Subject: [PATCH] Fix --- commands/games-mp/tic-tac-toe.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/commands/games-mp/tic-tac-toe.js b/commands/games-mp/tic-tac-toe.js index 5ae982ac..aa8b0e77 100644 --- a/commands/games-mp/tic-tac-toe.js +++ b/commands/games-mp/tic-tac-toe.js @@ -47,6 +47,7 @@ module.exports = class TicTacToeCommand extends Command { const sign = userTurn ? 'X' : 'O'; let choice; if (opponent.bot && !userTurn) { + // eslint-disable-next-line new-cap choice = ComputerMove(this.convertBoard(sides), { aiPlayer: 'o', huPlayer: 'x' }, 'Hard'); } else { await msg.say(stripIndents` @@ -104,14 +105,14 @@ module.exports = class TicTacToeCommand extends Command { playerWon(board, player) { if ( - (board[0] === player && board[1] === player && board[2] === player) || - (board[3] === player && board[4] === player && board[5] === player) || - (board[6] === player && board[7] === player && board[8] === player) || - (board[0] === player && board[3] === player && board[6] === player) || - (board[1] === player && board[4] === player && board[7] === player) || - (board[2] === player && board[5] === player && board[8] === player) || - (board[0] === player && board[4] === player && board[8] === player) || - (board[2] === player && board[4] === player && board[6] === player) + (board[0] === player && board[1] === player && board[2] === player) + || (board[3] === player && board[4] === player && board[5] === player) + || (board[6] === player && board[7] === player && board[8] === player) + || (board[0] === player && board[3] === player && board[6] === player) + || (board[1] === player && board[4] === player && board[7] === player) + || (board[2] === player && board[5] === player && board[8] === player) + || (board[0] === player && board[4] === player && board[8] === player) + || (board[2] === player && board[4] === player && board[6] === player) ) return true; return false; } @@ -124,16 +125,16 @@ module.exports = class TicTacToeCommand extends Command { convertBoard(board) { const newBoard = []; - let col = 0; + let num = 0; for (const piece of board) { if (piece === 'X') { - newBoard.push('x'); + newBoard.push('X'); } else if (piece === 'O') { - newBoard.push('o'); + newBoard.push('O'); } else { - newBoard.push('_'); + newBoard.push(num); } - if (newBoard.length === 3) col++; + num++; } return newBoard; }