X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FMagnetic.js;h=ea745dd6b95f360a6599c5c20dbbb222cd44670d;hb=0c3fe8a6c3e02af46e0bc646b40c1a0c420f9dcd;hp=32279905ad00d01159eead1f1d52d7a251d89357;hpb=8d61fc4ab7373b4a576f3f9108cdf7768ae27096;p=vchess.git diff --git a/client/src/variants/Magnetic.js b/client/src/variants/Magnetic.js index 32279905..ea745dd6 100644 --- a/client/src/variants/Magnetic.js +++ b/client/src/variants/Magnetic.js @@ -1,4 +1,6 @@ -class MagneticRules extends ChessRules +import { ChessRules, PiPo } from "@/base_rules"; + +export const VariantRules = class MagneticRules extends ChessRules { static get HasEnpassant() { return false; } @@ -191,10 +193,15 @@ class MagneticRules extends ChessRules } } - checkGameEnd() + getCurrentScore() { - // No valid move: our king disappeared - return this.turn == "w" ? "0-1" : "1-0"; + const color = this.turn; + const kp = this.kingPos[color]; + if (kp[0] < 0) //king disappeared + return (color == "w" ? "0-1" : "1-0"); + if (this.atLeastOneMove()) // game not over + return "*"; + return "1/2"; //no moves but kings still there } static get THRESHOLD_MATE()