return this.getColor(x1, y1) !== this.getColor(x2, y2);
}
+ // TODO: currently unused, but makes sense?
+ canSelfTake([x1, y1], [x2, y2]) {
+ return true;
+ }
+
canStepOver(i, j, p) {
// In some variants, objects on boards don't stop movement (Chakart)
return this.board[i][j] == "";
}
return squares.map(s => {
let mv = this.getBasicMove([x, y], s.sq);
- if (this.options["cylinder"] && s.segments.length >= 2)
+ if (this.options["cylinder"] && !!s.segments && s.segments.length >= 2)
mv.segments = s.segments;
return mv;
});
const addSquare = ([i, j]) => {
let elt = {sq: [i, j]};
if (o.segments)
- elt.segments = this.getSegments(segments, segStart, end);
+ elt.segments = this.getSegments(segments, segStart, [i, j]);
res.push(elt);
};
const exploreSteps = (stepArray, mode) => {
tryChangeTurn(move) {
if (this.isLastMove(move)) {
- this.turn = (this.turn == 'w' ? 'b' : 'w');
+ this.turn = C.GetOppTurn(this.turn);
this.movesCount++;
this.subTurn = 1;
}
playVisual(move, r) {
move.vanish.forEach(v => {
- this.g_pieces[v.x][v.y].remove();
+ if (this.g_pieces[v.x][v.y]) //can be null (e.g. Apocalypse)
+ this.g_pieces[v.x][v.y].remove();
this.g_pieces[v.x][v.y] = null;
});
let chessboard =
animateMoving(start, end, drag, segments, cb) {
let initPiece = this.getDomPiece(start.x, start.y);
+ if (!initPiece) { //TODO: shouldn't occur!
+ cb();
+ return;
+ }
// NOTE: cloning often not required, but light enough, and simpler
let movingPiece = initPiece.cloneNode();
initPiece.style.opacity = "0";