Spaces:
Running
Running
ChenyuRabbitLove
commited on
Commit
•
cfdf3bc
1
Parent(s):
97cd51a
fix: modify get_player_info function
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import json
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
@@ -20,12 +21,14 @@ seafoam = Seafoam()
|
|
20 |
def get_player_info(player_backend_user_id):
|
21 |
with open("latest_player_data.json", "r", encoding="utf-8") as file:
|
22 |
player_info = json.load(file)
|
23 |
-
|
24 |
-
|
25 |
-
return player_info
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
|
30 |
|
31 |
# start of gradio interface
|
|
|
1 |
import json
|
2 |
+
import logging
|
3 |
|
4 |
import gradio as gr
|
5 |
|
|
|
21 |
def get_player_info(player_backend_user_id):
|
22 |
with open("latest_player_data.json", "r", encoding="utf-8") as file:
|
23 |
player_info = json.load(file)
|
24 |
+
|
25 |
+
if player_backend_user_id in player_info:
|
26 |
+
return player_info[player_backend_user_id]
|
27 |
+
else:
|
28 |
+
logging.info(f"No data found for player ID {player_backend_user_id}. Initializing new player data.")
|
29 |
+
|
30 |
+
new_player = Player(player_backend_user_id=player_backend_user_id, init=True)
|
31 |
+
return new_player.to_dict()
|
32 |
|
33 |
|
34 |
# start of gradio interface
|