-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoves.py
42 lines (31 loc) · 1.16 KB
/
moves.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
37
38
39
40
41
42
import os
import json
from encoders import decodeMoveFile
moveNameDedupe = {}
moves = []
directory = os.path.join(".", "moves")
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(".ini"):
moveData = decodeMoveFile(os.path.join(".", "moves", file))
moves.append(moveData)
# Sort by index
movesSorted = sorted(moves, key=lambda x: int(x["index"]))
# Clean up the data
for move in movesSorted:
del move["index"]
# Move all fields from attackData to base object, equivalent of JavaScript's spread operator
for key in move["attackData"]:
move[key] = move["attackData"][key]
del move["attackData"]
move["type"] = move["type_name"]
del move["type_name"]
# Fix Curse type
if move["name"] == "Curse":
move["type"] = "Ghost"
# Fix Hidden Power names
if move["name"] == "Hidden Power" and move["power"] == 70:
move["name"] = f'{move["name"]} ({move["type"]})'
del move["description"]
with open(os.path.join(".", "src", "moves.json"), "w") as fjson:
json.dump(movesSorted, fjson, indent=4, default=str)