From 0945252b7241b6521e5eac0fa7cb27437f192649 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 9 Jan 2021 18:23:07 -0500 Subject: [PATCH] Better looking tic-tac-toe --- commands/games-mp/connect-four.js | 2 +- commands/games-mp/tic-tac-toe.js | 25 ++++++++++++++++++------- package.json | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/commands/games-mp/connect-four.js b/commands/games-mp/connect-four.js index 46c7c20c..a2a1c4b8 100644 --- a/commands/games-mp/connect-four.js +++ b/commands/games-mp/connect-four.js @@ -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 = ``; diff --git a/commands/games-mp/tic-tac-toe.js b/commands/games-mp/tic-tac-toe.js index 5d0dd489..8404f298 100644 --- a/commands/games-mp/tic-tac-toe.js +++ b/commands/games-mp/tic-tac-toe.js @@ -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; + } }; diff --git a/package.json b/package.json index ecac2137..1b0f1542 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "124.5.4", + "version": "124.5.5", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {