rename getOppCol into static GetOppCol + start thinking about problems page
[vchess.git] / public / javascripts / variants / Baroque.js
index 0b00c26..38d4012 100644 (file)
@@ -1,4 +1,4 @@
-class UltimaRules extends ChessRules
+class BaroqueRules extends ChessRules
 {
        static get HasFlags() { return false; }
 
@@ -7,7 +7,7 @@ class UltimaRules extends ChessRules
        static getPpath(b)
        {
                if (b[1] == "m") //'m' for Immobilizer (I is too similar to 1)
-                       return "Ultima/" + b;
+                       return "Baroque/" + b;
                return b; //usual piece
        }
 
@@ -58,7 +58,7 @@ class UltimaRules extends ChessRules
        {
                const piece = this.getPiece(x,y);
                const color = this.getColor(x,y);
-               const oppCol = this.getOppCol(color);
+               const oppCol = V.GetOppCol(color);
                const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
                outerLoop:
                for (let step of adjacentSteps)
@@ -137,7 +137,7 @@ class UltimaRules extends ChessRules
        {
                const steps = V.steps[V.ROOK];
                const color = this.turn;
-               const oppCol = this.getOppCol(color);
+               const oppCol = V.GetOppCol(color);
                moves.forEach(m => {
                        if (!!byChameleon && m.start.x!=m.end.x && m.start.y!=m.end.y)
                                return; //chameleon not moving as pawn
@@ -169,7 +169,7 @@ class UltimaRules extends ChessRules
                });
        }
 
-       // "Pincher"
+       // "Pincer"
        getPotentialPawnMoves([x,y])
        {
                let moves = super.getPotentialRookMoves([x,y]);
@@ -180,7 +180,7 @@ class UltimaRules extends ChessRules
        addRookCaptures(moves, byChameleon)
        {
                const color = this.turn;
-               const oppCol = this.getOppCol(color);
+               const oppCol = V.GetOppCol(color);
                const kp = this.kingPos[color];
                moves.forEach(m => {
                        // Check piece-king rectangle (if any) corners for enemy pieces
@@ -221,7 +221,7 @@ class UltimaRules extends ChessRules
                // Look in every direction for captures
                const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
                const color = this.turn;
-               const oppCol = this.getOppCol(color);
+               const oppCol = V.GetOppCol(color);
                let moves = [];
                const [x,y] = [startSquare[0],startSquare[1]];
                const piece = this.getPiece(x,y); //might be a chameleon!
@@ -321,7 +321,7 @@ class UltimaRules extends ChessRules
                const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
                let capturingDirections = [];
                const color = this.turn;
-               const oppCol = this.getOppCol(color);
+               const oppCol = V.GetOppCol(color);
                adjacentSteps.forEach(step => {
                        const [i,j] = [x+step[0],y+step[1]];
                        if (V.OnBoard(i,j) && this.board[i][j] != V.EMPTY && this.getColor(i,j) == oppCol
@@ -526,18 +526,6 @@ class UltimaRules extends ChessRules
                return false;
        }
 
-       updateVariables(move)
-       {
-               // Just update king(s) position(s)
-               const piece = move.vanish[0].p;
-               const c = move.vanish[0].c;
-               if (piece == V.KING && move.appear.length > 0)
-               {
-                       this.kingPos[c][0] = move.appear[0].x;
-                       this.kingPos[c][1] = move.appear[0].y;
-               }
-       }
-
        static get VALUES()
        {
                // TODO: totally experimental!
@@ -627,4 +615,4 @@ class UltimaRules extends ChessRules
        }
 }
 
-const VariantRules = UltimaRules;
+const VariantRules = BaroqueRules;