1 import { ChessRules
} from "@/base_rules";
3 // NOTE: a lot copy-pasted from Hoppelpoppel
4 export class NewzealandRules
extends ChessRules
{
6 // TODO: merge with base_rules.js
7 getSlideNJumpMoves_([x
, y
], steps
, oneStep
, options
) {
8 options
= options
|| {};
10 outerLoop: for (let step
of steps
) {
13 while (V
.OnBoard(i
, j
) && this.board
[i
][j
] == V
.EMPTY
) {
14 if (!options
.onlyTake
) moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
15 if (oneStep
) continue outerLoop
;
19 if (V
.OnBoard(i
, j
) && this.canTake([x
, y
], [i
, j
]) && !options
.onlyMove
)
20 moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
25 getPotentialKnightMoves(sq
) {
26 // The knight captures like a rook
28 this.getSlideNJumpMoves_(
29 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyMove: true })
31 this.getSlideNJumpMoves_(
32 sq
, ChessRules
.steps
[V
.ROOK
], null, { onlyTake: true }))
36 getPotentialRookMoves(sq
) {
37 // The rook captures like a knight
39 this.getSlideNJumpMoves_(
40 sq
, ChessRules
.steps
[V
.ROOK
], null, { onlyMove: true })
42 this.getSlideNJumpMoves_(
43 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyTake: true }))
47 isAttackedByKnight([x
, y
], color
) {
48 return super.isAttackedBySlideNJump(
49 [x
, y
], color
, V
.KNIGHT
, V
.steps
[V
.ROOK
]);
52 isAttackedByRook([x
, y
], color
) {
53 return super.isAttackedBySlideNJump(
54 [x
, y
], color
, V
.ROOK
, V
.steps
[V
.KNIGHT
], 1);