mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 14:20:51 +02:00
Better looking tic-tac-toe
This commit is contained in:
@@ -4,7 +4,7 @@ const { stripIndents } = require('common-tags');
|
||||
const { verify, list } = require('../../util/Util');
|
||||
const { LOADING_EMOJI_ID } = process.env;
|
||||
const blankEmoji = '⚪';
|
||||
const nums = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣'];
|
||||
const nums = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣'];
|
||||
const colors = require('../../assets/json/connect-four');
|
||||
colors.loading = `<a:loading:${LOADING_EMOJI_ID}>`;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const tictactoe = require('tictactoe-minimax-ai');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { verify } = require('../../util/Util');
|
||||
const nums = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣'];
|
||||
|
||||
module.exports = class TicTacToeCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -48,13 +49,8 @@ module.exports = class TicTacToeCommand extends Command {
|
||||
} else {
|
||||
await msg.say(stripIndents`
|
||||
${user}, which side do you pick? Type \`end\` to forefeit.
|
||||
\`\`\`
|
||||
${sides[0]} | ${sides[1]} | ${sides[2]}
|
||||
—————————
|
||||
${sides[3]} | ${sides[4]} | ${sides[5]}
|
||||
—————————
|
||||
${sides[6]} | ${sides[7]} | ${sides[8]}
|
||||
\`\`\`
|
||||
|
||||
${this.displayBoard(sides)}
|
||||
`);
|
||||
const filter = res => {
|
||||
if (res.author.id !== user.id) return false;
|
||||
@@ -119,4 +115,19 @@ module.exports = class TicTacToeCommand extends Command {
|
||||
}
|
||||
return newBoard;
|
||||
}
|
||||
|
||||
displayBoard(board) {
|
||||
let str = '';
|
||||
for (let i = 0; i < board.length; i++) {
|
||||
if (board[i] === 'X') {
|
||||
str += '❌';
|
||||
} else if (board[i] === 'O') {
|
||||
str += '⭕';
|
||||
} else {
|
||||
str += nums[i];
|
||||
}
|
||||
if (i % 3 === 2) str += '\n';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "124.5.4",
|
||||
"version": "124.5.5",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user