From 3bba8e6898bce1ff83f94664e5cc390f488cb2c2 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 7 Feb 2021 12:47:46 -0500 Subject: [PATCH] Fix --- commands/games-mp/chess.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/games-mp/chess.js b/commands/games-mp/chess.js index 4aa2551c..99d844f0 100644 --- a/commands/games-mp/chess.js +++ b/commands/games-mp/chess.js @@ -7,7 +7,7 @@ const path = require('path'); const { verify, reactIfAble } = require('../../util/Util'); const { centerImagePart } = require('../../util/Canvas'); const { FAILURE_EMOJI_ID } = process.env; -const turnRegex = /^((?:[A-H][1-8])|(?:[PKRQBN]))?([A-H])?(?: |, ?|-?>?)?([A-H][1-8])$/; +const turnRegex = /^((?:[A-H][1-8])|(?:[PKRQBNX]))?([A-H])?(?: |, ?|-?>?)?([A-H][1-8])$/; const pieces = ['pawn', 'rook', 'knight', 'king', 'queen', 'bishop']; const cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']; @@ -208,8 +208,9 @@ module.exports = class ChessCommand extends Command { const initial = move[1] || 'P'; if (gameState.pieces[initial]) return [initial, move[3]]; const possiblePieces = Object.keys(gameState.pieces).filter(piece => { - if (gameState.pieces[piece] !== initial) return false; - if (move[2] && !piece.startsWith(move[2])) return false; + if (this.pickImage(gameState.pieces[piece]).color !== gameState.turn) return false; + if (gameState.pieces[piece].toUpperCase() !== initial) return false; + if (move[2] && move[2] !== 'X' && !piece.startsWith(move[2])) return false; if (!moves[piece]) return false; return moves[piece].includes(move[3]); });