X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FAntiking.js;h=45daa62b0d29348f0246f7831a45084ac5d2cf75;hb=26b8e4f7c71030d49e44fe1d89632ef91b886d67;hp=0d342713e7c4889bbbe850c63bed7e25e3abe144;hpb=643479f8d7c3622b57fc49c4f10d9950793ebf4f;p=vchess.git diff --git a/public/javascripts/variants/Antiking.js b/public/javascripts/variants/Antiking.js index 0d342713..45daa62b 100644 --- a/public/javascripts/variants/Antiking.js +++ b/public/javascripts/variants/Antiking.js @@ -88,33 +88,27 @@ 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; } updateVariables(move) { super.updateVariables(move); - const piece = this.getPiece(move.start.x,move.start.y); - const c = this.getColor(move.start.x,move.start.y); + const piece = move.vanish[0].p; + const c = move.vanish[0].c; // Update antiking position if (piece == V.ANTIKING) { @@ -126,15 +120,15 @@ class AntikingRules extends ChessRules unupdateVariables(move) { super.unupdateVariables(move); - const c = this.getColor(move.start.x,move.start.y); - if (this.getPiece(move.start.x,move.start.y) == V.ANTIKING) + const c = move.vanish[0].c; + if (move.vanish[0].p == V.ANTIKING) this.antikingPos[c] = [move.start.x, move.start.y]; } 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])) { @@ -201,7 +195,7 @@ class AntikingRules extends ChessRules return pieces["b"].join("") + "/" + ranks23_black + "/8/8/" + ranks23_white + "/" + pieces["w"].join("").toUpperCase() + - " w 1111"; + " w 1111 -"; } }