Merge pull request #71 from hppeng-wynn/atree_hotfix

added nodes to all of the archer abilties in constants (not min yet tho)
This commit is contained in:
hppeng-wynn 2022-07-03 01:21:58 -05:00 committed by GitHub
commit 200a541ecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 148 additions and 87 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
*.swp *.swp
*.bat *.bat
*.json
sets/ sets/
.idea/ .idea/

View 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

View file

@ -9,7 +9,8 @@ const atrees = {
"cost": 1, "cost": 1,
"display": { "display": {
"row": 9, "row": 9,
"col": 6 "col": 6,
"icon": "node_4"
}, },
"properties": { "properties": {
"charges": 2, "charges": 2,
@ -49,7 +50,8 @@ const atrees = {
"cost": 1, "cost": 1,
"display": { "display": {
"row": 7, "row": 7,
"col": 4 "col": 4,
"icon": "node_4"
}, },
"properties": { "properties": {
"aoe": 0, "aoe": 0,
@ -73,7 +75,8 @@ const atrees = {
"cost": 1, "cost": 1,
"display": { "display": {
"row": 0, "row": 0,
"col": 4 "col": 4,
"icon": "node_4"
}, },
"properties": { "properties": {
"aoe": 4.5, "aoe": 4.5,
@ -111,7 +114,8 @@ const atrees = {
"cost": 1, "cost": 1,
"display": { "display": {
"row": 4, "row": 4,
"col": 4 "col": 4,
"icon": "node_1"
}, },
"properties": {}, "properties": {},
"effects": [ "effects": [
@ -139,7 +143,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 16, "row": 16,
"col": 6 "col": 6,
"icon": "node_1"
}, },
"properties": { "properties": {
"aoe": 0.8, "aoe": 0.8,
@ -170,7 +175,7 @@ const atrees = {
"dependencies": ["Arrow Storm"], "dependencies": ["Arrow Storm"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 16, "col": 8 }, "display": { "row": 16, "col": 8, "icon": "node_1"},
"properties": { "properties": {
"aoe": 2, "aoe": 2,
"duration": 5 "duration": 5
@ -199,7 +204,7 @@ const atrees = {
"dependencies": ["Arrow Storm"], "dependencies": ["Arrow Storm"],
"blockers": ["Phantom Ray"], "blockers": ["Phantom Ray"],
"cost": 2, "cost": 2,
"display": { "row": 15, "col": 2 }, "display": { "row": 15, "col": 2, "icon": "node_1"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -223,7 +228,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 1, "cost": 1,
"display": { "row": 9, "col": 2 }, "display": { "row": 9, "col": 2, "icon": "node_4"},
"properties": { "range": 16 }, "properties": { "range": 16 },
"effects": [ "effects": [
{ {
@ -263,7 +268,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 19, "row": 19,
"col": 1 "col": 1,
"icon": "node_3"
}, },
"properties": { "properties": {
"range": 4, "range": 4,
@ -311,7 +317,8 @@ const atrees = {
"cost": 1, "cost": 1,
"display": { "display": {
"row": 10, "row": 10,
"col": 1 "col": 1,
"icon": "node_0"
}, },
"properties": { "properties": {
"aoe": 8, "aoe": 8,
@ -341,7 +348,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 19, "row": 19,
"col": 8 "col": 8,
"icon": "node_3"
}, },
"properties": { "properties": {
"aoe": 7, "aoe": 7,
@ -366,7 +374,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 21, "row": 21,
"col": 1 "col": 1,
"icon": "node_1"
}, },
"properties": {}, "properties": {},
"effects": [ "effects": [
@ -404,7 +413,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 21, "row": 21,
"col": 5 "col": 5,
"icon": "node_2"
}, },
"properties": { "properties": {
"range": 26 "range": 26
@ -423,7 +433,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 22, "row": 22,
"col": 6 "col": 6,
"icon": "node_1"
}, },
"properties": {}, "properties": {},
"effects": [ "effects": [
@ -446,7 +457,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 25, "row": 25,
"col": 4 "col": 4,
"icon": "node_2"
}, },
"properties": { "properties": {
"range": 64, "range": 64,
@ -480,7 +492,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 26, "col": 1 }, "display": { "row": 26, "col": 1, "icon": "node_1"},
"properties": { "properties": {
"aoe": 4 "aoe": 4
}, },
@ -513,7 +525,7 @@ const atrees = {
"dependencies": ["Fire Creep"], "dependencies": ["Fire Creep"],
"blockers": [], "blockers": [],
"cost": 1, "cost": 1,
"display": { "row": 26, "col": 5 }, "display": { "row": 26, "col": 5, "icon": "node_1"},
"properties": { "properties": {
"duration": 2, "duration": 2,
"aoe": 0.4 "aoe": 0.4
@ -536,7 +548,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 28, "col": 0 }, "display": { "row": 28, "col": 0, "icon": "node_1"},
"properties": { "properties": {
"cooldown": 2 "cooldown": 2
}, },
@ -552,7 +564,7 @@ const atrees = {
"dependencies": ["Arrow Bomb"], "dependencies": ["Arrow Bomb"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 28, "col": 4 }, "display": { "row": 28, "col": 4, "icon": "node_1"},
"properties": { "properties": {
"gravity": 0 "gravity": 0
}, },
@ -576,7 +588,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 28, "row": 28,
"col": 8 "col": 8,
"icon": "node_3"
}, },
"properties": { "properties": {
"range": 16, "range": 16,
@ -602,7 +615,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 31, "row": 31,
"col": 0 "col": 0,
"icon": "node_1"
}, },
"properties": {}, "properties": {},
"effects": [ "effects": [
@ -630,7 +644,7 @@ const atrees = {
"dependencies": ["Focus"], "dependencies": ["Focus"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 31, "col": 5 }, "display": { "row": 31, "col": 5, "icon": "node_2"},
"properties": {}, "properties": {},
"effects": [] "effects": []
}, },
@ -644,7 +658,7 @@ const atrees = {
"dependencies": ["Arrow Shield"], "dependencies": ["Arrow Shield"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 32, "col": 7 }, "display": { "row": 32, "col": 7, "icon": "node_2"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -665,7 +679,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": ["Phantom Ray"], "blockers": ["Phantom Ray"],
"cost": 2, "cost": 2,
"display": { "row": 33, "col": 0 }, "display": { "row": 33, "col": 0, "icon": "node_3"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -684,7 +698,7 @@ const atrees = {
"dependencies": ["Fierce Stomp"], "dependencies": ["Fierce Stomp"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 37, "col": 1 }, "display": { "row": 37, "col": 1, "icon": "node_1"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -721,7 +735,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 37, "row": 37,
"col": 4 "col": 4,
"icon": "node_3"
}, },
"properties": {}, "properties": {},
"effects": [ "effects": [
@ -755,7 +770,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 37, "col": 7 }, "display": { "row": 37, "col": 7, "icon": "node_2"},
"properties": { "properties": {
"aoe": 2 "aoe": 2
}, },
@ -783,7 +798,7 @@ const atrees = {
"dependencies": ["Basaltic Trap"], "dependencies": ["Basaltic Trap"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 38, "col": 6 }, "display": {"row": 38, "col": 6, "icon": "node_1"},
"properties": { "properties": {
"attackSpeed": 0.2 "attackSpeed": 0.2
}, },
@ -815,7 +830,8 @@ const atrees = {
"cost": 2, "cost": 2,
"display": { "display": {
"row": 39, "row": 39,
"col": 2 "col": 2,
"icon": "node_2"
}, },
"properties": { "properties": {
"range": 2.5, "range": 2.5,
@ -833,7 +849,7 @@ const atrees = {
"dependencies": ["Guardian Angels"], "dependencies": ["Guardian Angels"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 40, "col": 1 }, "display": { "row": 40, "col": 1, "icon": "node_3"},
"properties": { "properties": {
"range": 8, "range": 8,
"shots": 5 "shots": 5
@ -863,7 +879,7 @@ const atrees = {
"dependencies": ["Basaltic Trap"], "dependencies": ["Basaltic Trap"],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "row": 40, "col": 7 }, "display": {"row": 40, "col": 7, "icon": "node_3"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -900,7 +916,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 1, "cost": 1,
"display": { "row": 2, "col": 4 }, "display": { "row": 2, "col": 4, "icon": "node_0"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -923,7 +939,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 1, "cost": 1,
"display": { "row": 2, "col": 6 }, "display": {"row": 2, "col": 6, "icon": "node_0"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -941,7 +957,7 @@ const atrees = {
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 1, "cost": 1,
"display": { "row": 21, "col": 3 }, "display": {"row": 21, "col": 3, "icon": "node_0"},
"properties": {}, "properties": {},
"effects": [ "effects": [
{ {
@ -1840,7 +1856,7 @@ const atrees = {
"display": { "display": {
"row": 17, "row": 17,
"col": 2, "col": 2,
"icon": "node_0" "icon": "node_1"
}, },
"properties": {}, "properties": {},
"effects": [{ "effects": [{

File diff suppressed because one or more lines are too long

View file

@ -13,6 +13,7 @@ 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())
def translate_id(id_data, atree_data):
for _class, info in atree_data.items(): for _class, info in atree_data.items():
def translate(path, ref): def translate(path, ref):
ref_dict = info ref_dict = info
@ -59,6 +60,7 @@ for _class, info in atree_data.items():
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)

View file

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