mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
Fix
This commit is contained in:
@@ -104,6 +104,7 @@ module.exports = class ConnectFourCommand extends Command {
|
|||||||
} else {
|
} else {
|
||||||
await msg.say(stripIndents`
|
await msg.say(stripIndents`
|
||||||
${user}, which column do you pick? Type \`end\` to forefeit.
|
${user}, which column do you pick? Type \`end\` to forefeit.
|
||||||
|
Can't think of a move? Use \`play for me\`.
|
||||||
${opponent.bot ? `I placed mine in **${lastMove}**.` : `Previous Move: **${lastMove}**`}
|
${opponent.bot ? `I placed mine in **${lastMove}**.` : `Previous Move: **${lastMove}**`}
|
||||||
|
|
||||||
${this.displayBoard(board, playerOneEmoji, playerTwoEmoji)}
|
${this.displayBoard(board, playerOneEmoji, playerTwoEmoji)}
|
||||||
@@ -113,6 +114,7 @@ module.exports = class ConnectFourCommand extends Command {
|
|||||||
if (res.author.id !== user.id) return false;
|
if (res.author.id !== user.id) return false;
|
||||||
const choice = res.content;
|
const choice = res.content;
|
||||||
if (choice.toLowerCase() === 'end') return true;
|
if (choice.toLowerCase() === 'end') return true;
|
||||||
|
if (choice.toLowerCase() === 'play for me') return true;
|
||||||
const j = Number.parseInt(choice, 10) - 1;
|
const j = Number.parseInt(choice, 10) - 1;
|
||||||
return board[colLevels[j]] && board[colLevels[j]][j] !== undefined;
|
return board[colLevels[j]] && board[colLevels[j]][j] !== undefined;
|
||||||
};
|
};
|
||||||
@@ -124,7 +126,6 @@ module.exports = class ConnectFourCommand extends Command {
|
|||||||
await msg.say('Sorry, time is up! I\'ll pick their move for them.');
|
await msg.say('Sorry, time is up! I\'ll pick their move for them.');
|
||||||
i = AIEngine.playAI('hard');
|
i = AIEngine.playAI('hard');
|
||||||
lastMove = i + 1;
|
lastMove = i + 1;
|
||||||
userTurn = !userTurn;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const choice = turn.first().content;
|
const choice = turn.first().content;
|
||||||
@@ -132,6 +133,11 @@ module.exports = class ConnectFourCommand extends Command {
|
|||||||
winner = userTurn ? opponent : msg.author;
|
winner = userTurn ? opponent : msg.author;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (choice.toLowerCase() === 'play for me') {
|
||||||
|
i = AIEngine.playAI('hard');
|
||||||
|
lastMove = i + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
i = Number.parseInt(choice, 10) - 1;
|
i = Number.parseInt(choice, 10) - 1;
|
||||||
AIEngine.play(i);
|
AIEngine.play(i);
|
||||||
lastMove = i + 1;
|
lastMove = i + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user