X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FMadhouse.js;h=1ed248d055afe3094cd1c144aa7627087c5f6bfc;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=c157437d43c6ff6c45b0b3fe7034c6a57a5bddf6;hpb=a9e1202b681d9d2f814767180183a0b04c58f8ab;p=vchess.git diff --git a/client/src/variants/Madhouse.js b/client/src/variants/Madhouse.js index c157437d..1ed248d0 100644 --- a/client/src/variants/Madhouse.js +++ b/client/src/variants/Madhouse.js @@ -2,10 +2,14 @@ import { ChessRules, Move, PiPo } from "@/base_rules"; 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) { @@ -14,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 @@ -254,4 +264,5 @@ export class MadhouseRules extends ChessRules { move.appear[0].p != V.PAWN ? move.appear[0].p.toUpperCase() : ""; return piece + "@" + V.CoordsToSquare(move.end); } + };