import { randInt } from "@/utils/alea";
export class DarkRules extends ChessRules {
+
// Analyse in Dark mode makes no sense
static get CanAnalyze() {
return false;
return "none";
}
+ static get SomeHiddenMoves() {
+ return true;
+ }
+
setOtherVariables(fen) {
super.setOtherVariables(fen);
const [sizeX, sizeY] = [V.size.x, V.size.y];
postPlay(move) {
super.postPlay(move);
- if (move.vanish.length >= 2 && move.vanish[1].p == V.KING)
+ if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
// We took opponent king (because if castle vanish[1] is a rook)
this.kingPos[this.turn] = [-1, -1];
postUndo(move) {
super.postUndo(move);
- const c = move.vanish[0].c;
- const oppCol = V.GetOppCol(c);
- if (this.kingPos[oppCol][0] < 0)
+ if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
// Last move took opponent's king:
- this.kingPos[oppCol] = [move.vanish[1].x, move.vanish[1].y];
+ this.kingPos[move.vanish[1].c] = [move.vanish[1].x, move.vanish[1].y];
// Update lights for both colors:
this.updateEnlightened();
candidates.push(j);
return moves[candidates[randInt(candidates.length)]];
}
+
};