// Is (x,y) on the chessboard?
onBoard(x, y) {
- return x >= 0 && x < this.size.x && y >= 0 && y < this.size.y;
+ return (x >= 0 && x < this.size.x &&
+ y >= 0 && y < this.size.y);
}
// Used in interface: 'side' arg == player color
return moves;
}
+ // NOTE: using special symbols to not interfere with variants' pieces codes
static get CannibalKings() {
return {
- "s": "p",
- "u": "r",
- "o": "n",
- "c": "b",
- "t": "q"
+ "!": "p",
+ "#": "r",
+ "$": "n",
+ "%": "b",
+ "*": "q"
};
}
static get CannibalKingCode() {
return {
- "p": "s",
- "r": "u",
- "n": "o",
- "b": "c",
- "q": "t",
+ "p": "!",
+ "r": "#",
+ "n": "$",
+ "b": "%",
+ "q": "*",
"k": "k"
};
}
(this.options["progressive"] && this.subTurn <= this.movesCount)
) {
const oppKingPos = this.searchKingPos(oppCol);
- if (oppKingPos[0] >= 0 && !this.underCheck(oppKingPos, color)) {
+ if (
+ oppKingPos[0] >= 0 &&
+ (
+ this.options["taking"] ||
+ !this.underCheck(oppKingPos, color)
+ )
+ ) {
this.subTurn++;
return;
}
playVisual(move, r) {
move.vanish.forEach(v => {
if (!this.enlightened || this.enlightened[v.x][v.y]) {
- this.g_pieces[v.x][v.y].remove();
+ // TODO: next "if" shouldn't be required
+ if (this.g_pieces[v.x][v.y])
+ this.g_pieces[v.x][v.y].remove();
this.g_pieces[v.x][v.y] = null;
}
});
const dropMove = (typeof i1 == "string");
const startArray = (dropMove ? this.r_pieces : this.g_pieces);
let startPiece = startArray[i1][j1];
+ // TODO: next "if" shouldn't be required
+ if (!startPiece) {
+ callback();
+ return;
+ }
let chessboard =
document.getElementById(this.containerId).querySelector(".chessboard");
const clonePiece = (