X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FAntiking.js;h=66eb9f0a890f699b91806e191a19832445d8e9d6;hb=b955c65b942d09d24b5c3bed0d755d4f2f8f71f1;hp=25a9dfcd0fc3da080512f3859f1086cf1136f53b;hpb=388e4c401f05b1f6a4c54e33c9da9114969a53c0;p=vchess.git diff --git a/public/javascripts/variants/Antiking.js b/public/javascripts/variants/Antiking.js index 25a9dfcd..66eb9f0a 100644 --- a/public/javascripts/variants/Antiking.js +++ b/public/javascripts/variants/Antiking.js @@ -88,25 +88,19 @@ class AntikingRules extends ChessRules V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep"); } - underCheck(move) + underCheck(color) { - const c = this.turn; - const oppCol = this.getOppCol(c); - this.play(move) - let res = this.isAttacked(this.kingPos[c], [oppCol]) - || !this.isAttacked(this.antikingPos[c], [oppCol]); - this.undo(move); + const oppCol = V.GetOppCol(color); + let res = this.isAttacked(this.kingPos[color], [oppCol]) + || !this.isAttacked(this.antikingPos[color], [oppCol]); return res; } - getCheckSquares(move) + getCheckSquares(color) { - let res = super.getCheckSquares(move); - this.play(move); - const c = this.turn; - if (!this.isAttacked(this.antikingPos[c], [this.getOppCol(c)])) - res.push(JSON.parse(JSON.stringify(this.antikingPos[c]))); - this.undo(move); + let res = super.getCheckSquares(color); + if (!this.isAttacked(this.antikingPos[color], [V.GetOppCol(color)])) + res.push(JSON.parse(JSON.stringify(this.antikingPos[color]))); return res; } @@ -134,7 +128,7 @@ class AntikingRules extends ChessRules checkGameEnd() { const color = this.turn; - const oppCol = this.getOppCol(color); + const oppCol = V.GetOppCol(color); if (!this.isAttacked(this.kingPos[color], [oppCol]) && this.isAttacked(this.antikingPos[color], [oppCol])) { @@ -204,5 +198,3 @@ class AntikingRules extends ChessRules " w 1111 -"; } } - -const VariantRules = AntikingRules;