dfabddb72cc9a41efa3ef78026d78f43e8340a35
1 import ChessRules
from "/base_rules.js";
2 import PiPo
from "/utils/PiPo.js";
4 export default class BenedictRules
extends ChessRules
{
8 select: C
.Options
.select
,
12 variable: "cleopatra",
37 if (!this.options
["cleopatra"])
38 return super.pieces(color
, x
, y
);
39 const allSpecs
= super.pieces(color
, x
, y
);
40 return Object
.assign({},
42 {'q': Object
.assign({}, allSpecs
['q'], {"class": "cleopatra"})}
46 postProcessPotentialMoves(moves
) {
47 const oppCol
= C
.GetOppCol(this.turn
);
48 let bMoves
= super.postProcessPotentialMoves(moves
);
51 if (!this.options
["cleopatra"] || m
.vanish
[0].p
== 'q') {
53 let attacks
= super.findDestSquares(
57 segments: this.options
["cylinder"]
59 ([i1
, j1
], [i2
, j2
]) => {
61 super.canTake([i1
, j1
], [i2
, j2
]) &&
62 (!this.options
["zen"] || this.getPiece(i2
, j2
) == 'k')
66 if (this.options
["zen"]) {
67 const zenAttacks
= super.findCapturesOn(
71 segments: this.options
["cylinder"]
73 ([i1
, j1
], [i2
, j2
]) =>
74 this.getPiece(i1
, j1
) != 'k' && super.canTake([i2
, j2
], [i1
, j1
])
76 Array
.prototype.push
.apply(attacks
, zenAttacks
);
79 attacks
.forEach(a
=> m
.flips
.push({x: a
.sq
[0], y: a
.sq
[1]}));
86 super.playOnBoard(move);
87 this.flipColorOf(move.flips
);
90 super.undoOnBoard(move);
91 this.flipColorOf(move.flips
);
95 for (let xy
of flips
) {
96 const newColor
= C
.GetOppCol(this.getColor(xy
.x
, xy
.y
));
97 this.board
[xy
.x
][xy
.y
] = newColor
+ this.board
[xy
.x
][xy
.y
][1];
101 // Moves cannot flip our king's color, so all are valid
106 // A king under (regular) check flips color, and the game is over.
111 playVisual(move, r
) {
112 super.playVisual(move, r
);
113 move.flips
.forEach(f
=> {
114 this.g_pieces
[f
.x
][f
.y
].classList
.toggle("white");
115 this.g_pieces
[f
.x
][f
.y
].classList
.toggle("black");