2022-06-25 15:03:03 +00:00
|
|
|
"""
|
2022-06-27 09:23:22 +00:00
|
|
|
Generate a JSON Ability Tree [atree_constants_id.json] with:
|
2022-06-25 15:03:03 +00:00
|
|
|
- All references replaced by numerical IDs
|
2022-06-27 09:23:22 +00:00
|
|
|
- Extra JSON File with Class: [Original name as key and Assigned IDs as value].
|
|
|
|
given a JSON Ability Tree with reference as string.
|
2022-06-25 15:03:03 +00:00
|
|
|
"""
|
|
|
|
import json
|
|
|
|
|
|
|
|
abilDict = {}
|
2022-06-27 09:23:22 +00:00
|
|
|
with open("atree_constants.json") as f:
|
2022-06-25 15:03:03 +00:00
|
|
|
data = json.loads(f.read())
|
|
|
|
for classType, info in data.items():
|
2022-06-27 09:23:22 +00:00
|
|
|
_id = 0
|
|
|
|
abilDict[classType] = {}
|
2022-06-25 15:03:03 +00:00
|
|
|
for abil in info:
|
2022-06-27 09:23:22 +00:00
|
|
|
abilDict[classType][abil["display_name"]] = _id
|
|
|
|
_id += 1
|
2022-06-25 15:03:03 +00:00
|
|
|
|
2022-06-27 09:23:22 +00:00
|
|
|
with open("atree_ids.json", "w", encoding='utf-8') as id_dest:
|
2022-06-25 15:03:03 +00:00
|
|
|
json.dump(abilDict, id_dest, ensure_ascii=False, indent=4)
|
|
|
|
|
|
|
|
for classType, info in data.items():
|
|
|
|
for abil in range(len(info)):
|
2022-06-27 09:23:22 +00:00
|
|
|
info[abil]["id"] = abilDict[classType][info[abil]["display_name"]]
|
2022-06-25 15:03:03 +00:00
|
|
|
for ref in range(len(info[abil]["parents"])):
|
2022-06-27 09:23:22 +00:00
|
|
|
info[abil]["parents"][ref] = abilDict[classType][info[abil]["parents"][ref]]
|
2022-06-25 15:03:03 +00:00
|
|
|
|
|
|
|
for ref in range(len(info[abil]["dependencies"])):
|
2022-06-27 09:23:22 +00:00
|
|
|
info[abil]["dependencies"][ref] = abilDict[classType][info[abil]["dependencies"][ref]]
|
2022-06-25 15:03:03 +00:00
|
|
|
|
|
|
|
for ref in range(len(info[abil]["blockers"])):
|
2022-06-27 09:23:22 +00:00
|
|
|
info[abil]["blockers"][ref] = abilDict[classType][info[abil]["blockers"][ref]]
|
2022-06-25 15:03:03 +00:00
|
|
|
|
2022-06-27 09:23:22 +00:00
|
|
|
with open('atree_constants_id.json', 'w', encoding='utf-8') as abil_dest:
|
|
|
|
json.dump(data, abil_dest, ensure_ascii=False, indent=4)
|