X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=1b22ae5e256588eb4d8731e37e7ace4df68eaa31;hb=554e3ad3773a3123701bd894db1df4c1843283b8;hp=8ad0894e2972c074d8474844e15d52511fefc7d8;hpb=3b641716d7e86d9f1b39d1e046ce197e6b5a8075;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 8ad0894..1b22ae5 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1007,6 +1007,8 @@ export default class ChessRules { let chessboard = container.querySelector(".chessboard"); let choices = document.createElement("div"); choices.id = "choices"; + if (!r) + r = chessboard.getBoundingClientRect(); choices.style.width = r.width + "px"; choices.style.height = r.height + "px"; choices.style.left = r.x + "px"; @@ -1906,10 +1908,12 @@ export default class ChessRules { return [-1, -1]; //king not found } - filterValid(moves) { + // Some variants (e.g. Refusal) may need to check opponent moves too + filterValid(moves, color) { if (moves.length == 0) return []; - const color = this.turn; + if (!color) + color = this.turn; const oppCol = C.GetOppCol(color); if (this.options["balance"] && [1, 3].includes(this.movesCount)) { // Forbid moves either giving check or exploding opponent's king: