4ef66f2a817569021dd7abadd28be7290d4eb354
1 import ChessRules
from "/base_rules.js";
2 import AbstractAntikingRules
from "/variants/_Antiking/class.js";
4 export default class Antiking1Rules
extends AbstractAntikingRules
{
14 const pawnShift
= (color
== "w" ? -1 : 1);
15 let res
= super.pieces(color
, x
, y
);
18 steps: [[pawnShift
, 1], [pawnShift
, -1]],
24 steps: [[pawnShift
, 0]],
31 genRandInitBaseFen() {
32 // Always deterministic setup
34 fen: "2prbkqA/2p1nnbr/2pppppp/8/8/PPPPPP2/RBNN1P2/aQKBRP2",
39 // (Anti)King flags at 1 (true) if they can knight-jump
41 this.kingFlags
= { w: {}, b: {} };
42 for (let i
=0; i
<fenflags
.length
; i
++) {
43 const white
= fenflags
.charCodeAt(i
) <= 90;
44 const curChar
= fenflags
.charAt(i
).toLowerCase();
45 this.kingFlags
[white
? 'w' : 'b'][curChar
] = true;
51 Array
.prototype.concat
.apply([],
53 const res
= Object
.keys(this.kingFlags
[c
]).join("");
54 return (c
== 'w' ? res
.toUpperCase() : res
);
60 getPotentialMovesFrom([x
, y
]) {
61 const color
= this.turn
;
62 let moves
= super.getPotentialMovesFrom([x
, y
]);
63 if (this.kingFlags
[color
][this.getPiece(x
, y
)]) {
64 // Allow knight jump (king or antiking)
65 const knightMoves
= super.getPotentialMovesOf('n', [x
, y
]);
66 // Remove captures (TODO: could be done more efficiently...)
67 moves
= moves
.concat(knightMoves
.filter(m
=> m
.vanish
.length
== 1));
74 // Update king+antiking flags
75 const piece
= move.vanish
[0].p
;
76 if (this.isKing(0, 0, piece
))
77 delete this.kingFlags
[move.vanish
[0].c
][piece
];