From 39ac00222482f28a00a1be1f54ef976c017d0412 Mon Sep 17 00:00:00 2001 From: Manicsteiner <63437036+Manicsteiner@users.noreply.github.com> Date: Tue, 3 Sep 2024 21:04:11 +0800 Subject: [PATCH] =?UTF-8?q?chore(tools):=20=E6=9F=A5=E6=89=BE=E8=82=89?= =?UTF-8?q?=E9=B8=BD=E6=8B=9B=E5=8B=9F=E4=B8=AD=E6=9C=AA=E6=8F=90=E5=8F=8A?= =?UTF-8?q?=E7=9A=84=E5=B9=B2=E5=91=98=20(#9865)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/RoguelikeOperSearch/.gitignore | 1 + .../RoguelikeOperSearch.py | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tools/RoguelikeOperSearch/.gitignore create mode 100644 tools/RoguelikeOperSearch/RoguelikeOperSearch.py diff --git a/tools/RoguelikeOperSearch/.gitignore b/tools/RoguelikeOperSearch/.gitignore new file mode 100644 index 0000000000..be85086f94 --- /dev/null +++ b/tools/RoguelikeOperSearch/.gitignore @@ -0,0 +1 @@ +missing* \ No newline at end of file diff --git a/tools/RoguelikeOperSearch/RoguelikeOperSearch.py b/tools/RoguelikeOperSearch/RoguelikeOperSearch.py new file mode 100644 index 0000000000..9aa21d0c5b --- /dev/null +++ b/tools/RoguelikeOperSearch/RoguelikeOperSearch.py @@ -0,0 +1,45 @@ +import os +import json + +cur_dir = os.path.dirname(os.path.abspath(__file__)) +proj_dir = os.path.join(cur_dir, "../../") + +battle_data_path = os.path.join(proj_dir, "resource/battle_data.json") +theme_paths = { + "Phantom": os.path.join(proj_dir, "resource/roguelike/Phantom/recruitment.json"), + "Mizuki": os.path.join(proj_dir, "resource/roguelike/Mizuki/recruitment.json"), + "Sami": os.path.join(proj_dir, "resource/roguelike/Sami/recruitment.json"), + "Sarkaz": os.path.join(proj_dir, "resource/roguelike/Sarkaz/recruitment.json") +} + +def read_battle_data_names(): + with open(battle_data_path, 'r', encoding='utf-8') as f: + data = json.load(f) + names = [] + for key, value in data.get("chars", {}).items(): + if key.startswith("char_"): + if value.get("rarity") and value.get("rarity") >=3: + name = value.get("name") + if name: + names.append(name) + return names + +def check_recruitment_files(names): + missing_oper = {} + for theme, path in theme_paths.items(): + missing_oper[theme] = [] + with open(path, 'r', encoding='utf-8') as f: + content = f.read() + for name in names: + if content.find(f'"{name}"') == -1: + missing_oper[theme].append(name) + + # 输出到missing_oper.txt + with open(os.path.join(cur_dir, 'missing_oper.txt'), 'w', encoding='utf-8') as f: + for theme, missing_names in missing_oper.items(): + if missing_names: + f.write(f"{theme}: {' , '.join(missing_names)}\n") + +if __name__ == "__main__": + names = read_battle_data_names() + check_recruitment_files(names)