d5366803116c74dcb2c5efc5012d5f54e658770f
1 import ChessRules
from "/base_rules.js";
2 import AbstractAntikingRules
from "/variants/_Antiking/class.js";
3 import BerolinaPawnSpec
from "/variants/_Berolina/pawnSpec.js";
5 export default class Antiking1Rules
extends AbstractAntikingRules
{
15 let res
= super.pieces(color
, x
, y
);
16 res
['p'] = BerolinaPawnSpec(color
);
20 genRandInitBaseFen() {
21 // Always deterministic setup
23 fen: "2prbkqA/2p1nnbr/2pppppp/8/8/PPPPPP2/RBNN1P2/aQKBRP2",
28 // (Anti)King flags at 1 (true) if they can knight-jump
30 this.kingFlags
= { w: {}, b: {} };
31 for (let i
=0; i
<fenflags
.length
; i
++) {
32 const white
= fenflags
.charCodeAt(i
) <= 90;
33 const curChar
= fenflags
.charAt(i
).toLowerCase();
34 this.kingFlags
[white
? 'w' : 'b'][curChar
] = true;
40 Array
.prototype.concat
.apply([],
42 const res
= Object
.keys(this.kingFlags
[c
]).join("");
43 return (c
== 'w' ? res
.toUpperCase() : res
);
49 getPotentialMovesFrom([x
, y
]) {
50 const color
= this.turn
;
51 let moves
= super.getPotentialMovesFrom([x
, y
]);
52 if (this.kingFlags
[color
][this.getPiece(x
, y
)]) {
53 // Allow knight jump (king or antiking)
54 const knightMoves
= super.getPotentialMovesOf('n', [x
, y
]);
55 // Remove captures (TODO: could be done more efficiently...)
56 moves
= moves
.concat(knightMoves
.filter(m
=> m
.vanish
.length
== 1));
63 // Update king+antiking flags
64 const piece
= move.vanish
[0].p
;
65 if (this.isKing(0, 0, piece
))
66 delete this.kingFlags
[move.vanish
[0].c
][piece
];