X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FCannibal.js;h=1a8a45183b69550e957ce70614f13c1d1b34944c;hb=801e28709e778bd3a93b014d1f9cb2fb7906e303;hp=a08f197547d88ded964ede5635136b3d463df19a;hpb=6f2f94374f1e73c375edf732d9425e575e81fff7;p=vchess.git diff --git a/client/src/variants/Cannibal.js b/client/src/variants/Cannibal.js index a08f1975..1a8a4518 100644 --- a/client/src/variants/Cannibal.js +++ b/client/src/variants/Cannibal.js @@ -88,7 +88,7 @@ export class CannibalRules extends ChessRules { return moves.filter(m => m.vanish.length == 2 && m.appear.length == 1); } - // Stop at the first capture found (if any) + // Stop at the first capture found (if any) atLeastOneCapture() { const color = this.turn; const oppCol = V.GetOppCol(color); @@ -207,8 +207,9 @@ export class CannibalRules extends ChessRules { this.kingPos[c][0] = move.appear[0].x; this.kingPos[c][1] = move.appear[0].y; this.castleFlags[c] = [V.size.y, V.size.y]; - return; } + // Next call is still required because the king may eat an opponent's rook + // TODO: castleFlags will be turned off twice then. super.updateCastleFlags(move, piece); } @@ -231,7 +232,18 @@ export class CannibalRules extends ChessRules { }; } - static get SEARCH_DEPTH() { - return 4; + getNotation(move) { + let notation = super.getNotation(move); + const lastRank = (move.appear[0].c == "w" ? 0 : 7); + if ( + move.end.x != lastRank && + this.getPiece(move.start.x, move.start.y) == V.PAWN && + move.vanish.length == 2 && + move.appear[0].p != V.PAWN + ) { + // Fix "promotion" (transform indicator) from base_rules notation + notation = notation.slice(0, -2); + } + return notation; } };