1 import { ChessRules
} from "@/base_rules";
3 export class Knightmate1Rules
extends ChessRules
{
5 static get COMMONER() {
10 return ChessRules
.PIECES
.concat([V
.COMMONER
]);
14 return ([V
.KING
, V
.COMMONER
].includes(b
[1]) ? "Knightmate/" : "") + b
;
17 static GenRandInitFen(options
) {
18 return ChessRules
.GenRandInitFen(options
)
19 .replace(/n
/g
, 'c').replace(/N
/g
, 'C');
22 getPotentialMovesFrom([x
, y
]) {
23 switch (this.getPiece(x
, y
)) {
25 return this.getPotentialCommonerMoves([x
, y
]);
27 return super.getPotentialMovesFrom([x
, y
]);
31 getPotentialCommonerMoves(sq
) {
32 return this.getSlideNJumpMoves(
33 sq
, V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]), 1);
36 getPotentialKingMoves(sq
) {
37 return super.getPotentialKnightMoves(sq
).concat(super.getCastleMoves(sq
));
40 isAttacked(sq
, color
) {
42 this.isAttackedByCommoner(sq
, color
) ||
43 this.isAttackedByPawn(sq
, color
) ||
44 this.isAttackedByRook(sq
, color
) ||
45 this.isAttackedByBishop(sq
, color
) ||
46 this.isAttackedByQueen(sq
, color
) ||
47 this.isAttackedByKing(sq
, color
)
51 isAttackedByKing(sq
, color
) {
52 return this.isAttackedBySlideNJump(
53 sq
, color
, V
.KING
, V
.steps
[V
.KNIGHT
], 1);
56 isAttackedByCommoner(sq
, color
) {
57 return this.isAttackedBySlideNJump(
58 sq
, color
, V
.COMMONER
, V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]), 1);
65 c: 5, //the commoner is valuable