From 468ddfa60e58ad6b9fbfd10fb21fa974fe49b8a0 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 19 Jan 2021 06:37:41 -0500 Subject: [PATCH] Fix --- commands/games-mp/connect-four.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/commands/games-mp/connect-four.js b/commands/games-mp/connect-four.js index 650c83b3..7b7bab96 100644 --- a/commands/games-mp/connect-four.js +++ b/commands/games-mp/connect-four.js @@ -122,25 +122,22 @@ module.exports = class ConnectFourCommand extends Command { max: 1, time: 60000 }); - if (!turn.size) { + const choice = turn ? turn.first().content : null; + if (!choice) { await msg.say('Sorry, time is up! I\'ll pick their move for them.'); i = AIEngine.playAI('hard'); lastMove = i + 1; - continue; - } - const choice = turn.first().content; - if (choice.toLowerCase() === 'end') { + } else if (choice.toLowerCase() === 'end') { winner = userTurn ? opponent : msg.author; break; - } - if (choice.toLowerCase() === 'play for me') { + } else if (choice.toLowerCase() === 'play for me') { i = AIEngine.playAI('hard'); lastMove = i + 1; - continue; + } else { + i = Number.parseInt(choice, 10) - 1; + AIEngine.play(i); + lastMove = i + 1; } - i = Number.parseInt(choice, 10) - 1; - AIEngine.play(i); - lastMove = i + 1; } board[colLevels[i]][i] = sign; colLevels[i]--;