1 import { ChessRules
} from "@/base_rules";
2 import { BerolinaRules
} from "@/variants/Berolina";
4 export class GridolinaRules
extends BerolinaRules
{
16 static OnDifferentGrids([x1
, y1
], [x2
, y2
]) {
18 Math
.abs(Math
.floor(x1
/ 2) - Math
.floor(x2
/ 2)) >= 1 ||
19 Math
.abs(Math
.floor(y1
/ 2) - Math
.floor(y2
/ 2)) >= 1
23 canTake([x1
, y1
], [x2
, y2
]) {
25 V
.OnDifferentGrids([x1
, y1
], [x2
, y2
]) &&
26 super.canTake([x1
, y1
], [x2
, y2
])
30 getPotentialMovesFrom([x
, y
]) {
32 super.getPotentialMovesFrom([x
, y
]).filter(m
=> {
33 return V
.OnDifferentGrids([x
, y
], [m
.end
.x
, m
.end
.y
]);
38 isAttackedBySlideNJump([x
, y
], color
, piece
, steps
, oneStep
) {
39 for (let step
of steps
) {
42 while (V
.OnBoard(rx
, ry
) && this.board
[rx
][ry
] == V
.EMPTY
&& !oneStep
) {
48 this.getPiece(rx
, ry
) == piece
&&
49 this.getColor(rx
, ry
) == color
&&
50 V
.OnDifferentGrids([x
, y
], [rx
, ry
])