Draft Fullcavalry and Atomic2 (pawn removal). Fix Grand
[vchess.git] / client / src / variants / Atomic2.js
1 import { ChessRules, Move, PiPo } from "@/base_rules";
2 import { Atomic1Rules } from "@/variants/Atomic1";
3
4 export class Atomic2Rules extends Atomic1Rules {
5
6 getPotentialMovesFrom([x, y]) {
7 if (this.movesCount == 0) {
8 if ([1, 6].includes(x)) {
9 const c = this.getColor(x, y);
10 return [
11 new Move({
12 appear: [],
13 vanish: [
14 new PiPo({ x: x, y: y, p: V.PAWN, c: c })
15 ],
16 start: { x: x, y: y },
17 end: { x: x, y: y }
18 })
19 ];
20 }
21 return [];
22 }
23 return super.getPotentialMovesFrom([x, y]);
24 }
25
26 hoverHighlight(x, y) {
27 return this.movesCount == 0 && [1, 6].includes(x);
28 }
29
30 doClick(square) {
31 if (this.movesCount >= 1) return null;
32 const [x, y] = [square[0], square[1]];
33 if (![1, 6].includes(x)) return null;
34 return new Move({
35 appear: [],
36 vanish: [
37 new PiPo({
38 x: x,
39 y: y,
40 c: this.getColor(x, y),
41 p: V.PAWN
42 })
43 ],
44 start: { x: x, y: y },
45 end: { x: x, y: y }
46 });
47 }
48
49 getNotation(move) {
50 if (move.appear.length == 0 && move.vanish.length == 1)
51 // First move in game
52 return V.CoordsToSquare(move.start) + "X";
53 return super.getNotation(move);
54 }
55
56 };