X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FKoopa.js;fp=client%2Fsrc%2Fvariants%2FKoopa.js;h=bc72d6df8ad11692dbf67ee910c6d3d5c74b9250;hb=13227d6124e1cf465d329373e32c407d6fd351d3;hp=c7b0859f1c389061695955d6bc3fddbada972570;hpb=c6b7573bc6acc38d54a15a80647b5cca53eeeb4a;p=vchess.git diff --git a/client/src/variants/Koopa.js b/client/src/variants/Koopa.js index c7b0859f..bc72d6df 100644 --- a/client/src/variants/Koopa.js +++ b/client/src/variants/Koopa.js @@ -235,9 +235,10 @@ export class KoopaRules extends ChessRules { // Base method is fine because a stunned king (which won't be detected) // can still castle after going back to normal. super.postPlay(move); - const kIdx = move.vanish.findIndex(v => v.p == "l"); + const kIdx = move.vanish.findIndex( + (v,i) => v.p == 'l' || (i >= 1 && v.p == 'k')); if (kIdx >= 0) - // A stunned king vanish (game over) + // A (stunned or not) king vanish: game over this.kingPos[move.vanish[kIdx].c] = [-1, -1]; move.stunned = JSON.stringify(this.stunned); // Array of stunned stage 1 pieces (just back to normal then) @@ -268,9 +269,10 @@ export class KoopaRules extends ChessRules { postUndo(move) { super.postUndo(move); - const kIdx = move.vanish.findIndex(v => v.p == "l"); + const kIdx = move.vanish.findIndex( + (v,i) => v.p == 'l' || (i >= 1 && v.p == 'k')); if (kIdx >= 0) { - // A stunned king vanished + // A king vanished this.kingPos[move.vanish[kIdx].c] = [move.vanish[kIdx].x, move.vanish[kIdx].y]; }