X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FTwokings.js;h=b5f2b05986f76c5beb90bfd56e5e4689165070e1;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=ce30d65378b3e6babbd4b0d546626958bc8f911a;hpb=305ede7ec3753fc669b7c86af5b5c5b2fc78a164;p=vchess.git diff --git a/client/src/variants/Twokings.js b/client/src/variants/Twokings.js index ce30d653..b5f2b059 100644 --- a/client/src/variants/Twokings.js +++ b/client/src/variants/Twokings.js @@ -2,6 +2,7 @@ import { ChessRules } from "@/base_rules"; import { CoregalRules } from "@/variants/Coregal"; export class TwokingsRules extends CoregalRules { + static get PawnSpecs() { return Object.assign( {}, @@ -14,14 +15,14 @@ export class TwokingsRules extends CoregalRules { if (position.length == 0) return false; const rows = position.split("/"); if (rows.length != V.size.x) return false; - let kings = { "w": 0, "b": 0 }; + let kings = { 'K': 0, 'k': 0 }; for (let row of rows) { let sumElts = 0; for (let i = 0; i < row.length; i++) { if (['K','k'].includes(row[i])) kings[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; } @@ -34,9 +35,10 @@ export class TwokingsRules extends CoregalRules { } // Not scanning king positions. In this variant, scan the board everytime. - scanKings(fen) {} + scanKings() {} - getCheckSquares(color) { + getCheckSquares() { + const color = this.turn; let squares = []; const oppCol = V.GetOppCol(color); for (let i=0; i { @@ -82,7 +84,7 @@ export class TwokingsRules extends CoregalRules { }; const fen = - CoregalRules.GenRandInitFen(randomness) + CoregalRules.GenRandInitFen(options) .replace("q", "k").replace("Q", "K"); // Now replace a bishop by the queen, // so that bishops are of different colors: @@ -100,6 +102,11 @@ export class TwokingsRules extends CoregalRules { ); } + getPotentialQueenMoves(sq) { + return this.getSlideNJumpMoves(sq, + V.steps[V.ROOK].concat(V.steps[V.BISHOP])); + } + underCheck(color) { const oppCol = V.GetOppCol(color); for (let i=0; i