+ getPotentialPawnMoves([x,y])
+ {
+ let moves = super.getPotentialPawnMoves([x,y]);
+ // Add potential promotions into king
+ const color = this.turn;
+ const V = VariantRules;
+ const [sizeX,sizeY] = V.size;
+ const shift = (color == "w" ? -1 : 1);
+ const lastRank = (color == "w" ? 0 : sizeX-1);
+
+ if (x+shift == lastRank)
+ {
+ // Normal move
+ if (this.board[x+shift][y] == V.EMPTY)
+ moves.push(this.getBasicMove([x,y], [x+shift,y], {c:color,p:V.KING}));
+ // Captures
+ if (y>0 && this.canTake([x,y], [x+shift,y-1])
+ && this.board[x+shift][y-1] != V.EMPTY)
+ {
+ moves.push(this.getBasicMove([x,y], [x+shift,y-1], {c:color,p:V.KING}));
+ }
+ if (y<sizeY-1 && this.canTake([x,y], [x+shift,y+1])
+ && this.board[x+shift][y+1] != V.EMPTY)
+ {
+ moves.push(this.getBasicMove([x,y], [x+shift,y+1], {c:color,p:V.KING}));
+ }
+ }
+
+ return moves;
+ }
+