- addPawnMoves([x1, y1], [x2, y2], moves) {
- let finalPieces = [V.PAWN];
- const color = this.turn;
- const lastRank = (color == "w" ? 0 : V.size.x - 1);
- if (x2 == lastRank) {
- if (this.board[x2][y2] != V.EMPTY)
- // Cannibal rules: no choice if capture
- finalPieces = [this.getPiece(x2, y2)];
- else finalPieces = V.PawnSpecs.promotions;
- }
- let tr = null;
- for (let piece of finalPieces) {
- tr = (piece != V.PAWN ? { c: color, p: piece } : null);
- moves.push(this.getBasicMove([x1, y1], [x2, y2], tr));
- }
- }
-
- getPossibleMovesFrom(sq) {
- let moves = this.filterValid(this.getPotentialMovesFrom(sq));
- const captureMoves = V.KeepCaptures(moves);
- if (captureMoves.length > 0) return captureMoves;
- if (this.atLeastOneCapture()) return [];
- return moves;
- }
-
- getAllValidMoves() {
- const moves = super.getAllValidMoves();
- if (moves.some(m => m.vanish.length == 2 && m.appear.length == 1))
- return V.KeepCaptures(moves);
- return moves;
- }
-