projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Special SVG for berolina pawns
[vchess.git]
/
client
/
src
/
variants
/
Madhouse.js
diff --git
a/client/src/variants/Madhouse.js
b/client/src/variants/Madhouse.js
index
c157437
..
1ed248d
100644
(file)
--- 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 {
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.
// 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) {
}
setOtherVariables(fen) {
@@
-14,6
+18,12
@@
export class MadhouseRules extends ChessRules {
this.firstMove = [];
}
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
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);
}
move.appear[0].p != V.PAWN ? move.appear[0].p.toUpperCase() : "";
return piece + "@" + V.CoordsToSquare(move.end);
}
+
};
};