X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=85666e209bd361f7de93df1afb92f6874705299f;hb=bc97fdd1302473b774cfb19e65dc3ed3ed388901;hp=a8dad15c575141e666b5326289ca7d36fee37a1d;hpb=df3fdaff8fa7b3046eb67e4bc4da37a5bcc8c4d7;p=xogo.git diff --git a/base_rules.js b/base_rules.js index a8dad15..85666e2 100644 --- a/base_rules.js +++ b/base_rules.js @@ -2320,7 +2320,7 @@ export default class ChessRules { tryChangeTurn(move) { if (this.isLastMove(move)) { - this.turn = (this.turn == 'w' ? 'b' : 'w'); + this.turn = C.GetOppTurn(this.turn); this.movesCount++; this.subTurn = 1; } @@ -2406,7 +2406,8 @@ export default class ChessRules { 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 = @@ -2475,6 +2476,10 @@ export default class ChessRules { 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";