X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FPacifist1.js;h=e595b0da898515a95b2284ea1b049dc1eac5ead6;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=234b02a851ae08d7ad5326638e86b2edaf437d68;hpb=a930dd712643df1d673bdc2b777b5912b9a41584;p=vchess.git diff --git a/client/src/variants/Pacifist1.js b/client/src/variants/Pacifist1.js index 234b02a8..e595b0da 100644 --- a/client/src/variants/Pacifist1.js +++ b/client/src/variants/Pacifist1.js @@ -1,6 +1,7 @@ import { ChessRules } from "@/base_rules"; export class Pacifist1Rules extends ChessRules { + static get PawnSpecs() { return Object.assign( {}, @@ -24,7 +25,7 @@ export class Pacifist1Rules extends ChessRules { if (['K','k'].includes(row[i])) kingsCount++; 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; } @@ -36,30 +37,8 @@ export class Pacifist1Rules extends ChessRules { return true; } - scanKings(fen) { - // Kings may be swapped, so they are not tracked (no kingPos) - this.INIT_COL_KING = { w: -1, b: -1 }; - const fenRows = V.ParseFen(fen).position.split("/"); - const startRow = { 'w': V.size.x - 1, 'b': 0 }; - for (let i = 0; i < fenRows.length; i++) { - let k = 0; //column index on board - for (let j = 0; j < fenRows[i].length; j++) { - switch (fenRows[i].charAt(j)) { - case "k": - this.INIT_COL_KING["b"] = k; - break; - case "K": - this.INIT_COL_KING["w"] = k; - break; - default: { - const num = parseInt(fenRows[i].charAt(j)); - if (!isNaN(num)) k += num - 1; - } - } - k++; - } - } - } + // Kings may be swapped, so they are not tracked (no kingPos) + scanKings(fen) { } // Sum white pieces attacking a square, and remove black pieces count. sumAttacks([x, y]) { @@ -175,21 +154,9 @@ export class Pacifist1Rules extends ChessRules { return moves; } - getSlideNJumpMoves([x, y], steps, oneStep) { - let moves = []; - outerLoop: for (let loop = 0; loop < steps.length; loop++) { - const step = steps[loop]; - let i = x + step[0]; - let j = y + step[1]; - while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) { - moves.push(this.getBasicMove([x, y], [i, j])); - if (oneStep) continue outerLoop; - i += step[0]; - j += step[1]; - } - // No captures - } - return moves; + canTake() { + // No captures + return false; } underCheck(color) { @@ -260,4 +227,5 @@ export class Pacifist1Rules extends ChessRules { static get SEARCH_DEPTH() { return 1; } + };