X-Git-Url: https://git.auder.net/rpsls.js?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FMagnetic.js;h=4549e846d9de4b78dbf772e4d2c9872778e25a34;hb=b83a675a3066c67cc7843ae27ad8aeffd15b0976;hp=0110c49ef88b14c830a99390ad3eebb91badae46;hpb=6808d7a16ec1e761c6a2dffec2281c96953e4d89;p=vchess.git diff --git a/client/src/variants/Magnetic.js b/client/src/variants/Magnetic.js index 0110c49e..4549e846 100644 --- a/client/src/variants/Magnetic.js +++ b/client/src/variants/Magnetic.js @@ -20,8 +20,10 @@ export const VariantRules = class MagneticRules extends ChessRules { // Complete a move with magnetic actions // TODO: job is done multiple times for (normal) promotions. applyMagneticLaws(move) { - 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 + // Exception: kings are not charged + if (move.appear[0].p == V.KING && move.appear.length == 1) return [move]; + // If castling, rook is charged: + const aIdx = move.appear[0].p != V.KING ? 0 : 1; const [x, y] = [move.appear[aIdx].x, move.appear[aIdx].y]; const color = this.turn; const lastRank = color == "w" ? 0 : 7; @@ -134,8 +136,9 @@ export const VariantRules = class MagneticRules extends ChessRules { return true; //TODO: is it right? } - underCheck() { - return false; //there is no check + filterValid(moves) { + // There are no checks + return moves; } getCheckSquares() { @@ -187,7 +190,7 @@ export const VariantRules = class MagneticRules extends ChessRules { const color = this.turn; const kp = this.kingPos[color]; if (kp[0] < 0) - //king disappeared + // King disappeared return color == "w" ? "0-1" : "1-0"; if (this.atLeastOneMove()) // game not over @@ -198,4 +201,8 @@ export const VariantRules = class MagneticRules extends ChessRules { static get THRESHOLD_MATE() { return 500; //checkmates evals may be slightly below 1000 } + + static get SEARCH_DEPTH() { + return 2; + } };