X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FCwda.js;h=2865d1fd3ea72e6f6e3bcf5329d0fb1805b3a80b;hp=c0d36edde1c5285785122379d9479afba3ac37b2;hb=10cceb25109739fa39b9b968be2707dee1d25a07;hpb=4313762da3237b04f204e121a20cab3ba7bb5dd2 diff --git a/client/src/variants/Cwda.js b/client/src/variants/Cwda.js index c0d36edd..2865d1fd 100644 --- a/client/src/variants/Cwda.js +++ b/client/src/variants/Cwda.js @@ -112,8 +112,7 @@ export class CwdaRules extends ChessRules { static IsGoodFen(fen) { if (!ChessRules.IsGoodFen(fen)) return false; const armies = V.ParseFen(fen).armies; - if (!armies || !armies.match(/^[CNRF]{2,2}$/)) return false; - return true; + return (!!armies && armies.match(/^[CNRF]{2,2}$/)); } getFen() { @@ -304,13 +303,9 @@ export class CwdaRules extends ChessRules { } getPotentialN_knightMoves(sq) { - const backward = (this.turn == 'w' ? 1 : -1); - const kingSteps = [ - [0, -1], [0, 1], [backward, -1], [backward, 0], [backward, 1] - ]; return ( this.getSlideNJumpMoves(sq, V.steps.$n, 1).concat( - this.getSlideNJumpMoves(sq, kingSteps, 1)) + this.getSlideNJumpMoves(sq, V.steps.f, 1)) ); } @@ -445,13 +440,9 @@ export class CwdaRules extends ChessRules { } isAttackedByN_knight(sq, color) { - const backward = (color == 'w' ? -1 : 1); - const kingSteps = [ - [0, -1], [0, 1], [backward, -1], [backward, 0], [backward, 1] - ]; return ( - this.isAttackedBySlideNJump(sq, color, V.N_KNIGHT, V.steps.$n) || - this.isAttackedBySlideNJump(sq, color, V.N_KNIGHT, kingSteps, 1) + this.isAttackedBySlideNJump(sq, color, V.N_KNIGHT, V.steps.$n, 1) || + this.isAttackedBySlideNJump(sq, color, V.N_KNIGHT, V.steps.f, 1) ); } @@ -514,6 +505,20 @@ export class CwdaRules extends ChessRules { ); } + // [HACK] So that the function above works also on Fide army: + isAttackedByF_rook(sq, color) { + return super.isAttackedByRook(sq, color); + } + isAttackedByF_knight(sq, color) { + return super.isAttackedByKnight(sq, color); + } + isAttackedByF_bishop(sq, color) { + return super.isAttackedByBishop(sq, color); + } + isAttackedByF_queen(sq, color) { + return super.isAttackedByQueen(sq, color); + } + static get VALUES() { return Object.assign( {