Fix wrong knightrider french translation
[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 canIplay(side, [x, y]) {
31 if (this.movesCount == 0)
32 return (this.turn == side && this.getPiece(x, y) == V.PAWN);
33 return super.canIplay(side, [x, y]);
34 }
35
36 doClick(square) {
37 if (this.movesCount >= 1) return null;
38 const [x, y] = [square[0], square[1]];
39 if (![1, 6].includes(x)) return null;
40 return new Move({
41 appear: [],
42 vanish: [
43 new PiPo({
44 x: x,
45 y: y,
46 c: this.getColor(x, y),
47 p: V.PAWN
48 })
49 ],
50 start: { x: x, y: y },
51 end: { x: x, y: y }
52 });
53 }
54
55 getNotation(move) {
56 if (move.appear.length == 0 && move.vanish.length == 1)
57 // First move in game
58 return V.CoordsToSquare(move.start) + "X";
59 return super.getNotation(move);
60 }
61
62 };