Attempt to clarify installation instructions a little
[vchess.git] / client / src / variants / Rifle.js
1 import { ChessRules, PiPo, Move } from "@/base_rules";
2
3 export class RifleRules extends ChessRules {
4
5 getBasicMove([sx, sy], [ex, ey], tr) {
6 let mv = new Move({
7 appear: [],
8 vanish: [],
9 start: {x:sx, y:sy},
10 end: {x:ex, y:ey}
11 });
12 if (this.board[ex][ey] != V.EMPTY) {
13 // No movement: just vanishing enemy piece
14 mv.vanish = [
15 new PiPo({
16 x: ex,
17 y: ey,
18 c: this.getColor(ex, ey),
19 p: this.getPiece(ex, ey)
20 })
21 ];
22 }
23 else {
24 // Normal move
25 mv.appear = [
26 new PiPo({
27 x: ex,
28 y: ey,
29 c: tr ? tr.c : this.getColor(sx, sy),
30 p: tr ? tr.p : this.getPiece(sx, sy)
31 })
32 ];
33 mv.vanish = [
34 new PiPo({
35 x: sx,
36 y: sy,
37 c: this.getColor(sx, sy),
38 p: this.getPiece(sx, sy)
39 })
40 ];
41 }
42
43 return mv;
44 }
45
46 getEnpassantCaptures([x, y], shiftX) {
47 let moves = [];
48 const Lep = this.epSquares.length;
49 const epSquare = this.epSquares[Lep - 1]; //always at least one element
50 if (
51 !!epSquare &&
52 epSquare.x == x + shiftX &&
53 Math.abs(epSquare.y - y) == 1
54 ) {
55 let enpassantMove = new Move({
56 appear: [],
57 vanish: [],
58 start: {x:x, y:y},
59 end: {x:x+shiftX, y:epSquare.y}
60 });
61 enpassantMove.vanish.push({
62 x: x,
63 y: epSquare.y,
64 p: "p",
65 c: this.getColor(x, epSquare.y)
66 });
67 moves.push(enpassantMove);
68 }
69 return moves;
70 }
71
72 static get SEARCH_DEPTH() {
73 return 2;
74 }
75
76 };