X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAntiking1.js;h=92034a307279f47c2c96701105bf40f32798aea3;hb=7e8a7ea1cb66adb4a987badfb0a3c2f99a21bd0a;hp=3aa02d35f5b8095597bf7a3e8e1a585eee677166;hpb=bb688df52df0713aba7b2c1c068614544f5ae96d;p=vchess.git diff --git a/client/src/variants/Antiking1.js b/client/src/variants/Antiking1.js index 3aa02d35..92034a30 100644 --- a/client/src/variants/Antiking1.js +++ b/client/src/variants/Antiking1.js @@ -4,6 +4,7 @@ import { ArrayFun } from "@/utils/array"; import { randInt } from "@/utils/alea"; export class Antiking1Rules extends BerolinaRules { + static get PawnSpecs() { return Object.assign( {}, @@ -28,6 +29,19 @@ export class Antiking1Rules extends BerolinaRules { 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] }; @@ -43,7 +57,7 @@ export class Antiking1Rules extends BerolinaRules { this.antikingPos["w"] = [i, k]; break; default: { - const num = parseInt(rows[i].charAt(j)); + const num = parseInt(rows[i].charAt(j), 10); if (!isNaN(num)) k += num - 1; } } @@ -163,7 +177,8 @@ export class Antiking1Rules extends BerolinaRules { return res; } - getCheckSquares(color) { + getCheckSquares() { + const color = this.turn; let res = []; const oppCol = V.GetOppCol(color); if (this.isAttacked(this.kingPos[color], oppCol)) @@ -207,4 +222,5 @@ export class Antiking1Rules extends BerolinaRules { static get SEARCH_DEPTH() { return 2; } + };