2026-01-20 10:13:51 +08:00
|
|
|
'''
|
|
|
|
|
读取卡牌定义文件列表和内容
|
|
|
|
|
'''
|
2026-01-02 21:47:28 +08:00
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
def readCardList() -> dict:
|
2026-01-05 13:07:53 +08:00
|
|
|
with open("resources/cards/list.json", "r", encoding="utf8") as f:
|
2026-01-02 21:47:28 +08:00
|
|
|
text = f.read()
|
|
|
|
|
result = json.loads(text)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2026-01-20 09:34:24 +08:00
|
|
|
card_list = readCardList()
|
|
|
|
|
|
2026-01-02 21:47:28 +08:00
|
|
|
def readCard(id: str):
|
2026-01-20 09:34:24 +08:00
|
|
|
path = card_list.get(id, -1)
|
2026-01-05 09:30:43 +08:00
|
|
|
if (path == -1):
|
|
|
|
|
return {"message": f"No Card {id}"}
|
2026-01-05 13:07:53 +08:00
|
|
|
with open(f"resources/cards/{path}.json", "r", encoding="utf8") as f:
|
2026-01-05 09:30:43 +08:00
|
|
|
text = f.read()
|
|
|
|
|
result = json.loads(text)
|
|
|
|
|
|
|
|
|
|
return {"message": "OK", "content": result}
|