1 import { ChessRules
, PiPo
, Move
} from "@/base_rules";
2 import { ArrayFun
} from "@/utils/array";
3 import { randInt
} from "@/utils/alea";
7 // rook 1 or 2 squares orthogonal
8 // bishop 1 or 2 diagonal
9 // queen = bishop + rook
10 // knight: one square orthogonal + 1 diagonal (only acepted desc)
11 // no castle or en passant. Promotion possible only by capture (otherwise hole)
13 export const VariantRules
= class WormholeRules
extends ChessRules
{
14 // TODO: redefine pieces movements, taking care of holes (auxiliary func: getSquareAfter(shiftX,shiftY))
15 // this aux func could return null / undefined
16 // revoir getPotentialMoves et isAttacked : tout ce qui touche au board avec calcul,
17 // car les "board[x+..][y+..]" deviennent des board[getSquareAfter...]
18 // Special FEN sign for holes: 'x'
20 static get HasFlags() {
24 static get HasEnpassant() {
28 getSquareAfter(sq
, shift
) {
33 if (b
.indexOf('x') >= 0)
34 return "Wormhole/hole.svg";
38 // TODO: postUpdateVars: board[start] = "xx"; --> V.HOLE
40 updateVariables(move) {
41 super.updateVariables(move);
44 unupdateVariables(move) {
45 super.unupdateVariables(move);
49 const piece
= this.getPiece(move.start
.x
, move.start
.y
);
50 // Indicate start square + dest square, because holes distort the board
53 V
.CoordsToSquare(move.start
) +
54 (move.vanish
.length
> move.appear
.length
? "x" : "") +
55 V
.CoordsToSquare(move.end
);
56 if (piece
== V
.PAWN
&& move.appear
[0].p
!= V
.PAWN
)
58 notation
+= "=" + move.appear
[0].p
.toUpperCase();