X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAntiking.js;h=94c8af6d021dc09ba401c8432bb6ad31f19dfeba;hp=c3fe0137da267b1b224e3acbd0aa315d88ee2680;hb=68e19a449db7a12e0a168e99cd750d985c983ba1;hpb=11589e7c4bb1b69473588d133db8b6d1d37b8fee diff --git a/client/src/variants/Antiking.js b/client/src/variants/Antiking.js index c3fe0137..94c8af6d 100644 --- a/client/src/variants/Antiking.js +++ b/client/src/variants/Antiking.js @@ -68,28 +68,31 @@ export const VariantRules = class AntikingRules extends ChessRules { ); } - isAttacked(sq, colors) { + isAttacked(sq, color) { return ( - super.isAttacked(sq, colors) || this.isAttackedByAntiking(sq, colors) + super.isAttacked(sq, color) || + this.isAttackedByAntiking(sq, color) ); } - isAttackedByKing([x, y], colors) { - if (this.getPiece(x, y) == V.ANTIKING) return false; //antiking is not attacked by king + isAttackedByKing([x, y], color) { + // Antiking is not attacked by king: + if (this.getPiece(x, y) == V.ANTIKING) return false; return this.isAttackedBySlideNJump( [x, y], - colors, + color, V.KING, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep" ); } - isAttackedByAntiking([x, y], colors) { - if ([V.KING, V.ANTIKING].includes(this.getPiece(x, y))) return false; //(anti)king is not attacked by antiking + isAttackedByAntiking([x, y], color) { + // (Anti)King is not attacked by antiking + if ([V.KING, V.ANTIKING].includes(this.getPiece(x, y))) return false; return this.isAttackedBySlideNJump( [x, y], - colors, + color, V.ANTIKING, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep" @@ -99,14 +102,14 @@ export const VariantRules = class AntikingRules extends ChessRules { underCheck(color) { const oppCol = V.GetOppCol(color); let res = - this.isAttacked(this.kingPos[color], [oppCol]) || - !this.isAttacked(this.antikingPos[color], [oppCol]); + this.isAttacked(this.kingPos[color], oppCol) || + !this.isAttacked(this.antikingPos[color], oppCol); return res; } getCheckSquares(color) { let res = super.getCheckSquares(color); - if (!this.isAttacked(this.antikingPos[color], [V.GetOppCol(color)])) + if (!this.isAttacked(this.antikingPos[color], V.GetOppCol(color))) res.push(JSON.parse(JSON.stringify(this.antikingPos[color]))); return res; } @@ -136,8 +139,8 @@ export const VariantRules = class AntikingRules extends ChessRules { const color = this.turn; const oppCol = V.GetOppCol(color); if ( - !this.isAttacked(this.kingPos[color], [oppCol]) && - this.isAttacked(this.antikingPos[color], [oppCol]) + !this.isAttacked(this.kingPos[color], oppCol) && + this.isAttacked(this.antikingPos[color], oppCol) ) { return "1/2"; }