Slight change in Ultima rules. TODO: merge with removed code 'isAttacked'
[vchess.git] / public / javascripts / variants / Magnetic.js
index 7d9d511..ec2c975 100644 (file)
@@ -137,10 +137,11 @@ class MagneticRules extends ChessRules
                return moves;
        }
 
-       // TODO: verify this assertion
        atLeastOneMove()
        {
-               return true; //always at least one possible move
+               if (this.kingPos[this.turn][0] < 0)
+                       return false;
+               return true; //TODO: is it right?
        }
 
        underCheck(move)
@@ -165,8 +166,8 @@ class MagneticRules extends ChessRules
        {
                super.updateVariables(move);
                const c = this.getColor(move.start.x,move.start.y);
-               if (c != this.getColor(move.end.x,move.end.y)
-                       && this.board[move.end.x][move.end.y] != VariantRules.EMPTY
+               if (this.board[move.end.x][move.end.y] != VariantRules.EMPTY
+                       && c != this.getColor(move.end.x,move.end.y)
                        && this.getPiece(move.end.x,move.end.y) == VariantRules.KING)
                {
                        // We took opponent king !
@@ -205,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