-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_evos.py
36 lines (33 loc) · 1.15 KB
/
add_evos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import json
import pathlib
import re
import os
if __name__ == "__main__":
sprites_dir = pathlib.Path("./public") / "sprites"
data_file = "src/Libraries/Pokemon/allGens.json"
evo_data_file = "evoData.json"
missing = []
with open(evo_data_file) as f:
evo_data = json.load(f)
with open(data_file) as f:
data = json.load(f)
# Try to transform the name to get the file
all_mon_names = [mon["name"].lower() for gen in data.values() for mon in gen.values()]
for gen in data.values():
for mon in gen.values():
if mon.get("evos"):
continue
name = mon["name"].lower()
try:
evos = evo_data[name].get("evos")
except KeyError:
missing.append(name)
continue
evos = [e for e in evos if e.lower() in all_mon_names] if evos else None
if evos:
mon["evos"] = evos
for m in missing:
print(m)
print(f'Missing total of {len(missing)}')
with open(data_file, "w") as f:
json.dump(data, f, indent=4)