X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FAntiking.js;h=71e01ff14ad39bd947cc3a08997b4f2d8a2f2b45;hb=a734a1a07f5309300a95ae2bd113c72be15bab22;hp=f8c7465aeeed1cfc683c00b11b8c4c315efc90fb;hpb=a37076f1ac8f4c19d9b34a60cbe89df86b88fa0b;p=vchess.git diff --git a/public/javascripts/variants/Antiking.js b/public/javascripts/variants/Antiking.js index f8c7465a..71e01ff1 100644 --- a/public/javascripts/variants/Antiking.js +++ b/public/javascripts/variants/Antiking.js @@ -42,7 +42,7 @@ class AntikingRules extends ChessRules const piece2 = this.getPiece(x2,y2); const color1 = this.getColor(x1,y1); const color2 = this.getColor(x2,y2); - return !["a","A"].includes(piece2) && + return piece2 != "a" && ((piece1 != "a" && color1 != color2) || (piece1 == "a" && color1 == color2)); } @@ -81,8 +81,8 @@ class AntikingRules extends ChessRules isAttackedByAntiking([x,y], colors) { const V = VariantRules; - if (this.getPiece(x,y) == V.KING) - return false; //king is not attacked by antiking + if ([V.KING,V.ANTIKING].includes(this.getPiece(x,y))) + return false; //(anti)king is not attacked by antiking return this.isAttackedBySlideNJump([x,y], colors, V.ANTIKING, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep"); } @@ -92,8 +92,8 @@ class AntikingRules extends ChessRules 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); + let res = this.isAttacked(this.kingPos[c], [oppCol]) + || !this.isAttacked(this.antikingPos[c], [oppCol]); this.undo(move); return res; } @@ -103,7 +103,7 @@ class AntikingRules extends ChessRules let res = super.getCheckSquares(move); this.play(move); const c = this.turn; - if (!this.isAttacked(this.antikingPos[c], this.getOppCol(c))) + if (!this.isAttacked(this.antikingPos[c], [this.getOppCol(c)])) res.push(JSON.parse(JSON.stringify(this.antikingPos[c]))); this.undo(move); return res; @@ -134,8 +134,8 @@ class AntikingRules extends ChessRules { const color = this.turn; const oppCol = this.getOppCol(color); - if (!this.isAttacked(this.kingPos[color], oppCol) - && this.isAttacked(this.antikingPos[color], oppCol)) + if (!this.isAttacked(this.kingPos[color], [oppCol]) + && this.isAttacked(this.antikingPos[color], [oppCol])) { return "1/2"; }