X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FKoopa.js;h=38b3e885f9958f548b4c1eb3690ff9b6577c3ca3;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=8d4f0e97ff7d9ff6728191797bece4fd87a0263f;hpb=fccaa87852129f8f27c66a9d3b626f91868109c8;p=vchess.git diff --git a/client/src/variants/Koopa.js b/client/src/variants/Koopa.js index 8d4f0e97..38b3e885 100644 --- a/client/src/variants/Koopa.js +++ b/client/src/variants/Koopa.js @@ -1,6 +1,7 @@ import { ChessRules, PiPo } from "@/base_rules"; export class KoopaRules extends ChessRules { + static get HasEnpassant() { return false; } @@ -58,7 +59,6 @@ export class KoopaRules extends ChessRules { // stand for stunned indicator. scanKings(fen) { - this.INIT_COL_KING = { w: -1, b: -1 }; // Squares of white and black king: this.kingPos = { w: [-1, -1], b: [-1, -1] }; const fenRows = V.ParseFen(fen).position.split("/"); @@ -70,12 +70,10 @@ export class KoopaRules extends ChessRules { case "k": case "l": this.kingPos["b"] = [i, k]; - this.INIT_COL_KING["b"] = k; break; case "K": case "L": this.kingPos["w"] = [i, k]; - this.INIT_COL_KING["w"] = k; break; default: { const num = parseInt(fenRows[i].charAt(j), 10); @@ -118,7 +116,17 @@ export class KoopaRules extends ChessRules { } getPotentialMovesFrom([x, y]) { - let moves = super.getPotentialMovesFrom([x, y]); + let moves = super.getPotentialMovesFrom([x, y]).filter(m => { + if ( + m.vanish[0].p != V.PAWN || + m.appear[0].p == V.PAWN || + m.vanish.length == 1 + ) { + return true; + } + // Pawn promotion, "capturing": remove duplicates + return m.appear[0].p == V.QUEEN; + }); // Complete moves: stuns & kicks let promoteAfterStun = []; const color = this.turn; @@ -208,10 +216,8 @@ export class KoopaRules extends ChessRules { getPotentialKingMoves(sq) { return ( this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ).concat(super.getCastleMoves(sq, true, ['r'])) + sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1 + ).concat(super.getCastleMoves(sq, null, true, ['r'])) ); } @@ -359,4 +365,5 @@ export class KoopaRules extends ChessRules { } return notation; } + };