From 7721a36a50b840b1dfe4cfaf5ed7abcbf525ffd5 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Tue, 16 Feb 2021 23:04:38 +0100 Subject: [PATCH] Fix Pandemonium + Janggi (first move) --- client/src/variants/Janggi.js | 8 ++++++-- client/src/variants/Pandemonium.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/src/variants/Janggi.js b/client/src/variants/Janggi.js index 27342422..aecc8fe2 100644 --- a/client/src/variants/Janggi.js +++ b/client/src/variants/Janggi.js @@ -107,8 +107,12 @@ export class JanggiRules extends ChessRules { if (this.movesCount <= 1) { const firstRank = (this.movesCount == 0 ? 9 : 0); const initDestFile = new Map([[1, 2], [7, 6]]); - // Only option is knight / elephant swap: - if (x == firstRank && !!initDestFile.get(y)) { + // Only option is knight --> elephant swap: + if ( + x == firstRank && + !!initDestFile.get(y) && + this.getPiece(x, y) == V.KNIGHT + ) { const destFile = initDestFile.get(y); moves.push( new Move({ diff --git a/client/src/variants/Pandemonium.js b/client/src/variants/Pandemonium.js index 7795a7b1..f4ae3c44 100644 --- a/client/src/variants/Pandemonium.js +++ b/client/src/variants/Pandemonium.js @@ -287,8 +287,12 @@ export class PandemoniumRules extends ChessRules { const firstRank = (this.movesCount == 0 ? 9 : 0); // TODO: initDestFile currently hardcoded for deterministic setup const initDestFile = new Map([[1, 2], [8, 7]]); - // Only option is knight / bishop swap: - if (x == firstRank && !!initDestFile.get(y)) { + // Only option is knight --> bishop swap: + if ( + x == firstRank && + !!initDestFile.get(y) && + this.getPiece(x, y) == V.KNIGHT + ) { const destFile = initDestFile.get(y); return [ new Move({ -- 2.44.0