Some fixes, draw lines on board, add 7 variants
[vchess.git] / client / src / variants / Gridolina.js
1 import { ChessRules } from "@/base_rules";
2 import { BerolinaRules } from "@/variants/Berolina";
3
4 export class GridolinaRules extends BerolinaRules {
5 static get Lines() {
6 return [
7 [[2, 0], [2, 8]],
8 [[4, 0], [4, 8]],
9 [[6, 0], [6, 8]],
10 [[0, 2], [8, 2]],
11 [[0, 4], [8, 4]],
12 [[0, 6], [8, 6]]
13 ];
14 }
15
16 static OnDifferentGrids([x1, y1], [x2, y2]) {
17 return (
18 Math.abs(Math.floor(x1 / 2) - Math.floor(x2 / 2)) >= 1 ||
19 Math.abs(Math.floor(y1 / 2) - Math.floor(y2 / 2)) >= 1
20 );
21 }
22
23 canTake([x1, y1], [x2, y2]) {
24 return (
25 V.OnDifferentGrids([x1, y1], [x2, y2]) &&
26 super.canTake([x1, y1], [x2, y2])
27 );
28 }
29
30 getPotentialMovesFrom([x, y]) {
31 return (
32 super.getPotentialMovesFrom([x, y]).filter(m => {
33 return V.OnDifferentGrids([x, y], [m.end.x, m.end.y]);
34 })
35 );
36 }
37 };