Implemented multi-move possibility in a moves list => better support for multi-moves...
[vchess.git] / client / src / variants / Wormhole.js
1 import { ChessRules, PiPo, Move } from "@/base_rules";
2 import { ArrayFun } from "@/utils/array";
3 import { randInt } from "@/utils/alea";
4
5 // TODO:
6 // Short-range pieces:
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)
12
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'
19
20 static get HasFlags() {
21 return false;
22 }
23
24 static get HasEnpassant() {
25 return false;
26 }
27
28 getSquareAfter(sq, shift) {
29 // TODO
30 }
31
32 getPpath(b) {
33 if (b.indexOf('x') >= 0)
34 return "Wormhole/hole.svg";
35 return b;
36 }
37
38 // TODO: postUpdateVars: board[start] = "xx"; --> V.HOLE
39
40 updateVariables(move) {
41 super.updateVariables(move);
42 }
43
44 unupdateVariables(move) {
45 super.unupdateVariables(move);
46 }
47
48 getNotation(move) {
49 const piece = this.getPiece(move.start.x, move.start.y);
50 // Indicate start square + dest square, because holes distort the board
51 let notation =
52 piece.toUpperCase() +
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)
57 // Promotion
58 notation += "=" + move.appear[0].p.toUpperCase();
59 return notation;
60 }
61 };