Commit | Line | Data |
---|---|---|
c322a844 BA |
1 | import { ChessRules, PiPo, Move } from "@/base_rules"; |
2 | ||
3 | export const VariantRules = class RifleRules extends ChessRules { | |
4 | static get HasEnpassant() { | |
5 | // Due to the capturing mode, en passant is disabled | |
6 | return false; | |
7 | } | |
8 | ||
9 | getBasicMove([sx, sy], [ex, ey], tr) { | |
10 | let mv = new Move({ | |
11 | appear: [], | |
12 | vanish: [], | |
13 | start: {x:sx, y:sy}, | |
14 | end: {x:ex, y:ey} | |
15 | }); | |
16 | if (this.board[ex][ey] != V.EMPTY) { | |
17 | // No movement: just vanishing enemy piece | |
18 | mv.vanish = [ | |
19 | new PiPo({ | |
20 | x: ex, | |
21 | y: ey, | |
22 | c: this.getColor(ex, ey), | |
23 | p: this.getPiece(ex, ey) | |
24 | }) | |
25 | ]; | |
26 | } | |
27 | else { | |
28 | // Normal move | |
29 | mv.appear = [ | |
30 | new PiPo({ | |
31 | x: ex, | |
32 | y: ey, | |
33 | c: tr ? tr.c : this.getColor(sx, sy), | |
34 | p: tr ? tr.p : this.getPiece(sx, sy) | |
35 | }) | |
36 | ]; | |
37 | mv.vanish = [ | |
38 | new PiPo({ | |
39 | x: sx, | |
40 | y: sy, | |
41 | c: this.getColor(sx, sy), | |
42 | p: this.getPiece(sx, sy) | |
43 | }) | |
44 | ]; | |
45 | } | |
46 | ||
47 | return mv; | |
48 | } | |
49 | }; |