eb7d6251c42ea17718c457c8320cce860ed958ea
1 import { ChessRules
} from "@/base_rules";
3 // NOTE: a lot copy-pasted from Hoppelpoppel
4 export class NewzealandRules
extends ChessRules
{
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 rook
27 this.getSlideNJumpMoves_(
28 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyMove: true })
30 this.getSlideNJumpMoves_(
31 sq
, ChessRules
.steps
[V
.ROOK
], null, { onlyTake: true }))
35 getPotentialRookMoves(sq
) {
36 // The rook captures like a knight
38 this.getSlideNJumpMoves_(
39 sq
, ChessRules
.steps
[V
.ROOK
], null, { onlyMove: true })
41 this.getSlideNJumpMoves_(
42 sq
, ChessRules
.steps
[V
.KNIGHT
], "oneStep", { onlyTake: true }))
46 isAttackedByKnight([x
, y
], color
) {
47 return super.isAttackedBySlideNJump(
55 isAttackedByRook([x
, y
], color
) {
56 return super.isAttackedBySlideNJump(