From 0709b5f40a4ed8bf8c0602e169950b2ea578d180 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 16 Jan 2021 15:10:54 +0100
Subject: [PATCH] Fix bugs in Bario

---
 client/src/variants/Bario.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/src/variants/Bario.js b/client/src/variants/Bario.js
index 57dd18ea..e895aeef 100644
--- a/client/src/variants/Bario.js
+++ b/client/src/variants/Bario.js
@@ -350,7 +350,7 @@ export class BarioRules extends ChessRules {
       ];
       let [i, j] = [x1 + step[0], y1 + step[1]];
       while (i != x2 || j != y2) {
-        if (this.board[i][j] != V.EMPTY) return false;
+        if (!V.OnBoard(i, j) || this.board[i][j] != V.EMPTY) return false;
         i += step[0];
         j += step[1];
       }
@@ -426,6 +426,7 @@ export class BarioRules extends ChessRules {
     else {
       if (move.vanish.length == 2 && move.vanish[1].p == V.UNDEFINED)
         this.captureUndefined.push(move.end);
+      else this.captureUndefined.push(null);
       if (move.appear[0].p == V.KING) super.postPlay(move);
       else {
         // If now all my pieces are defined, back to undefined state,
@@ -538,8 +539,7 @@ export class BarioRules extends ChessRules {
       for (let j = 0; j < 8; j++) this.board[firstRank][j] = "";
     }
     else {
-      if (move.vanish.length == 2 && move.vanish[1].p == V.UNDEFINED)
-        this.captureUndefined.pop();
+      this.captureUndefined.pop();
       if (move.appear[0].p == V.KING) super.postUndo(move);
       else {
         if (!!move.position) {
-- 
2.44.0