From f38ec23b1f72b7eace275c9fff53eb3cb9ea9505 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 7 Feb 2021 13:05:52 -0500 Subject: [PATCH] Properly detect stalemate --- commands/games-mp/chess.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/games-mp/chess.js b/commands/games-mp/chess.js index da3cbd28..a1fcae39 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])|(?:[PKRQBNX]))?([A-H])?(?: |, ?|-?>?)?([A-H][1-8])$/; +const turnRegex = /^((?:[A-H][1-8])|(?:[PKRQBNX]))?([A-H])?(?: |, ?|-?>?)?([A-H][1-8])(=[QRNB])?$/; const pieces = ['pawn', 'rook', 'knight', 'king', 'queen', 'bishop']; const cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']; @@ -181,7 +181,7 @@ module.exports = class ChessCommand extends Command { fiftyRuleMove++; } game.move(choice[0], choice[1]); - if (!game.moves().length) stalemate = true; + if (!Object.keys(game.moves()).length) stalemate = true; } } this.client.games.delete(msg.channel.id);