X-Git-Url: https://git.auder.net/pieces/Checkered/cq.svg?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FPacosako.js;h=bf847199256520876590623bbf359f2cb4b364b1;hb=057e34c4b970db0b1b19dcb44ec58ec7afdb9bc0;hp=2048d2c052db73819d9b1c4875e0ff0380dfb1fc;hpb=4a2093139089632727de4f510127ef186cab528e;p=vchess.git diff --git a/client/src/variants/Pacosako.js b/client/src/variants/Pacosako.js index 2048d2c0..bf847199 100644 --- a/client/src/variants/Pacosako.js +++ b/client/src/variants/Pacosako.js @@ -405,6 +405,23 @@ export class PacosakoRules extends ChessRules { return moves; } + getPotentialKingMoves(sq) { + let moves = this.getSlideNJumpMoves( + sq, + V.steps[V.ROOK].concat(V.steps[V.BISHOP]), + "oneStep" + ); + const c = this.turn; + const oppCol = V.GetOppCol(c); + if ( + !this.isAttacked(this.kingPos[c], oppCol) && + this.castleFlags[c].some(v => v < V.size.y) + ) { + moves = moves.concat(super.getCastleMoves(sq, null, true)); + } + return moves; + } + getEpSquare(moveOrSquare) { if (typeof moveOrSquare === "string") { const square = moveOrSquare; @@ -455,6 +472,7 @@ export class PacosakoRules extends ChessRules { } play(move) { + move.flags = JSON.stringify(this.aggregateFlags()); this.epSquares.push(this.getEpSquare(move)); // Check if the move is the last of the turn: all cases except releases if (!move.released) { @@ -482,6 +500,7 @@ export class PacosakoRules extends ChessRules { undo(move) { this.epSquares.pop(); + this.disaggregateFlags(JSON.parse(move.flags)); V.UndoOnBoard(this.board, move); this.lastMoveEnd.pop(); if (!move.released) {