Attempt to prevent other tabs new games while playing (...)
authorBenjamin Auder <benjamin.auder@somewhere>
Sun, 18 Nov 2018 12:50:22 +0000 (13:50 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sun, 18 Nov 2018 12:50:22 +0000 (13:50 +0100)
public/javascripts/components/game.js

index 9e00d12..1e68fe6 100644 (file)
@@ -466,6 +466,13 @@ Vue.component('my-game', {
                        this.score = "*";
                        if (mode=="human" && !oppId)
                        {
+                               const storageVariant = localStorage.getItem("variant");
+                               if (!!storageVariant && storageVariant !== variant)
+                               {
+                                       // TODO: find a better way to ensure this. Newgame system is currently a mess.
+                                       alert("Finish your " + storageVariant + " game first!");
+                                       return;
+                               }
                                // Send game request and wait..
                                this.clearStorage(); //in case of
                                try {