X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDoublemove2.js;h=4801d367792d84c35f1098c2422b9c9d4400dd12;hp=7f3f6cecf26f0692babcbbf99eef42bfeb7f8eae;hb=964eda04ad6415b4ec95387ea08b63a3d0f0f9cc;hpb=032ecd58543d1182b41da0c45b272e99a3014ad8 diff --git a/client/src/variants/Doublemove2.js b/client/src/variants/Doublemove2.js index 7f3f6cec..4801d367 100644 --- a/client/src/variants/Doublemove2.js +++ b/client/src/variants/Doublemove2.js @@ -110,7 +110,13 @@ export class Doublemove2Rules extends ChessRules { else { this.epSquares.push([epSq]); this.movesCount++; - if (this.movesCount == 1) this.turn = "b"; + if ( + this.movesCount == 1 || + // King is captured at subTurn 1? + (move.vanish.length == 2 && move.vanish[1].p == V.KING) + ) { + this.turn = "b"; + } } if (this.movesCount > 1) this.subTurn = 3 - this.subTurn; this.postPlay(move); @@ -127,9 +133,11 @@ export class Doublemove2Rules extends ChessRules { return; } const oppCol = V.GetOppCol(c); - if (move.vanish.length == 2 && move.vanish[1].p == V.KING) + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) { // Opponent's king is captured, game over this.kingPos[oppCol] = [-1, -1]; + move.captureKing = true; //for undo + } const oppFirstRank = V.size.x - 1 - firstRank; if ( move.start.x == firstRank && //our rook moves? @@ -150,7 +158,7 @@ export class Doublemove2Rules extends ChessRules { undo(move) { this.disaggregateFlags(JSON.parse(move.flags)); V.UndoOnBoard(this.board, move); - if (this.subTurn == 2 || this.movesCount == 1) { + if (this.subTurn == 2 || this.movesCount == 1 || !!move.captureKing) { this.epSquares.pop(); this.movesCount--; if (this.movesCount == 0) this.turn = "w";