chore(tools): 查找肉鸽招募中未提及的干员 (#9865)

This commit is contained in:
Manicsteiner
2024-09-03 21:04:11 +08:00
committed by GitHub
parent f4362b44f9
commit 39ac002224
2 changed files with 46 additions and 0 deletions

1
tools/RoguelikeOperSearch/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
missing*

View File

@@ -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)