X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAntiking2.js;h=a7ec2a83cdbc1487123a9829770062a6cb83517e;hb=af34341d92d47d14f396e7f4adb81f2a7e9d9a61;hp=087dce35c6e155caf2a3c16dde47828fe5a35121;hpb=bb688df52df0713aba7b2c1c068614544f5ae96d;p=vchess.git diff --git a/client/src/variants/Antiking2.js b/client/src/variants/Antiking2.js index 087dce35..a7ec2a83 100644 --- a/client/src/variants/Antiking2.js +++ b/client/src/variants/Antiking2.js @@ -15,6 +15,19 @@ export class Antiking2Rules extends ChessRules { return b[1] == "a" ? "Antiking/" + b : b; } + static IsGoodPosition(position) { + if (!ChessRules.IsGoodPosition(position)) return false; + const rows = position.split("/"); + // Check that exactly one antiking of each color is there: + let antikings = { 'a': 0, 'A': 0 }; + for (let row of rows) { + for (let i = 0; i < row.length; i++) + if (['A','a'].includes(row[i])) antikings[row[i]]++; + } + if (Object.values(antikings).some(v => v != 1)) return false; + return true; + } + setOtherVariables(fen) { super.setOtherVariables(fen); this.antikingPos = { w: [-1, -1], b: [-1, -1] }; @@ -104,7 +117,8 @@ export class Antiking2Rules extends ChessRules { return res; } - getCheckSquares(color) { + getCheckSquares() { + const color = this.turn; let res = []; const oppCol = V.GetOppCol(color); if (this.isAttacked(this.kingPos[color], oppCol))