projects
/
xogo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Various bug fixes
[xogo.git]
/
base_rules.js
diff --git
a/base_rules.js
b/base_rules.js
index
a8dad15
..
e127b74
100644
(file)
--- a/
base_rules.js
+++ b/
base_rules.js
@@
-1321,6
+1321,11
@@
export default class ChessRules {
return this.getColor(x1, y1) !== this.getColor(x2, y2);
}
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] == "";
canStepOver(i, j, p) {
// In some variants, objects on boards don't stop movement (Chakart)
return this.board[i][j] == "";
@@
-1724,7
+1729,7
@@
export default class ChessRules {
}
return squares.map(s => {
let mv = this.getBasicMove([x, y], s.sq);
}
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;
});
mv.segments = s.segments;
return mv;
});
@@
-1742,7
+1747,7
@@
export default class ChessRules {
const addSquare = ([i, j]) => {
let elt = {sq: [i, j]};
if (o.segments)
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) => {
res.push(elt);
};
const exploreSteps = (stepArray, mode) => {
@@
-2320,7
+2325,7
@@
export default class ChessRules {
tryChangeTurn(move) {
if (this.isLastMove(move)) {
tryChangeTurn(move) {
if (this.isLastMove(move)) {
- this.turn =
(this.turn == 'w' ? 'b' : 'w'
);
+ this.turn =
C.GetOppTurn(this.turn
);
this.movesCount++;
this.subTurn = 1;
}
this.movesCount++;
this.subTurn = 1;
}
@@
-2406,7
+2411,8
@@
export default class ChessRules {
playVisual(move, r) {
move.vanish.forEach(v => {
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 =
this.g_pieces[v.x][v.y] = null;
});
let chessboard =
@@
-2475,6
+2481,10
@@
export default class ChessRules {
animateMoving(start, end, drag, segments, cb) {
let initPiece = this.getDomPiece(start.x, start.y);
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";
// NOTE: cloning often not required, but light enough, and simpler
let movingPiece = initPiece.cloneNode();
initPiece.style.opacity = "0";