Fix typo
[vchess.git] / client / src / variants / Relayup.js
... / ...
CommitLineData
1import { ChessRules } from "@/base_rules";
2
3// Pawns relayed by one square at a time (but with relaying pioece movements)
4// diff from https://www.chessvariants.com/rules/relay-chess ==> new name
5export class RelayupRules extends ChessRules {
6
7 static get PawnSpecs() {
8 return Object.assign(
9 {},
10 ChessRules.PawnSpecs,
11 { twoSquares: false }
12 );
13 }
14
15 static get HasFlags() {
16 return false;
17 }
18
19 static get HasEnpassant() {
20 return false;
21 }
22
23 getPotentialMovesFrom([x, y]) {
24 let moves = super.getPotentialMovesFrom([x, y]);
25
26 // Expand possible moves if guarded by friendly pieces:
27 // --> Pawns cannot be promoted through a relaying move (thus 8th rank forbidden)
28 // TODO
29
30 return moves;
31 }
32
33 getNotation(move) {
34 // Translate final and initial square
35 const initSquare = V.CoordsToSquare(move.start);
36 const finalSquare = V.CoordsToSquare(move.end);
37 const piece = this.getPiece(move.start.x, move.start.y);
38
39 // Since pieces and pawns could move like knight,
40 // indicate start and end squares
41 let notation =
42 piece.toUpperCase() +
43 initSquare +
44 (move.vanish.length > move.appear.length ? "x" : "") +
45 finalSquare
46
47 if (
48 piece == V.PAWN &&
49 move.appear.length > 0 &&
50 move.appear[0].p != V.PAWN
51 ) {
52 // Promotion
53 notation += "=" + move.appear[0].p.toUpperCase();
54 }
55
56 return notation;
57 }
58
59};