Alice almost fixed
authorBenjamin Auder <benjamin.auder@somewhere>
Fri, 23 Nov 2018 13:20:31 +0000 (14:20 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Fri, 23 Nov 2018 13:20:31 +0000 (14:20 +0100)
public/javascripts/base_rules.js
public/javascripts/components/game.js
public/javascripts/variants/Alice.js

index cb426f3..346eff0 100644 (file)
@@ -699,8 +699,6 @@ class ChessRules
 
        play(move, ingame)
        {
-               console.log("play " + this.getNotation(move));
-               console.log(JSON.stringify(move));
                if (!!ingame)
                        move.notation = this.getNotation(move);
 
@@ -718,7 +716,6 @@ class ChessRules
                this.moves.pop();
                this.unupdateVariables(move);
                this.parseFlags(JSON.parse(move.flags));
-               console.log("undo " + this.getNotation(move));
        }
 
        //////////////
index ca8a6bf..397ba52 100644 (file)
@@ -574,7 +574,7 @@ Vue.component('my-game', {
                        this.newGame("computer");
                },
                newGame: function(mode, fenInit, color, oppId, moves, continuation) {
-                       const fen = "pppppppp/rnbqkbnr/8/8/8/8/PPPPPPPP/ROBQKBOR 1111"; //fenInit || VariantRules.GenRandInitFen();
+                       const fen = fenInit || VariantRules.GenRandInitFen();
                        console.log(fen); //DEBUG
                        this.score = "*";
                        if (mode=="human" && !oppId)
@@ -672,7 +672,7 @@ Vue.component('my-game', {
                                this.selectedPiece.style.display = "inline-block";
                                this.selectedPiece.style.zIndex = 3000;
                                let startSquare = this.getSquareFromId(e.target.parentNode.id);
-                               this.possibleMoves = true//this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
+                               this.possibleMoves = this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare)
                                        ? this.vr.getPossibleMovesFrom(startSquare)
                                        : [];
                                e.target.parentNode.appendChild(this.selectedPiece);
index 1e1ce46..4d10506 100644 (file)
@@ -50,10 +50,8 @@ class AliceRules extends ChessRules
                return sideBoard;
        }
 
-       // TODO: castle & enPassant https://www.chessvariants.com/other.dir/alice.html
-       // TODO: enPassant seulement si l'on est du même coté que le coté de départ du pion adverse
-       // (en passant en sortant du monde... : il faut donc ajouter des coups non trouvés)
-       // castle: check that all destination squares are not occupied
+       // NOTE: castle & enPassant https://www.chessvariants.com/other.dir/alice.html
+       // --> Should be OK as is.
        getPotentialMovesFrom([x,y])
        {
                let sideBoard = this.getBoardOfPiece([x,y]);
@@ -67,8 +65,20 @@ class AliceRules extends ChessRules
                // Finally filter impossible moves
                const mirrorSide = (Object.keys(VariantRules.ALICE_CODES).includes(this.getPiece(x,y)) ? 1 : 2);
                return moves.filter(m => {
-                       if (this.board[m.end.x][m.end.y] != VariantRules.EMPTY)
+                       if (m.appear.length == 2) //castle
                        {
+                               // If appear[i] not in vanish array, then must be empty square on other board
+                               m.appear.forEach(psq => {
+                                       if (this.board[psq.x][psq.y] != VariantRules.EMPTY &&
+                                               ![m.vanish[0].y,m.vanish[1].y].includes(psq.y))
+                                       {
+                                               return false;
+                                       }
+                               });
+                       }
+                       else if (this.board[m.end.x][m.end.y] != VariantRules.EMPTY)
+                       {
+                               // Attempt to capture
                                const piece = this.getPiece(m.end.x,m.end.y);
                                if ((mirrorSide==1 && Object.keys(VariantRules.ALICE_PIECES).includes(piece))
                                        || (mirrorSide==2 && Object.keys(VariantRules.ALICE_CODES).includes(piece)))