Fix Some Bugs

This commit is contained in:
Dragon Fire
2020-03-17 17:01:35 -04:00
parent 22870f4c02
commit f9bece1eb2
+3 -2
View File
@@ -60,6 +60,7 @@ module.exports = class ConnectFourCommand extends Command {
const filter = res => { const filter = res => {
const choice = res.content; const choice = res.content;
if (choice.toLowerCase() === 'end') return true; if (choice.toLowerCase() === 'end') return true;
if (!board[Number.parseInt(choice, 10) - 1]) return false;
if (!board[Number.parseInt(choice, 10) - 1].includes(null)) return false; if (!board[Number.parseInt(choice, 10) - 1].includes(null)) return false;
return res.author.id === user.id; return res.author.id === user.id;
}; };
@@ -78,7 +79,7 @@ module.exports = class ConnectFourCommand extends Command {
break; break;
} }
const i = Number.parseInt(choice, 10) - 1; const i = Number.parseInt(choice, 10) - 1;
board[i][board[i][6]] = sign; board[i][5 - board[i][6]] = sign;
board[i][6] += 1; board[i][6] += 1;
if (this.verifyWin(board)) winner = userTurn ? msg.author : opponent; if (this.verifyWin(board)) winner = userTurn ? msg.author : opponent;
userTurn = !userTurn; userTurn = !userTurn;
@@ -132,6 +133,6 @@ module.exports = class ConnectFourCommand extends Command {
if (piece === 'user') return playerOneEmoji; if (piece === 'user') return playerOneEmoji;
if (piece === 'oppo') return playerTwoEmoji; if (piece === 'oppo') return playerTwoEmoji;
return blankEmoji; return blankEmoji;
}).join(' ')).join('\n'); }).join('')).join('\n');
} }
}; };