Commit | Line | Data |
---|---|---|
c3a86f01 BA |
1 | import { ChessRules, PiPo, Move } from "@/base_rules"; |
2 | import { ArrayFun } from "@/utils/array"; | |
3 | import { randInt } from "@/utils/alea"; | |
4 | ||
5 | // TODO: | |
e71161fb BA |
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) | |
c3a86f01 | 12 | |
c322a844 | 13 | export const VariantRules = class WormholeRules extends ChessRules { |
e71161fb BA |
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 | ||
c3a86f01 BA |
20 | static get HasFlags() { |
21 | return false; | |
22 | } | |
23 | ||
24 | static get HasEnpassant() { | |
25 | return false; | |
26 | } | |
27 | ||
e71161fb BA |
28 | getSquareAfter(sq, shift) { |
29 | // TODO | |
c3a86f01 BA |
30 | } |
31 | ||
e71161fb BA |
32 | getPpath(b) { |
33 | if (b.indexOf('x') >= 0) | |
34 | return "Wormhole/hole.svg"; | |
c3a86f01 BA |
35 | return b; |
36 | } | |
37 | ||
e71161fb | 38 | // TODO: postUpdateVars: board[start] = "xx"; --> V.HOLE |
c3a86f01 BA |
39 | |
40 | updateVariables(move) { | |
41 | super.updateVariables(move); | |
c3a86f01 BA |
42 | } |
43 | ||
44 | unupdateVariables(move) { | |
45 | super.unupdateVariables(move); | |
c3a86f01 BA |
46 | } |
47 | ||
48 | getNotation(move) { | |
c3a86f01 | 49 | const piece = this.getPiece(move.start.x, move.start.y); |
e71161fb BA |
50 | // Indicate start square + dest square, because holes distort the board |
51 | let notation = | |
c3a86f01 | 52 | piece.toUpperCase() + |
e71161fb | 53 | V.CoordsToSquare(move.start) + |
c3a86f01 | 54 | (move.vanish.length > move.appear.length ? "x" : "") + |
e71161fb BA |
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; | |
c3a86f01 BA |
60 | } |
61 | }; |