From 1bcd92712809d8195662b60471230d256d5ee2ea Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 23 Mar 2024 23:44:14 -0400 Subject: [PATCH] Reduce complexity --- commands/games-mp/tic-tac-toe.js | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/commands/games-mp/tic-tac-toe.js b/commands/games-mp/tic-tac-toe.js index d5634dd7..7da31e34 100644 --- a/commands/games-mp/tic-tac-toe.js +++ b/commands/games-mp/tic-tac-toe.js @@ -37,7 +37,7 @@ module.exports = class TicTacToeCommand extends Command { return msg.say('Looks like they declined...'); } } - const sides = ['1', '2', '3', '4', '5', '6', '7', '8', '9']; + const sides = [0, 1, 2, 3, 4, 5, 6, 7, 8]; const taken = []; let userTurn = true; let winner = null; @@ -48,7 +48,7 @@ module.exports = class TicTacToeCommand extends Command { let choice; if (opponent.bot && !userTurn) { // eslint-disable-next-line new-cap - choice = ComputerMove(this.convertBoard(sides), { aiPlayer: 'O', huPlayer: 'X' }, 'Hard'); + choice = ComputerMove(sides, { aiPlayer: 'O', huPlayer: 'X' }, 'Hard'); } else { await msg.say(stripIndents` ${user}, which side do you pick? Type \`end\` to forfeit. @@ -124,22 +124,6 @@ module.exports = class TicTacToeCommand extends Command { return null; } - convertBoard(board) { - const newBoard = []; - let num = 0; - for (const piece of board) { - if (piece === 'X') { - newBoard.push('X'); - } else if (piece === 'O') { - newBoard.push('O'); - } else { - newBoard.push(num); - } - num++; - } - return newBoard; - } - displayBoard(board) { let str = ''; for (let i = 0; i < board.length; i++) {