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(randomness
) {
18 return ChessRules
.GenRandInitFen(randomness
)
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(
34 V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]),
39 getPotentialKingMoves(sq
) {
40 return super.getPotentialKnightMoves(sq
).concat(super.getCastleMoves(sq
));
43 isAttacked(sq
, color
) {
45 this.isAttackedByCommoner(sq
, color
) ||
46 this.isAttackedByPawn(sq
, color
) ||
47 this.isAttackedByRook(sq
, color
) ||
48 this.isAttackedByBishop(sq
, color
) ||
49 this.isAttackedByQueen(sq
, color
) ||
50 this.isAttackedByKing(sq
, color
)
54 isAttackedByKing(sq
, color
) {
55 return this.isAttackedBySlideNJump(
64 isAttackedByCommoner(sq
, color
) {
65 return this.isAttackedBySlideNJump(
69 V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]),
78 c: 5, //the commoner is valuable