From 57cbea204d0ee66509783664af9757f9273fa254 Mon Sep 17 00:00:00 2001
From: Jesusaves <cpntb1@ymail.com>
Date: Tue, 18 May 2021 00:03:46 -0300
Subject: Create mySoul structure and make the /souldata request

---
 game/client.rpy | 22 ++++++++++++++++++++--
 game/renpy.rpy  |  5 ++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/game/client.rpy b/game/client.rpy
index 9b5a8fe..9a26ea3 100644
--- a/game/client.rpy
+++ b/game/client.rpy
@@ -138,8 +138,26 @@ init 2 python:
     ############################################
     # TODO: Launch thread requesting /soul data
     def load_souldata():
-        global progress
-        progress = 100
+        global progress, responsive, vaultId, vaultToken, mySoul
+        try:
+            auth = {"vaultId": vaultId,
+                    "token": vaultToken}
+
+            ## Make the POST request
+            r=vault.post(VAULT_HOST+"/souldata", json=auth, timeout=15.0)
+            if r.status_code != 200:
+                raise Exception("Request error: %d" % r.status_code)
+            dat=r.json()
+
+            ## Update mySoul
+            mySoul={}
+            mySoul["level"]=dat["soulv"]
+            mySoul["exp"]=dat["soulx"]
+            progress = 100
+        except:
+            traceback.print_exc()
+            mySoul = None
+            responsive = False
         return
 
 
diff --git a/game/renpy.rpy b/game/renpy.rpy
index f87c368..824e29e 100644
--- a/game/renpy.rpy
+++ b/game/renpy.rpy
@@ -262,6 +262,7 @@ Soul Level remains constant regardless of the subworld you're at.{/color}{fast}"
 #################################################################################
 label thevoid:
     $ progress = 0
+    $ mySoul = None
     $ renpy.invoke_in_thread(load_souldata)
     scene DKBG
     show expression (ManaSparkle().sm) as flare
@@ -276,7 +277,9 @@ label thevoid:
             else:
                 break
     hide loader with None
-    pause
+    if mySoul is not None:
+        $ stdout("Level %d EXP %d" % (mySoul["level"], mySoul["exp"]))
+        pause
     scene black with Dissolve(1.5)
     pause 0.15
     return
-- 
cgit v1.2.3-70-g09d2