Spaces:
Sleeping
Sleeping
Commit
·
82eb64f
1
Parent(s):
77f112d
feat: add get player achivement status function
Browse files- utils/utils.py +46 -0
utils/utils.py
CHANGED
|
@@ -41,3 +41,49 @@ def get_player_adventure_logs_html(player_info: gr.State) -> str:
|
|
| 41 |
adventure_logs = "".join(get_player_adventure_logs(player_info))
|
| 42 |
template_content = get_content("htmls/adventure_template.html")
|
| 43 |
return template_content.replace("{logs}", adventure_logs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
adventure_logs = "".join(get_player_adventure_logs(player_info))
|
| 42 |
template_content = get_content("htmls/adventure_template.html")
|
| 43 |
return template_content.replace("{logs}", adventure_logs)
|
| 44 |
+
|
| 45 |
+
def get_player_achievements(player_info: gr.State) -> List[str]:
|
| 46 |
+
achivement_name_map = {
|
| 47 |
+
"participation_star": "參賽之星",
|
| 48 |
+
"star_score_settler": "星際積分領航者",
|
| 49 |
+
"interstellar_traveler_I": "星際旅行者 I",
|
| 50 |
+
"interstellar_traveler_II": "星際旅行者 II",
|
| 51 |
+
"interstellar_traveler_III": "星際旅行者 III",
|
| 52 |
+
"interstellar_traveler_IV": "星際旅行者 IV",
|
| 53 |
+
"consistent_climbers_club_I": "連續爬升俱樂部 I",
|
| 54 |
+
"consistent_climbers_club_II": "連續爬升俱樂部 II",
|
| 55 |
+
"consistent_climbers_club_III": "連續爬升俱樂部 III",
|
| 56 |
+
"star_cluster_detector": "星團探測官",
|
| 57 |
+
"starry_vigilante": "群星瞭望者",
|
| 58 |
+
"planetary_decoder": "行星解碼",
|
| 59 |
+
"galactic_librarian": "星系圖書館員",
|
| 60 |
+
"energy_enthusiast_I": "能量狂熱者 I",
|
| 61 |
+
"energy_enthusiast_II": "能量狂熱者 II",
|
| 62 |
+
"energy_enthusiast_III": "能量狂熱者 III",
|
| 63 |
+
"energy_enthusiast_IV": "能量狂熱者 IV",
|
| 64 |
+
"knowledge_planet_explorer_I": "知識星球探險家 I",
|
| 65 |
+
"knowledge_planet_explorer_II": "知識星球探險家 II",
|
| 66 |
+
"scientific_expedition_explorer_I": "科學探險探險家 I",
|
| 67 |
+
"scientific_expedition_explorer_II": "科學探險探險家 II",
|
| 68 |
+
"cultural_celebration_explorer_I": "文化慶典探險家 I",
|
| 69 |
+
"cultural_celebration_explorer_II": "文化慶典探險家 II",
|
| 70 |
+
"youth_literature_explorer_I": "青春文學探險家 I",
|
| 71 |
+
"youth_literature_explorer_II": "青春文學探險家 II",
|
| 72 |
+
"path_to_wealth_explorer_I": "財富之路探險家 I",
|
| 73 |
+
"path_to_wealth_explorer_II": "財富之路探險家 II",
|
| 74 |
+
"cultivation_universe_explorer_I": "素養宇宙探險家 I",
|
| 75 |
+
"cultivation_universe_explorer_II": "素養宇宙探險家 II",
|
| 76 |
+
"electronic_and_information_college_explorer_I": "電資學院探險家 I",
|
| 77 |
+
"electronic_and_information_college_explorer_II": "電資學院探險家 II",
|
| 78 |
+
"star_warrior": "星空學霸",
|
| 79 |
+
}
|
| 80 |
+
print(player_info["rewards_status"])
|
| 81 |
+
rewards_status = json.loads(player_info["rewards_status"])
|
| 82 |
+
# rewards_status rountine_achevement sholud be removed
|
| 83 |
+
return [
|
| 84 |
+
(
|
| 85 |
+
achivement_name_map[achievement_key],
|
| 86 |
+
"完成" if achievement_value["is_completed"] else "未完成",
|
| 87 |
+
)
|
| 88 |
+
for achievement_key, achievement_value in rewards_status.items()
|
| 89 |
+
]
|