X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FArena.js;h=880f0082a97f4fa10f30b4c33c12561ef1f386c4;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=7cfda1d0dac3620cb99d6c5452bd3b83ce6ac8f2;hpb=57d9b2c4f08948bd5a5fc4a01a0b62d4c80523e2;p=vchess.git diff --git a/client/src/variants/Arena.js b/client/src/variants/Arena.js index 7cfda1d0..880f0082 100644 --- a/client/src/variants/Arena.js +++ b/client/src/variants/Arena.js @@ -1,6 +1,14 @@ import { ChessRules } from "@/base_rules"; export class ArenaRules extends ChessRules { + + static get Lines() { + return [ + [[2, 0], [2, 8]], + [[6, 0], [6, 8]] + ]; + } + static get HasFlags() { return false; } @@ -25,7 +33,7 @@ export class ArenaRules extends ChessRules { if (['K','k','Q','q'].includes(row[i])) royals[row[i]]++; if (V.PIECES.includes(row[i].toLowerCase())) sumElts++; else { - const num = parseInt(row[i]); + const num = parseInt(row[i], 10); if (isNaN(num)) return false; sumElts += num; } @@ -44,8 +52,8 @@ export class ArenaRules extends ChessRules { scanKings() {} - static GenRandInitFen(randomness) { - return ChessRules.GenRandInitFen(randomness).slice(0, -6) + "-"; + static GenRandInitFen(options) { + return ChessRules.GenRandInitFen(options).slice(0, -6) + "-"; } static InArena(x) { @@ -68,27 +76,13 @@ export class ArenaRules extends ChessRules { } getPotentialQueenMoves(sq) { - return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]) - ).filter(m => { - // Filter out moves longer than 3 squares - return Math.max( - Math.abs(m.end.x - m.start.x), - Math.abs(m.end.y - m.start.y)) <= 3; - }); + return super.getSlideNJumpMoves( + sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 3); } getPotentialKingMoves(sq) { - return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]) - ).filter(m => { - // Filter out moves longer than 3 squares - return Math.max( - Math.abs(m.end.x - m.start.x), - Math.abs(m.end.y - m.start.y)) <= 3; - }); + return super.getSlideNJumpMoves( + sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 3); } getCheckSquares() { @@ -143,4 +137,5 @@ export class ArenaRules extends ChessRules { static get SEARCH_DEPTH() { return 4; } + };