- const finalPieces = x + shiftX == lastRank
- ? [V.ROOK,V.KNIGHT,V.BISHOP,V.QUEEN]
- : [V.PAWN]
- // One square diagonally
- for (let shiftY of [-1,1])
- {
- if (this.board[x+shiftX][y+shiftY] == V.EMPTY)
- {
- for (let piece of finalPieces)
- {
- moves.push(this.getBasicMove([x,y], [x+shiftX,y+shiftY],
- {c:pawnColor,p:piece}));
- }
- if (x == startRank && this.board[x+2*shiftX][y] == V.EMPTY)
- {
- // Two squares jump
- moves.push(this.getBasicMove([x,y], [x+2*shiftX,y+2*shiftY]);
- }
- }
- }
- // Capture
- if (this.board[x+shiftX][y] != V.EMPTY
- && this.canTake([x,y], [x+shiftX,y]))