X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAtomic2.js;fp=client%2Fsrc%2Fvariants%2FAtomic2.js;h=9ea22961a7106863bafc20ee619aa618f527d6c1;hb=0fb43db7c2858201e8410670b90f95ad8b138964;hp=0000000000000000000000000000000000000000;hpb=1186fba725f3da468f8834a9b44d58993a7d86d4;p=vchess.git diff --git a/client/src/variants/Atomic2.js b/client/src/variants/Atomic2.js new file mode 100644 index 00000000..9ea22961 --- /dev/null +++ b/client/src/variants/Atomic2.js @@ -0,0 +1,56 @@ +import { ChessRules, Move, PiPo } from "@/base_rules"; +import { Atomic1Rules } from "@/variants/Atomic1"; + +export class Atomic2Rules extends Atomic1Rules { + + getPotentialMovesFrom([x, y]) { + if (this.movesCount == 0) { + if ([1, 6].includes(x)) { + const c = this.getColor(x, y); + return [ + new Move({ + appear: [], + vanish: [ + new PiPo({ x: x, y: y, p: V.PAWN, c: c }) + ], + start: { x: x, y: y }, + end: { x: x, y: y } + }) + ]; + } + return []; + } + return super.getPotentialMovesFrom([x, y]); + } + + hoverHighlight(x, y) { + return this.movesCount == 0 && [1, 6].includes(x); + } + + doClick(square) { + if (this.movesCount >= 1) return null; + const [x, y] = [square[0], square[1]]; + if (![1, 6].includes(x)) return null; + return new Move({ + appear: [], + vanish: [ + new PiPo({ + x: x, + y: y, + c: this.getColor(x, y), + p: V.PAWN + }) + ], + start: { x: x, y: y }, + end: { x: x, y: y } + }); + } + + getNotation(move) { + if (move.appear.length == 0 && move.vanish.length == 1) + // First move in game + return V.CoordsToSquare(move.start) + "X"; + return super.getNotation(move); + } + +};