X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FMagnetic.js;h=ec2c975207d176d2edbff4e98ac8442f136b778c;hp=e126f1cee175f9aafe0691cb70a34802a8a175d6;hb=9d218497ab97bc0e94ec4c1f0a40cf02df3ea0d4;hpb=9e42b4dd8a70b9593cc44ab181b4df32032ca250 diff --git a/public/javascripts/variants/Magnetic.js b/public/javascripts/variants/Magnetic.js index e126f1ce..ec2c9752 100644 --- a/public/javascripts/variants/Magnetic.js +++ b/public/javascripts/variants/Magnetic.js @@ -112,7 +112,8 @@ class MagneticRules extends ChessRules // Scan move for pawn (max 1) on 8th rank for (let i=1; i { + if (psq.x == firstRank && this.INIT_COL_ROOK[c].includes(psq.y)) + this.castleFlags[c][psq.y==this.INIT_COL_ROOK[c][0] ? 0 : 1] = false; + else if (psq.x == oppFirstRank && this.INIT_COL_ROOK[oppCol].includes(psq.y)) + this.castleFlags[oppCol][psq.y==this.INIT_COL_ROOK[oppCol][0] ? 0 : 1] = false; + }); } unupdateVariables(move) @@ -194,19 +206,6 @@ class MagneticRules extends ChessRules } } - checkGameOver() - { - if (this.checkRepetition()) - return "1/2"; - - const color = this.turn; - // TODO: do we need "atLeastOneMove()"? - if (this.atLeastOneMove() && this.kingPos[color][0] >= 0) - return "*"; - - return this.checkGameEnd(); - } - checkGameEnd() { // No valid move: our king disappeared @@ -216,19 +215,4 @@ class MagneticRules extends ChessRules static get THRESHOLD_MATE() { return 500; //checkmates evals may be slightly below 1000 } - - getComputerMove() - { - let moves1 = this.getAllValidMoves(); - // Can I mate in 1 ? - for (let i of _.shuffle(_.range(moves1.length))) - { - this.play(moves1[i]); - const finish = (Math.abs(this.evalPosition()) >= VariantRules.THRESHOLD_MATE); - this.undo(moves1[i]); - if (finish) - return moves1[i]; - } - return super.getComputerMove(moves1); - } }