This commit is contained in:
2026-06-24 14:34:17 +08:00
parent d8ceb93ea7
commit 97ad05baa5
8 changed files with 358 additions and 96 deletions
+32 -1
View File
@@ -50,6 +50,37 @@ def gold_to_string(gold_amount):
return "".join(parts)
def gold_to_parts(gold_amount):
"""将铜钱数拆成模板可渲染的货币片段"""
try:
amount = int(gold_amount or 0)
except (TypeError, ValueError):
amount = 0
if amount <= 0:
return []
bricks = amount // 100000000
gold = (amount % 100000000) // 10000
silver = (amount % 10000) // 100
copper = amount % 100
parts = []
started = False
for key, name, value in [
("zhuang", "", bricks),
("jin", "", gold),
("yin", "", silver),
("tong", "", copper),
]:
if value != 0:
started = True
if started:
parts.append({"key": key, "name": name, "value": value})
return parts
def week_to_num(week :str):
week_map = {
"": 0,
@@ -110,4 +141,4 @@ def load_as_base64(icons_dir: str) -> dict[str, str]:
icons[display_name] = f"data:{mime};base64,{data}"
return icons
return icons