Add Ambiguous. Fix a few issues with FEN generation / options
[xogo.git] / base_rules.js
index 8ad0894..1b22ae5 100644 (file)
@@ -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: