1 import { ChessRules
} from "@/base_rules";
3 export class HoppelpoppelRules
extends ChessRules
{
5 // TODO: merge with base_rules.js (see also Orda, Empire)
6 getSlideNJumpMoves_([x
, y
], steps
, oneStep
, options
) {
7 options
= options
|| {};
9 outerLoop: for (let step
of steps
) {
12 while (V
.OnBoard(i
, j
) && this.board
[i
][j
] == V
.EMPTY
) {
13 if (!options
.onlyTake
) moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
14 if (oneStep
) continue outerLoop
;
18 if (V
.OnBoard(i
, j
) && this.canTake([x
, y
], [i
, j
]) && !options
.onlyMove
)
19 moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
24 getPotentialKnightMoves(sq
) {
25 // The knight captures like a bishop
27 this.getSlideNJumpMoves_(
28 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyMove: true })
30 this.getSlideNJumpMoves_(
31 sq
, ChessRules
.steps
[V
.BISHOP
], null, { onlyTake: true }))
35 getPotentialBishopMoves(sq
) {
36 // The bishop captures like a knight
38 this.getSlideNJumpMoves_(
39 sq
, ChessRules
.steps
[V
.BISHOP
], null, { onlyMove: true })
41 this.getSlideNJumpMoves_(
42 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyTake: true }))
46 isAttackedByKnight([x
, y
], color
) {
47 return super.isAttackedBySlideNJump(
48 [x
, y
], color
, V
.KNIGHT
, V
.steps
[V
.BISHOP
]);
51 isAttackedByBishop([x
, y
], color
) {
52 return super.isAttackedBySlideNJump(
53 [x
, y
], color
, V
.BISHOP
, V
.steps
[V
.KNIGHT
], 1);