import { ChessRules, PiPo, Move } from "@/base_rules";
export class Allmate2Rules extends ChessRules {
+
static get HasEnpassant() {
return false;
}
oppMoves = this.getPotentialQueenMoves([i, j]);
break;
case V.KING:
- oppMoves = this.getPotentialKingMoves([i, j]);
+ // Do not allow castling to escape from check
+ oppMoves = super.getSlideNJumpMoves(
+ [i, j],
+ V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
+ "oneStep"
+ );
break;
}
for (let om of oppMoves) {
- if (om.vanish.length == 2 && om.appear.length == 1)
+ if (om.vanish.length == 2)
// Skip captures: forbidden in this mode
continue;
V.PlayOnBoard(this.board, om);
}
}
}
+ this.undo(m);
// 3) Add mate-captures:
Object.values(attacked).forEach(sq => {
p: this.getPiece(sq[0], sq[1])
}));
});
-
- this.undo(m);
});
return moves;
// No "under check" conditions in castling
getCastleMoves(sq) {
- return super.getCastleMoves(sq, "castleInCheck");
+ return super.getCastleMoves(sq, null, "castleInCheck");
}
// TODO: allow pieces to "commit suicide"? (Currently yes except king)
this.kingPos[this.turn] = [-1, -1];
// Or maybe a rook?
else if (v.p == V.ROOK) {
- if (v.y < this.INIT_COL_KING[v.c])
+ if (v.y < this.kingPos[v.c][1])
this.castleFlags[v.c][0] = 8;
else
- // v.y > this.INIT_COL_KING[v.c]
+ // v.y > this.kingPos[v.c][1]
this.castleFlags[v.c][1] = 8;
}
}
}
return notation;
}
+
};