From: Benjamin Auder <benjamin.auder@somewhere>
Date: Thu, 9 Apr 2020 11:04:07 +0000 (+0200)
Subject: Fix disconnexion => remove challenges in main Hall
X-Git-Url: https://git.auder.net/variants/Apocalypse/scripts/current/pieces/doc/mini-custom.min.css?a=commitdiff_plain;h=aef58d08d7c453f7ae7947e718c3bd6f092f02f2;p=vchess.git

Fix disconnexion => remove challenges in main Hall
---

diff --git a/client/src/translations/rules/Sittuyin/en.pug b/client/src/translations/rules/Sittuyin/en.pug
index ab959b82..d9703ac4 100644
--- a/client/src/translations/rules/Sittuyin/en.pug
+++ b/client/src/translations/rules/Sittuyin/en.pug
@@ -56,6 +56,8 @@ p.
   If you only have one pawn remaining, it can promote from any square.
   Promotion is always in a general, and you can have only one general on the
   board.
+  The promoted general cannot attack any opponent's piece, nor can he discover
+  a rook attack on the enemy king.
 
 h3 Source
 
diff --git a/client/src/translations/rules/Sittuyin/es.pug b/client/src/translations/rules/Sittuyin/es.pug
index 0a76725b..f7a757e0 100644
--- a/client/src/translations/rules/Sittuyin/es.pug
+++ b/client/src/translations/rules/Sittuyin/es.pug
@@ -59,6 +59,8 @@ p.
   Si solo le queda un peón, puede ser promovido desde cualquier asunto.
   La promoción siempre se realiza en un general, y solo puede tener uno
   general en el tablero de ajedrez.
+  El general promovido no debe atacar una pieza contraria, ni descubrir un
+  ataque de la torre al rey enemigo.
 
 h3 Fuente
 
diff --git a/client/src/translations/rules/Sittuyin/fr.pug b/client/src/translations/rules/Sittuyin/fr.pug
index c8cad9f9..4b6ee434 100644
--- a/client/src/translations/rules/Sittuyin/fr.pug
+++ b/client/src/translations/rules/Sittuyin/fr.pug
@@ -58,6 +58,8 @@ p.
   n'importe quelle case.
   La promotion s'effectue toujours en un général, et vous ne pouvez avoir qu'un
   général sur l'échiquier.
+  Le général promu ne doit pas attaquer une pièce adverse, ni découvrir une
+  attaque de tour sur le roi ennemi.
 
 h3 Source
 
diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue
index cb088088..ee8d53e5 100644
--- a/client/src/views/Hall.vue
+++ b/client/src/views/Hall.vue
@@ -681,12 +681,19 @@ export default {
             this.$delete(this.people, data.from[0]);
           else this.$forceUpdate(); //TODO: shouldn't be required
           if (data.code == "disconnect") {
-            // Remove the live challenges sent by this player:
-            ArrayFun.remove(
-              this.challenges,
-              c => c.type == "live" && c.from.sid == data.from[0],
-              "all"
-            );
+            // Remove the live challenges sent by this player, if
+            // he isn't connected on another tab:
+            if (
+              !this.people[data.from[0]] ||
+              Object.values(this.people[data.from[0]].tmpIds)
+                .every(v => v.page != "/")
+            ) {
+              ArrayFun.remove(
+                this.challenges,
+                c => c.type == "live" && c.from.sid == data.from[0],
+                "all"
+              );
+            }
           } else {
             // Remove the matching live game if now unreachable
             const gid = data.page.match(/[a-zA-Z0-9]+$/)[0];