Minify file, update minify script, add README for minifying
This commit is contained in:
parent
b3ef2e2ff4
commit
f7d4946c4b
5 changed files with 97 additions and 52 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
*.swp
|
*.swp
|
||||||
*.bat
|
*.bat
|
||||||
|
*.json
|
||||||
sets/
|
sets/
|
||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
|
|
5
js/README_atree_constants.md
Normal file
5
js/README_atree_constants.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
How to convert:
|
||||||
|
|
||||||
|
1. edit `atree_constants.js`
|
||||||
|
2. run `python3 ../py_script/atree-generateID.py
|
||||||
|
3. check that the site still works
|
File diff suppressed because one or more lines are too long
|
@ -13,52 +13,54 @@ with open("atree_ids.json") as f:
|
||||||
with open("atree_constants.json") as f:
|
with open("atree_constants.json") as f:
|
||||||
atree_data = json.loads(f.read())
|
atree_data = json.loads(f.read())
|
||||||
|
|
||||||
for _class, info in atree_data.items():
|
def translate_id(id_data, atree_data):
|
||||||
def translate(path, ref):
|
for _class, info in atree_data.items():
|
||||||
ref_dict = info
|
def translate(path, ref):
|
||||||
for x in path:
|
ref_dict = info
|
||||||
ref_dict = ref_dict[x]
|
for x in path:
|
||||||
ref_dict[ref] = id_data[_class][ref_dict[ref]]
|
ref_dict = ref_dict[x]
|
||||||
|
ref_dict[ref] = id_data[_class][ref_dict[ref]]
|
||||||
for abil in range(len(info)):
|
|
||||||
info[abil]["id"] = id_data[_class][info[abil]["display_name"]]
|
for abil in range(len(info)):
|
||||||
for ref in range(len(info[abil]["parents"])):
|
info[abil]["id"] = id_data[_class][info[abil]["display_name"]]
|
||||||
translate([abil, "parents"], ref)
|
for ref in range(len(info[abil]["parents"])):
|
||||||
|
translate([abil, "parents"], ref)
|
||||||
|
|
||||||
for ref in range(len(info[abil]["dependencies"])):
|
for ref in range(len(info[abil]["dependencies"])):
|
||||||
translate([abil, "dependencies"], ref)
|
translate([abil, "dependencies"], ref)
|
||||||
|
|
||||||
for ref in range(len(info[abil]["blockers"])):
|
for ref in range(len(info[abil]["blockers"])):
|
||||||
translate([abil, "blockers"], ref)
|
translate([abil, "blockers"], ref)
|
||||||
|
|
||||||
if "base_abil" in info[abil]:
|
if "base_abil" in info[abil]:
|
||||||
base_abil_name = info[abil]["base_abil"]
|
base_abil_name = info[abil]["base_abil"]
|
||||||
if base_abil_name in id_data[_class]:
|
if base_abil_name in id_data[_class]:
|
||||||
translate([abil], "base_abil")
|
translate([abil], "base_abil")
|
||||||
|
|
||||||
if "effects" not in info[abil]:
|
if "effects" not in info[abil]:
|
||||||
print("WARNING: abil missing 'effects' tag")
|
print("WARNING: abil missing 'effects' tag")
|
||||||
print(info[abil])
|
print(info[abil])
|
||||||
info[abil]["effects"] = []
|
info[abil]["effects"] = []
|
||||||
for effect in info[abil]["effects"]:
|
for effect in info[abil]["effects"]:
|
||||||
if effect["type"] == "raw_stat":
|
if effect["type"] == "raw_stat":
|
||||||
for bonus in effect["bonuses"]:
|
for bonus in effect["bonuses"]:
|
||||||
if "abil" in bonus and bonus["abil"] in id_data[_class]:
|
if "abil" in bonus and bonus["abil"] in id_data[_class]:
|
||||||
bonus["abil"] = id_data[_class][bonus["abil"]]
|
bonus["abil"] = id_data[_class][bonus["abil"]]
|
||||||
|
|
||||||
elif effect["type"] == "stat_scaling":
|
elif effect["type"] == "stat_scaling":
|
||||||
if "inputs" in effect: # Might not exist for sliders
|
if "inputs" in effect: # Might not exist for sliders
|
||||||
for _input in effect["inputs"]:
|
for _input in effect["inputs"]:
|
||||||
if "abil" in _input and _input["abil"] in id_data[_class]:
|
if "abil" in _input and _input["abil"] in id_data[_class]:
|
||||||
_input["abil"] = id_data[_class][_input["abil"]]
|
_input["abil"] = id_data[_class][_input["abil"]]
|
||||||
if isinstance(effect["output"], list):
|
if isinstance(effect["output"], list):
|
||||||
for output in effect["output"]:
|
for output in effect["output"]:
|
||||||
if "abil" in output and output["abil"] in id_data[_class]:
|
if "abil" in output and output["abil"] in id_data[_class]:
|
||||||
output["abil"] = id_data[_class][output["abil"]]
|
output["abil"] = id_data[_class][output["abil"]]
|
||||||
else:
|
else:
|
||||||
if "abil" in effect["output"] and effect["output"]["abil"] in id_data[_class]:
|
if "abil" in effect["output"] and effect["output"]["abil"] in id_data[_class]:
|
||||||
effect["output"]["abil"] = id_data[_class][effect["output"]["abil"]]
|
effect["output"]["abil"] = id_data[_class][effect["output"]["abil"]]
|
||||||
|
|
||||||
|
translate_id(id_data, atree_data)
|
||||||
|
|
||||||
with open('atree_constants_idfied.json', 'w', encoding='utf-8') as abil_dest:
|
with open('atree_constants_idfied.json', 'w', encoding='utf-8') as abil_dest:
|
||||||
json.dump(atree_data, abil_dest, ensure_ascii=False, indent=4)
|
json.dump(atree_data, abil_dest, ensure_ascii=False, indent=4)
|
||||||
|
|
|
@ -6,6 +6,53 @@ given [atree_constants.js] .js form of the Ability Tree with reference as string
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
def translate_id(id_data, atree_data):
|
||||||
|
for _class, info in atree_data.items():
|
||||||
|
def translate(path, ref):
|
||||||
|
ref_dict = info
|
||||||
|
for x in path:
|
||||||
|
ref_dict = ref_dict[x]
|
||||||
|
ref_dict[ref] = id_data[_class][ref_dict[ref]]
|
||||||
|
|
||||||
|
for abil in range(len(info)):
|
||||||
|
info[abil]["id"] = id_data[_class][info[abil]["display_name"]]
|
||||||
|
for ref in range(len(info[abil]["parents"])):
|
||||||
|
translate([abil, "parents"], ref)
|
||||||
|
|
||||||
|
for ref in range(len(info[abil]["dependencies"])):
|
||||||
|
translate([abil, "dependencies"], ref)
|
||||||
|
|
||||||
|
for ref in range(len(info[abil]["blockers"])):
|
||||||
|
translate([abil, "blockers"], ref)
|
||||||
|
|
||||||
|
if "base_abil" in info[abil]:
|
||||||
|
base_abil_name = info[abil]["base_abil"]
|
||||||
|
if base_abil_name in id_data[_class]:
|
||||||
|
translate([abil], "base_abil")
|
||||||
|
|
||||||
|
if "effects" not in info[abil]:
|
||||||
|
print("WARNING: abil missing 'effects' tag")
|
||||||
|
print(info[abil])
|
||||||
|
info[abil]["effects"] = []
|
||||||
|
for effect in info[abil]["effects"]:
|
||||||
|
if effect["type"] == "raw_stat":
|
||||||
|
for bonus in effect["bonuses"]:
|
||||||
|
if "abil" in bonus and bonus["abil"] in id_data[_class]:
|
||||||
|
bonus["abil"] = id_data[_class][bonus["abil"]]
|
||||||
|
|
||||||
|
elif effect["type"] == "stat_scaling":
|
||||||
|
if "inputs" in effect: # Might not exist for sliders
|
||||||
|
for _input in effect["inputs"]:
|
||||||
|
if "abil" in _input and _input["abil"] in id_data[_class]:
|
||||||
|
_input["abil"] = id_data[_class][_input["abil"]]
|
||||||
|
if isinstance(effect["output"], list):
|
||||||
|
for output in effect["output"]:
|
||||||
|
if "abil" in output and output["abil"] in id_data[_class]:
|
||||||
|
output["abil"] = id_data[_class][output["abil"]]
|
||||||
|
else:
|
||||||
|
if "abil" in effect["output"] and effect["output"]["abil"] in id_data[_class]:
|
||||||
|
effect["output"]["abil"] = id_data[_class][effect["output"]["abil"]]
|
||||||
|
|
||||||
abilDict = {}
|
abilDict = {}
|
||||||
with open("atree_constants.js") as f:
|
with open("atree_constants.js") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
@ -21,17 +68,7 @@ with open("atree_constants.js") as f:
|
||||||
with open("atree_ids.json", "w", encoding='utf-8') as id_dest:
|
with open("atree_ids.json", "w", encoding='utf-8') as id_dest:
|
||||||
json.dump(abilDict, id_dest, ensure_ascii=False, indent=4)
|
json.dump(abilDict, id_dest, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
for classType, info in data.items():
|
translate_id(abilDict, data)
|
||||||
for abil in range(len(info)):
|
|
||||||
info[abil]["id"] = abilDict[classType][info[abil]["display_name"]]
|
|
||||||
for ref in range(len(info[abil]["parents"])):
|
|
||||||
info[abil]["parents"][ref] = abilDict[classType][info[abil]["parents"][ref]]
|
|
||||||
|
|
||||||
for ref in range(len(info[abil]["dependencies"])):
|
|
||||||
info[abil]["dependencies"][ref] = abilDict[classType][info[abil]["dependencies"][ref]]
|
|
||||||
|
|
||||||
for ref in range(len(info[abil]["blockers"])):
|
|
||||||
info[abil]["blockers"][ref] = abilDict[classType][info[abil]["blockers"][ref]]
|
|
||||||
|
|
||||||
data_str = json.dumps(data, ensure_ascii=False, separators=(',', ':'))
|
data_str = json.dumps(data, ensure_ascii=False, separators=(',', ':'))
|
||||||
data_str = "const atrees=" + data_str
|
data_str = "const atrees=" + data_str
|
||||||
|
|
Loading…
Reference in a new issue