Spaces:
Running
Running
ChenyuRabbitLove
commited on
Commit
•
97cd51a
1
Parent(s):
a969205
feature: add render player avatar
Browse files- app.py +3 -0
- utils/utils.py +3 -0
app.py
CHANGED
@@ -11,6 +11,7 @@ from utils.utils import (
|
|
11 |
get_player_adventure_logs_html,
|
12 |
get_player_achievements,
|
13 |
get_current_story,
|
|
|
14 |
save_latest_player_data,
|
15 |
)
|
16 |
|
@@ -117,6 +118,8 @@ with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
|
|
117 |
player_info_query_btn.click(get_player_achievements, player_info, achievements)
|
118 |
).then(
|
119 |
player_info_query_btn.click(get_current_story, None, adventure)
|
|
|
|
|
120 |
)
|
121 |
|
122 |
pull_newest_player_data.submit(
|
|
|
11 |
get_player_adventure_logs_html,
|
12 |
get_player_achievements,
|
13 |
get_current_story,
|
14 |
+
get_player_avatar,
|
15 |
save_latest_player_data,
|
16 |
)
|
17 |
|
|
|
118 |
player_info_query_btn.click(get_player_achievements, player_info, achievements)
|
119 |
).then(
|
120 |
player_info_query_btn.click(get_current_story, None, adventure)
|
121 |
+
).then(
|
122 |
+
player_info_query_btn.click(get_player_avatar, player_info, avatar)
|
123 |
)
|
124 |
|
125 |
pull_newest_player_data.submit(
|
utils/utils.py
CHANGED
@@ -39,6 +39,9 @@ def get_player_partners(player_info: gr.State) -> List[str]:
|
|
39 |
def get_player_badges(player_info: gr.State) -> List[str]:
|
40 |
return [f"{MEDIA_PATH}{badge}{MEDIA_FILE_TYPE}" for badge in player_info["badges"]]
|
41 |
|
|
|
|
|
|
|
42 |
|
43 |
def get_player_adventure_logs(player_info: gr.State) -> List[str]:
|
44 |
log_template = """<div class="adventure"><p>{player_log}</p></div>"""
|
|
|
39 |
def get_player_badges(player_info: gr.State) -> List[str]:
|
40 |
return [f"{MEDIA_PATH}{badge}{MEDIA_FILE_TYPE}" for badge in player_info["badges"]]
|
41 |
|
42 |
+
def get_player_avatar(player_info: gr.State) -> str:
|
43 |
+
return f"{AVATAR_PATH}avatar_{player_info['player_group'] + 1}{AVATAR_FILE_TYPE}"
|
44 |
+
|
45 |
|
46 |
def get_player_adventure_logs(player_info: gr.State) -> List[str]:
|
47 |
log_template = """<div class="adventure"><p>{player_log}</p></div>"""
|