X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAntiking2.js;h=fa0bbcc45fcfe7042204317d9b77c867c16e44c0;hb=HEAD;hp=2dad5e4912ba1bc68a0009c25281ac3c12173540;hpb=6f2f94374f1e73c375edf732d9425e575e81fff7;p=vchess.git diff --git a/client/src/variants/Antiking2.js b/client/src/variants/Antiking2.js index 2dad5e49..fa0bbcc4 100644 --- a/client/src/variants/Antiking2.js +++ b/client/src/variants/Antiking2.js @@ -3,6 +3,7 @@ import { ArrayFun } from "@/utils/array"; import { randInt } from "@/utils/alea"; export class Antiking2Rules extends ChessRules { + static get ANTIKING() { return "a"; } @@ -43,7 +44,7 @@ export class Antiking2Rules extends ChessRules { 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; } } @@ -78,10 +79,7 @@ export class Antiking2Rules extends ChessRules { getPotentialAntikingMoves(sq) { // The antiking moves like a king (only captured colors differ) return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); + sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1); } isAttacked(sq, color) { @@ -101,12 +99,7 @@ export class Antiking2Rules extends ChessRules { // (Anti)King is not attacked by antiking if ([V.KING, V.ANTIKING].includes(this.getPiece(x, y))) return false; return this.isAttackedBySlideNJump( - [x, y], - color, - V.ANTIKING, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); + [x, y], color, V.ANTIKING, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1); } underCheck(color) { @@ -117,7 +110,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)) @@ -152,15 +146,15 @@ export class Antiking2Rules extends ChessRules { ); } - static GenRandInitFen(randomness) { - if (randomness == 0) + static GenRandInitFen(options) { + if (options.randomness == 0) return "rnbqkbnr/pppppppp/3A4/8/8/3a4/PPPPPPPP/RNBQKBNR w 0 ahah -"; let pieces = { w: new Array(8), b: new Array(8) }; let flags = ""; let antikingPos = { w: -1, b: -1 }; for (let c of ["w", "b"]) { - if (c == 'b' && randomness == 1) { + if (c == 'b' && options.randomness == 1) { pieces['b'] = pieces['w']; antikingPos['b'] = antikingPos['w']; flags += flags; @@ -231,4 +225,5 @@ export class Antiking2Rules extends ChessRules { static get SEARCH_DEPTH() { return 2; } + };