X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FMadhouse.js;h=1ed248d055afe3094cd1c144aa7627087c5f6bfc;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=5f90904e04d889e6302328f88ae52b2f6e71ddb4;hpb=7e8a7ea1cb66adb4a987badfb0a3c2f99a21bd0a;p=vchess.git diff --git a/client/src/variants/Madhouse.js b/client/src/variants/Madhouse.js index 5f90904e..1ed248d0 100644 --- a/client/src/variants/Madhouse.js +++ b/client/src/variants/Madhouse.js @@ -3,10 +3,13 @@ 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) { @@ -15,6 +18,12 @@ export class MadhouseRules extends ChessRules { 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