X-Git-Url: https://git.auder.net/variants/Baroque/current/gitweb.js?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FDark.js;h=3879d9dfa8cc18a22d957e16f28064c8af4f216f;hb=ab4f4bf258ed68d8292b64d81babde03cddbae3c;hp=96f50de794027e887aa552c5534a94735847f4e9;hpb=5915f72002ae63b04620cebe47adf778174b1bee;p=vchess.git diff --git a/public/javascripts/variants/Dark.js b/public/javascripts/variants/Dark.js index 96f50de7..3879d9df 100644 --- a/public/javascripts/variants/Dark.js +++ b/public/javascripts/variants/Dark.js @@ -16,15 +16,37 @@ class DarkRules extends ChessRules updateEnlightened() { - // Initialize with pieces positions (which are seen) for (let i=0; i 0) - { - this.kingPos[c][0] = move.appear[0].x; - this.kingPos[c][1] = move.appear[0].y; - } + super.updateVariables(move); if (move.vanish.length >= 2 && move.vanish[1].p == V.KING) { // We took opponent king ! - const oppCol = this.getOppCol(c); - this.kingPos[oppCol] = [-1,-1]; + this.kingPos[this.turn] = [-1,-1]; } // Update moves for both colors: @@ -98,7 +112,7 @@ class DarkRules extends ChessRules { super.unupdateVariables(move); const c = move.vanish[0].c; - const oppCol = this.getOppCol(c); + const oppCol = V.GetOppCol(c); if (this.kingPos[oppCol][0] < 0) { // Last move took opponent's king @@ -132,7 +146,7 @@ class DarkRules extends ChessRules { const maxeval = V.INFINITY; const color = this.turn; - const oppCol = this.getOppCol(color); + const oppCol = V.GetOppCol(color); const pawnShift = (color == "w" ? -1 : 1); const kp = this.kingPos[color]; @@ -271,5 +285,3 @@ class DarkRules extends ChessRules return moves[_.sample(candidates, 1)]; } } - -const VariantRules = DarkRules;