import { randInt } from "@/utils/alea";
export class MadhouseRules extends ChessRules {
- hoverHighlight(x, y) {
+
+ hoverHighlight([x, y], side) {
// Testing move validity results in an infinite update loop.
// TODO: find a way to test validity anyway.
- return (this.subTurn == 2 && this.board[x][y] == V.EMPTY);
+ return (
+ (this.subTurn == 2 && this.board[x][y] == V.EMPTY) &&
+ (!side || side == this.turn)
+ );
}
setOtherVariables(fen) {
this.firstMove = [];
}
+ canIplay(side, [x, y]) {
+ if (this.subTurn == 1) return super.canIplay(side, [x, y]);
+ // subturn == 2, drop a piece:
+ return side == this.turn && this.board[x][y] == V.EMPTY;
+ }
+
getPotentialMovesFrom([x, y]) {
if (this.subTurn == 1) return super.getPotentialMovesFrom([x, y]);
// subTurn == 2: a move is a click, not handled here
move.appear[0].p != V.PAWN ? move.appear[0].p.toUpperCase() : "";
return piece + "@" + V.CoordsToSquare(move.end);
}
+
};