X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FMagnetic.js;h=7b0d096ced0410205ee95c5949ecd70a0ac157f7;hb=b6487fb9c41705187cf97215fc9e8f86a59057c7;hp=ec2c975207d176d2edbff4e98ac8442f136b778c;hpb=9d218497ab97bc0e94ec4c1f0a40cf02df3ea0d4;p=vchess.git diff --git a/public/javascripts/variants/Magnetic.js b/public/javascripts/variants/Magnetic.js index ec2c9752..7b0d096c 100644 --- a/public/javascripts/variants/Magnetic.js +++ b/public/javascripts/variants/Magnetic.js @@ -1,9 +1,6 @@ class MagneticRules extends ChessRules { - getEpSquare(move) - { - return undefined; //no en-passant - } + static get HasEnpassant() { return false; } getPotentialMovesFrom([x,y]) { @@ -23,7 +20,6 @@ class MagneticRules extends ChessRules // TODO: job is done multiple times for (normal) promotions. applyMagneticLaws(move) { - const V = VariantRules; if (move.appear[0].p == V.KING && move.appear.length==1) return [move]; //kings are not charged const aIdx = (move.appear[0].p != V.KING ? 0 : 1); //if castling, rook is charged @@ -32,11 +28,10 @@ class MagneticRules extends ChessRules const lastRank = (color=="w" ? 0 : 7); const standardMove = JSON.parse(JSON.stringify(move)); this.play(standardMove); - const [sizeX,sizeY] = V.size; for (let step of [[-1,0],[1,0],[0,-1],[0,1]]) { let [i,j] = [x+step[0],y+step[1]]; - while (i>=0 && i=0 && j=0 && ii=0 && jj= 2 && move.vanish[1].p == V.KING) { // We took opponent king ! const oppCol = this.getOppCol(c); @@ -190,7 +175,7 @@ class MagneticRules extends ChessRules unupdateVariables(move) { super.unupdateVariables(move); - const c = this.getColor(move.start.x,move.start.y); + const c = move.vanish[0].c; const oppCol = this.getOppCol(c); if (this.kingPos[oppCol][0] < 0) { @@ -212,7 +197,10 @@ class MagneticRules extends ChessRules return this.turn == "w" ? "0-1" : "1-0"; } - static get THRESHOLD_MATE() { + static get THRESHOLD_MATE() + { return 500; //checkmates evals may be slightly below 1000 } } + +const VariantRules = MagneticRules;