X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDark.js;h=fd6d571943ed8d5110ac2a5522932c1e9c84f4ac;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=cb073cfd7c9b74f8ca742a2da218d6e509657d5b;hpb=00eef1ca12534a43cb8e2e12155a46c00353eac2;p=vchess.git diff --git a/client/src/variants/Dark.js b/client/src/variants/Dark.js index cb073cfd..fd6d5719 100644 --- a/client/src/variants/Dark.js +++ b/client/src/variants/Dark.js @@ -3,6 +3,7 @@ import { ArrayFun } from "@/utils/array"; import { randInt } from "@/utils/alea"; export class DarkRules extends ChessRules { + // Analyse in Dark mode makes no sense static get CanAnalyze() { return false; @@ -109,7 +110,7 @@ export class DarkRules extends ChessRules { postPlay(move) { super.postPlay(move); - if (move.vanish.length >= 2 && move.vanish[1].p == V.KING) + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) // We took opponent king (because if castle vanish[1] is a rook) this.kingPos[this.turn] = [-1, -1]; @@ -119,11 +120,9 @@ export class DarkRules extends ChessRules { postUndo(move) { super.postUndo(move); - const c = move.vanish[0].c; - const oppCol = V.GetOppCol(c); - if (this.kingPos[oppCol][0] < 0) + if (move.vanish.length == 2 && move.vanish[1].p == V.KING) // Last move took opponent's king: - this.kingPos[oppCol] = [move.vanish[1].x, move.vanish[1].y]; + this.kingPos[move.vanish[1].c] = [move.vanish[1].x, move.vanish[1].y]; // Update lights for both colors: this.updateEnlightened(); @@ -271,4 +270,5 @@ export class DarkRules extends ChessRules { candidates.push(j); return moves[candidates[randInt(candidates.length)]]; } + };