1 import { ChessRules
} from "@/base_rules";
3 export class HoppelpoppelRules
extends ChessRules
{
5 getSlideNJumpMoves_([x
, y
], steps
, oneStep
, options
) {
6 options
= options
|| {};
8 outerLoop: for (let step
of steps
) {
11 while (V
.OnBoard(i
, j
) && this.board
[i
][j
] == V
.EMPTY
) {
12 if (!options
.onlyTake
) moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
13 if (!!oneStep
) continue outerLoop
;
17 if (V
.OnBoard(i
, j
) && this.canTake([x
, y
], [i
, j
]) && !options
.onlyMove
)
18 moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
23 getPotentialKnightMoves(sq
) {
24 // The knight captures like a bishop
26 this.getSlideNJumpMoves_(
27 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyMove: true })
29 this.getSlideNJumpMoves_(
30 sq
, ChessRules
.steps
[V
.BISHOP
], null, { onlyTake: true }))
34 getPotentialBishopMoves(sq
) {
35 // The bishop captures like a knight
37 this.getSlideNJumpMoves_(
38 sq
, ChessRules
.steps
[V
.BISHOP
], null, { onlyMove: true })
40 this.getSlideNJumpMoves_(
41 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyTake: true }))
45 isAttackedByKnight([x
, y
], color
) {
46 return super.isAttackedBySlideNJump(
54 isAttackedByBishop([x
, y
], color
) {
55 return super.isAttackedBySlideNJump(