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