X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDark.js;h=bc14cfa32565bf42af67c707c46c3e3d73fe23c0;hp=777aacc87ae3b99ca72e4708742a75ba9de6a1e5;hb=4f51861013271a060b358884097a676e3d42d496;hpb=0e16cb26f6380f57f1079ece9bdb654243073bde diff --git a/client/src/variants/Dark.js b/client/src/variants/Dark.js index 777aacc8..bc14cfa3 100644 --- a/client/src/variants/Dark.js +++ b/client/src/variants/Dark.js @@ -104,11 +104,11 @@ export const VariantRules = class DarkRules extends ChessRules super.updateVariables(move); if (move.vanish.length >= 2 && move.vanish[1].p == V.KING) { - // We took opponent king ! + // We took opponent king ! (because if castle vanish[1] is a rook) this.kingPos[this.turn] = [-1,-1]; } - // Update moves for both colors: + // Update lights for both colors: this.updateEnlightened(); } @@ -130,7 +130,7 @@ export const VariantRules = class DarkRules extends ChessRules } } - // Update moves for both colors: + // Update lights for both colors: this.updateEnlightened(); } @@ -157,7 +157,6 @@ export const VariantRules = class DarkRules extends ChessRules const color = this.turn; const oppCol = V.GetOppCol(color); const pawnShift = (color == "w" ? -1 : 1); - const kp = this.kingPos[color]; // Do not cheat: the current enlightment is all we can see const myLight = JSON.parse(JSON.stringify(this.enlightened[color])); @@ -165,6 +164,7 @@ export const VariantRules = class DarkRules extends ChessRules // Can a slider on (i,j) apparently take my king? // NOTE: inaccurate because assume yes if some squares are shadowed const sliderTake = ([i,j], piece) => { + const kp = this.kingPos[color]; let step = undefined; if (piece == V.BISHOP) { @@ -189,10 +189,10 @@ export const VariantRules = class DarkRules extends ChessRules // Check for obstacles let obstacle = false; for ( - let x=kp[0]+step[0], y=kp[1]+step[1]; - x != i && y != j; - x += step[0], y+= step[1]) - { + let x=kp[0]+step[0], y=kp[1]+step[1]; + x != i && y != j; + x += step[0], y += step[1]) + { if (myLight[x][y] && this.board[x][y] != V.EMPTY) { obstacle = true; @@ -206,6 +206,7 @@ export const VariantRules = class DarkRules extends ChessRules // Do I see something which can take my king ? const kingThreats = () => { + const kp = this.kingPos[color]; for (let i=0; i