X-Git-Url: https://git.auder.net/variants/%24%7Bvname%7D/current/gitweb.css?a=blobdiff_plain;f=base_rules.js;h=2d08bd614d0123a7c69a05475606696dd80e87c3;hb=518bfb7a260f95e282f763878c2e9cf5ba58ef86;hp=11b8b30fbaffc43958bcab57d2bfd8fa23123e28;hpb=b9877ed29697640d72b8f3d89848863fc87bd7e8;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 11b8b30..2d08bd6 100644 --- a/base_rules.js +++ b/base_rules.js @@ -779,8 +779,8 @@ export default class ChessRules { piece = "k"; //capturing cannibal king: back to king form const oldCount = this.reserve[color][piece]; this.reserve[color][piece] = count; - // Redrawing is much easier if count==0 - if ([oldCount, count].includes(0)) + // Redrawing is much easier if count==0 (or undefined) + if ([oldCount, count].some(item => !item)) this.re_drawReserve([color]); else { const numId = this.getReserveNumId(color, piece); @@ -2340,14 +2340,13 @@ export default class ChessRules { } postPlay(move) { - const color = this.turn; if (this.options["dark"]) this.updateEnlightened(); if (this.options["teleport"]) { if ( this.subTurnTeleport == 1 && move.vanish.length > move.appear.length && - move.vanish[1].c == color + move.vanish[1].c == this.turn ) { const v = move.vanish[move.vanish.length - 1]; this.captured = {x: v.x, y: v.y, c: v.c, p: v.p}; @@ -2357,8 +2356,12 @@ export default class ChessRules { this.subTurnTeleport = 1; this.captured = null; } + this.tryChangeTurn(move); + } + + tryChangeTurn(move) { if (this.isLastMove(move)) { - this.turn = C.GetOppCol(color); + this.turn = C.GetOppCol(this.turn); this.movesCount++; this.subTurn = 1; }