X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShatranj.js;h=568e2d963d6b1695d3963351b23a7dd69d7d8ad5;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=7d76b838c49a313a1c4a679043f09ad3be1658c0;hpb=b406466b0f0ce67451f1718053e5f5691d6507fb;p=vchess.git diff --git a/client/src/variants/Shatranj.js b/client/src/variants/Shatranj.js index 7d76b838..568e2d96 100644 --- a/client/src/variants/Shatranj.js +++ b/client/src/variants/Shatranj.js @@ -1,6 +1,7 @@ import { ChessRules } from "@/base_rules"; export class ShatranjRules extends ChessRules { + static get HasFlags() { return false; } @@ -9,6 +10,14 @@ export class ShatranjRules extends ChessRules { return false; } + static get Monochrome() { + return true; + } + + static get Notoodark() { + return true; + } + static get PawnSpecs() { return Object.assign( {}, @@ -34,57 +43,40 @@ export class ShatranjRules extends ChessRules { ]; } - static GenRandInitFen(randomness) { + static GenRandInitFen(options) { // Remove castle flags and en-passant indication - return ChessRules.GenRandInitFen(randomness).slice(0, -7); + return ChessRules.GenRandInitFen(options).slice(0, -7); } getPotentialBishopMoves(sq) { - let moves = this.getSlideNJumpMoves(sq, V.ElephantSteps, "oneStep"); + let moves = this.getSlideNJumpMoves(sq, V.ElephantSteps, 1); // Complete with "repositioning moves": like a queen, without capture - let repositioningMoves = this.getSlideNJumpMoves( - sq, - V.steps[V.BISHOP], - "oneStep" - ).filter(m => m.vanish.length == 1); + let repositioningMoves = + this.getSlideNJumpMoves(sq, V.steps[V.BISHOP], 1) + .filter(m => m.vanish.length == 1); return moves.concat(repositioningMoves); } getPotentialQueenMoves(sq) { // Diagonal capturing moves - let captures = this.getSlideNJumpMoves( - sq, - V.steps[V.BISHOP], - "oneStep" - ).filter(m => m.vanish.length == 2); + let captures = + this.getSlideNJumpMoves(sq, V.steps[V.BISHOP], 1) + .filter(m => m.vanish.length == 2); return captures.concat( // Orthogonal non-capturing moves - this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK], - "oneStep" - ).filter(m => m.vanish.length == 1) + this.getSlideNJumpMoves(sq, V.steps[V.ROOK], 1) + .filter(m => m.vanish.length == 1) ); } isAttackedByBishop(sq, color) { return this.isAttackedBySlideNJump( - sq, - color, - V.BISHOP, - V.ElephantSteps, - "oneStep" - ); + sq, color, V.BISHOP, V.ElephantSteps, 1); } isAttackedByQueen(sq, color) { return this.isAttackedBySlideNJump( - sq, - color, - V.QUEEN, - V.steps[V.BISHOP], - "oneStep" - ); + sq, color, V.QUEEN, V.steps[V.BISHOP], 1); } getCurrentScore() { @@ -143,4 +135,5 @@ export class ShatranjRules extends ChessRules { k: 1000 }; } + };