Attempt to fix Alice chess
authorBenjamin Auder <benjamin.auder@somewhere>
Sun, 25 Nov 2018 23:39:32 +0000 (00:39 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sun, 25 Nov 2018 23:39:32 +0000 (00:39 +0100)
public/javascripts/base_rules.js
public/javascripts/variants/Alice.js

index 0f637c5..8568936 100644 (file)
@@ -698,6 +698,10 @@ class ChessRules
 
        play(move, ingame)
        {
+               // DEBUG:
+//             if (!this.states) this.states = [];
+//             if (!ingame) this.states.push(JSON.stringify(this.board));
+
                if (!!ingame)
                        move.notation = this.getNotation(move);
 
@@ -715,6 +719,11 @@ class ChessRules
                this.moves.pop();
                this.unupdateVariables(move);
                this.parseFlags(JSON.parse(move.flags));
+
+               // DEBUG:
+//             let state = this.states.pop();
+//             if (JSON.stringify(this.board) != state)
+//                     debugger;
        }
 
        //////////////
index 7616827..9a7cefa 100644 (file)
@@ -132,7 +132,8 @@ class AliceRules extends ChessRules
                                });
                        }
                        // Fix en-passant captures
-                       if (m.vanish.length == 2 && this.board[m.end.x][m.end.y] == VariantRules.EMPTY)
+                       if (m.vanish[0].p == VariantRules.PAWN
+                               && m.vanish.length == 2 && this.board[m.end.x][m.end.y] == VariantRules.EMPTY)
                        {
                                m.vanish[1].c = this.getOppCol(this.getColor(x,y));
                                // In the special case of en-passant, if