| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import os
- import json
- from game.const import rouge_theme as rt
- def main(root_dir="."):
- for dirpath, _, filenames in os.walk(root_dir):
- for filename in filenames:
- if filename.lower().endswith(".json"):
- file_path = os.path.join(dirpath, filename)
- try:
- with open(file_path, "r", encoding="utf-8") as f:
- try:
- data = json.load(f)
- except json.JSONDecodeError:
- print(f"[跳过] {file_path} 不是有效的 JSON 文件")
- continue
- if data.get("skills", None) is None:
- continue
- mon_type = "normal"
- if data.get("elite", False):
- mon_type = "elite"
- elif data.get("boss", False):
- mon_type = "boss"
- speed = "极慢"
- if 1 <= data["speed"] <= 2.5:
- speed = "慢"
- elif 2.5 < data["speed"] <= 3.5:
- speed = "中"
- elif 3.5 < data["speed"] <= 4.5:
- speed = "快"
- elif 4.5 < data["speed"]:
- speed = "极快"
- sight = "极小"
- if 2 < data["resent_dist"] <= 3:
- sight = "小"
- elif 3 < data["resent_dist"] <= 5:
- sight = "中"
- elif 5 < data["resent_dist"] <= 7:
- sight = "大"
- elif 7 < data["resent_dist"]:
- sight = "极大"
- new_data = {
- "chs_name": data["chs_name"],
- "character": data["character"],
- "type": mon_type,
- "blood": data["blood"],
- "speed": speed,
- "contact": data["contact"],
- "defense": data["defense"],
- "resent_dist": sight,
- "info": "???",
- "strategy": "???"
- }
- # 覆盖写回文件
- with open(file_path, "w", encoding="utf-8") as f:
- json.dump(new_data, f, ensure_ascii=False, indent=4)
- print(f"[更新完成] {file_path}")
- except Exception as e:
- print(f"[错误] {file_path}: {e}")
- def test():
- l = []
- for k in rt.theme_skyland_mon_dic.keys():
- l.append(k)
- print(l)
- if __name__ == "__main__":
- main(".")
- # test()
- pass
|