X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FCheckered1.js;h=fd0d68dffd39f9242432407b321ea8daf6b3d6f9;hp=4556f07b3f6cf2fe0c0c7aee91598a4971eee5e8;hb=165530a519288327f3a6364a43f1b9e73d944a20;hpb=6f10b38369cc92057a25cc0150727aeeeaa6f1d1 diff --git a/client/src/variants/Checkered1.js b/client/src/variants/Checkered1.js index 4556f07b..fd0d68df 100644 --- a/client/src/variants/Checkered1.js +++ b/client/src/variants/Checkered1.js @@ -131,7 +131,7 @@ export class Checkered1Rules extends ChessRules { ); } - getPotentialMovesFrom([x, y]) { + getPotentialMovesFrom([x, y], noswitch) { let standardMoves = super.getPotentialMovesFrom([x, y]); if (this.stage == 1) { const color = this.turn; @@ -141,7 +141,10 @@ export class Checkered1Rules extends ChessRules { // King is treated differently: it never turn checkered if (this.getPiece(x, y) == V.KING) { // If at least one checkered piece, allow switching: - if (this.board.some(b => b.some(cell => cell[0] == 'c'))) { + if ( + !noswitch && + this.board.some(b => b.some(cell => cell[0] == 'c')) + ) { const oppCol = V.GetOppCol(color); moves.push( new Move({ @@ -328,7 +331,7 @@ export class Checkered1Rules extends ChessRules { ) ) ) { - const moves = this.getPotentialMovesFrom([i, j]); + const moves = this.getPotentialMovesFrom([i, j], "noswitch"); if (moves.length > 0) { for (let k = 0; k < moves.length; k++) if (this.filterValid([moves[k]]).length > 0) return true;