X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FKnightmate2.js;h=bbdd12d95115a5743b7d27daeb22a89ecd8c930f;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=c90fb0ccecb932c10aa49dc1893fe867259a9353;hpb=3de62e0a608bd2be22c875930bb538b674968a6b;p=vchess.git diff --git a/client/src/variants/Knightmate2.js b/client/src/variants/Knightmate2.js index c90fb0cc..bbdd12d9 100644 --- a/client/src/variants/Knightmate2.js +++ b/client/src/variants/Knightmate2.js @@ -43,9 +43,9 @@ export class Knightmate2Rules extends ChessRules { scanKings() {} - static GenRandInitFen(randomness) { + static GenRandInitFen(options) { return ( - ChessRules.GenRandInitFen(randomness) + ChessRules.GenRandInitFen(options) .replace(/k/g, 'c').replace(/K/g, 'C') .replace(/n/g, 'k').replace(/N/g, 'K') ); @@ -62,10 +62,7 @@ export class Knightmate2Rules extends ChessRules { getPotentialCommonerMoves(sq) { return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); + sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1); } getPotentialKingMoves(sq) { @@ -85,22 +82,12 @@ export class Knightmate2Rules extends ChessRules { isAttackedByKing(sq, color) { return this.isAttackedBySlideNJump( - sq, - color, - V.KING, - V.steps[V.KNIGHT], - "oneStep" - ); + sq, color, V.KING, V.steps[V.KNIGHT], 1); } isAttackedByCommoner(sq, color) { return this.isAttackedBySlideNJump( - sq, - color, - V.COMMONER, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); + sq, color, V.COMMONER, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1); } postPlay() {} @@ -131,7 +118,7 @@ export class Knightmate2Rules extends ChessRules { for (let i of [0, 1]) { if ( kings.length >= i+1 && - super.isAttacked([kings[i].x, kings[i].y], oppCol) + this.isAttacked([kings[i].x, kings[i].y], oppCol) ) { res.push([kings[i].x, kings[i].y]); } @@ -154,7 +141,7 @@ export class Knightmate2Rules extends ChessRules { this.board[k.x][k.y] == V.EMPTY ? [m.appear[0].x, m.appear[0].y] //king moved : [k.x, k.y] - if (super.isAttacked(curKingPos, oppCol)) attacks++; + if (this.isAttacked(curKingPos, oppCol)) attacks++; else break; //no need to check further } this.undo(m); @@ -172,8 +159,8 @@ export class Knightmate2Rules extends ChessRules { const oppCol = V.GetOppCol(color); const kings = this.getKingsPos(color); if ( - super.isAttacked([kings[0].x, kings[0].y], oppCol) || - (kings.length == 2 && super.isAttacked([kings[1].x, kings[1].y], oppCol)) + this.isAttacked([kings[0].x, kings[0].y], oppCol) || + (kings.length == 2 && this.isAttacked([kings[1].x, kings[1].y], oppCol)) ) { return (color == 'w' ? "0-1" : "1-0"); }