Merge branch 'atree' into sock_encoding

This commit is contained in:
ferricles 2022-07-04 22:25:37 -07:00
commit e8a9439b64
11 changed files with 2120 additions and 1379 deletions

3105
clean.json

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -39,6 +39,9 @@ add_spell_prop: {
base_spell: int // spell identifier base_spell: int // spell identifier
target_part: Optional[str] // Part of the spell to modify. Can be not present/empty for ex. cost modifier. target_part: Optional[str] // Part of the spell to modify. Can be not present/empty for ex. cost modifier.
// If target part does not exist, a new part is created. // If target part does not exist, a new part is created.
behavior: Optional[str] // One of: "merge", "modify". default: merge
// merge: add if exist, make new part if not exist
// modify: change existing part. do nothing if not exist
cost: Optional[int] // change to spellcost cost: Optional[int] // change to spellcost
multipliers: Optional[array[float, 6]] // Additive changes to spellmult (for damage spell) multipliers: Optional[array[float, 6]] // Additive changes to spellmult (for damage spell)
power: Optional[float] // Additive change to healing power (for heal spell) power: Optional[float] // Additive change to healing power (for heal spell)
@ -57,6 +60,9 @@ raw_stat: {
type: "raw_stat" type: "raw_stat"
toggle: Optional[bool | str] // default: false; true means create anon. toggle, toggle: Optional[bool | str] // default: false; true means create anon. toggle,
// string value means bind to (or create) named button // string value means bind to (or create) named button
behavior: Optional[str] // One of: "merge", "modify". default: merge
// merge: add if exist, make new part if not exist
// modify: change existing part. do nothing if not exist
bonuses: List[stat_bonus] bonuses: List[stat_bonus]
} }
stat_bonus: { stat_bonus: {
@ -452,7 +458,7 @@ const atree_collect_spells = new (class extends ComputeNode {
has_spell_def = true; has_spell_def = true;
// replace_spell just replaces all (defined) aspects. // replace_spell just replaces all (defined) aspects.
for (const key in effect) { for (const key in effect) {
ret_spell[key] = effect[key]; ret_spell[key] = deepcopy(effect[key]);
} }
} }
} }
@ -465,7 +471,7 @@ const atree_collect_spells = new (class extends ComputeNode {
// Already handled above. // Already handled above.
continue; continue;
case 'add_spell_prop': { case 'add_spell_prop': {
const { base_spell, target_part = null, cost = 0} = effect; const { base_spell, target_part = null, cost = 0, behavior = 'merge'} = effect;
if (base_spell !== base_spell_id) { continue; } // TODO: redundant? if we assume abils only affect one spell if (base_spell !== base_spell_id) { continue; } // TODO: redundant? if we assume abils only affect one spell
ret_spell.cost += cost; ret_spell.cost += cost;
@ -497,7 +503,7 @@ const atree_collect_spells = new (class extends ComputeNode {
break; break;
} }
} }
if (!found_part) { // add part. if (!found_part && behavior === 'merge') { // add part. if behavior is merge
let spell_part = deepcopy(effect); let spell_part = deepcopy(effect);
spell_part.name = target_part; // has some extra fields but whatever spell_part.name = target_part; // has some extra fields but whatever
ret_spell.parts.push(spell_part); ret_spell.parts.push(spell_part);

View file

@ -267,16 +267,16 @@ const atrees = {
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "display": {
"row": 19, "row": 19,
"col": 1, "col": 1,
"icon": "node_3" "icon": "node_3"
}, },
"properties": { "properties": {
"range": 4, "range": 4,
"duration": 60, "duration": 60,
"shots": 8, "shots": 8,
"count": 2 "charges": 2
}, },
"effects": [ "effects": [
{ {
"type": "replace_spell", "type": "replace_spell",
@ -583,7 +583,7 @@ const atrees = {
"archetype_req": 5, "archetype_req": 5,
"base_abil": "Arrow Bomb", "base_abil": "Arrow Bomb",
"parents": ["More Traps", "Better Arrow Shield"], "parents": ["More Traps", "Better Arrow Shield"],
"dependencies": ["Fire Creep"], "dependencies": [],
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "display": {
@ -1192,7 +1192,7 @@ const atrees = {
"type": "add_spell_prop", "type": "add_spell_prop",
"base_spell": 4, "base_spell": 4,
"target_part": "Total Damage", "target_part": "Total Damage",
"hits": { "Shield Damage": 2 } "hits": { "Shield Damage": 2, "Single Bow": 2 }
}, },
{ {
"type": "raw_stat", "type": "raw_stat",
@ -1304,6 +1304,7 @@ const atrees = {
"type": "add_spell_prop", "type": "add_spell_prop",
"base_spell": 3, "base_spell": 3,
"target_part": "Arrow Shield", "target_part": "Arrow Shield",
"behavior": "modify",
"multipliers": [40, 0, 0, 0, 0, 0] "multipliers": [40, 0, 0, 0, 0, 0]
}, },
{ {
@ -1311,6 +1312,7 @@ const atrees = {
"bonuses": [{ "bonuses": [{
"type": "prop", "type": "prop",
"abil": "Arrow Shield", "abil": "Arrow Shield",
"behavior": "modify",
"name": "aoe", "name": "aoe",
"value": 1 "value": 1
}] }]
@ -1677,7 +1679,7 @@ const atrees = {
"display": { "display": {
"row": 19, "row": 19,
"col": 4, "col": 4,
"icon": "node_2" "icon": "node_3"
}, },
"properties": {}, "properties": {},
"effects": [{ "effects": [{
@ -3319,7 +3321,7 @@ const atrees = {
"display_name": "Rejuvenating Skin", "display_name": "Rejuvenating Skin",
"desc": "Regain back 30% of the damage you take as healing over 30s", "desc": "Regain back 30% of the damage you take as healing over 30s",
"archetype": "Paladin", "archetype": "Paladin",
"archetype_req": 0, "archetype_req": 5,
"parents": ["Burning Heart", "Stronger Bash"], "parents": ["Burning Heart", "Stronger Bash"],
"dependencies": [], "dependencies": [],
"blockers": [], "blockers": [],

File diff suppressed because one or more lines are too long

View file

@ -51,7 +51,7 @@ let boosts_node = new (class extends ComputeNode {
} }
let res = new Map(); let res = new Map();
res.set('damageMultiplier', 1+damage_boost); res.set('damageMultiplier', 1+damage_boost);
res.set('defMultiplier', 1+def_boost); res.set('defMultiplier', 1-def_boost);
return res; return res;
} }
})().update(); })().update();
@ -610,6 +610,7 @@ class SpellDamageCalcNode extends ComputeNode {
const dam_res_keys = ['normal_min', 'normal_max', 'normal_total', 'crit_min', 'crit_max', 'crit_total']; const dam_res_keys = ['normal_min', 'normal_max', 'normal_total', 'crit_min', 'crit_max', 'crit_total'];
for (const [subpart_name, hits] of Object.entries(part.hits)) { for (const [subpart_name, hits] of Object.entries(part.hits)) {
const subpart = spell_result_map.get(subpart_name); const subpart = spell_result_map.get(subpart_name);
if (!subpart) { continue; }
if (spell_result.type) { if (spell_result.type) {
if (subpart.type !== spell_result.type) { if (subpart.type !== spell_result.type) {
throw "SpellCalc total subpart type mismatch"; throw "SpellCalc total subpart type mismatch";

View file

@ -1,4 +1,4 @@
const DB_VERSION = 90; const DB_VERSION = 91;
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.jsA // @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.jsA
let db; let db;

100
py_script/items_common.py Normal file
View file

@ -0,0 +1,100 @@
translate_mappings = {
#"name": "name",
#"displayName": "displayName",
#"tier": "tier",
#"set": "set",
"sockets": "slots",
#"type": "type",
#"armorType": "armorType", (deleted)
"armorColor": "color", #(deleted)
"addedLore": "lore", #(deleted)
#"material": "material", (deleted)
"dropType": "drop",
#"quest": "quest",
"restrictions": "restrict",
"damage": "nDam",
"fireDamage": "fDam",
"waterDamage": "wDam",
"airDamage": "aDam",
"thunderDamage": "tDam",
"earthDamage": "eDam",
"attackSpeed": "atkSpd",
"health": "hp",
"fireDefense": "fDef",
"waterDefense": "wDef",
"airDefense": "aDef",
"thunderDefense": "tDef",
"earthDefense": "eDef",
"level": "lvl",
"classRequirement": "classReq",
"strength": "strReq",
"dexterity": "dexReq",
"intelligence": "intReq",
"agility": "agiReq",
"defense": "defReq",
"healthRegen": "hprPct",
"manaRegen": "mr",
"spellDamage": "sdPct",
"damageBonus": "mdPct",
"lifeSteal": "ls",
"manaSteal": "ms",
"xpBonus": "xpb",
"lootBonus": "lb",
"reflection": "ref",
"strengthPoints": "str",
"dexterityPoints": "dex",
"intelligencePoints": "int",
"agilityPoints": "agi",
"defensePoints": "def",
#"thorns": "thorns",
"exploding": "expd",
"speed": "spd",
"attackSpeedBonus": "atkTier",
#"poison": "poison",
"healthBonus": "hpBonus",
"soulPoints": "spRegen",
"emeraldStealing": "eSteal",
"healthRegenRaw": "hprRaw",
"spellDamageRaw": "sdRaw",
"damageBonusRaw": "mdRaw",
"bonusFireDamage": "fDamPct",
"bonusWaterDamage": "wDamPct",
"bonusAirDamage": "aDamPct",
"bonusThunderDamage": "tDamPct",
"bonusEarthDamage": "eDamPct",
"bonusFireDefense": "fDefPct",
"bonusWaterDefense": "wDefPct",
"bonusAirDefense": "aDefPct",
"bonusThunderDefense": "tDefPct",
"bonusEarthDefense": "eDefPct",
"accessoryType": "type",
"identified": "fixID",
#"skin": "skin",
#"category": "category",
"spellCostPct1": "spPct1",
"spellCostRaw1": "spRaw1",
"spellCostPct2": "spPct2",
"spellCostRaw2": "spRaw2",
"spellCostPct3": "spPct3",
"spellCostRaw3": "spRaw3",
"spellCostPct4": "spPct4",
"spellCostRaw4": "spRaw4",
"rainbowSpellDamageRaw": "rainbowRaw",
#"sprint": "sprint",
"sprintRegen": "sprintReg",
"jumpHeight": "jh",
"lootQuality": "lq",
"gatherXpBonus": "gXp",
"gatherSpeed": "gSpd",
}
delete_keys = [
#"addedLore",
#"skin",
#"armorType",
#"armorColor",
#"material"
]

23
py_script/merge.json Normal file
View file

@ -0,0 +1,23 @@
{"items": [
{"name":"Keratoconus","type":"helmet","level":101,"tier":"Legendary","sockets":3,"majorIds":[],"intelligence":65,"agility":65,"intelligencePoints":15,"defensePoints":-10,"health":3900,"thunderDefense":-150,"fireDefense":-150,"airDefense":250,"tDamPct-base":-40,"wDamPct-base":30,"aDamPct-base":35,"hprPct-base":-50,"mr-base":8,"spRaw4-base":-4,"category":"armor","displayName":"Keratoconus","bonusThunderDamage":-40,"bonusWaterDamage":30,"bonusAirDamage":35,"healthRegen":-50,"manaRegen":8,"spellCostRaw4":-4,"identified":false},
{"name":"Wanderlust","type":"chestplate","level":103,"tier":"Legendary","sockets":2,"majorIds":[],"dexterity":45,"agility":55,"health":3500,"thunderDefense":75,"waterDefense":100,"fireDefense":-75,"airDefense":100,"wDamPct-base":20,"aDamPct-base":30,"sdRaw-base":208,"hprPct-base":-15,"ms-base":-11,"ls-base":230,"spd-base":25,"category":"armor","displayName":"Wanderlust","bonusWaterDamage":20,"bonusAirDamage":30,"spellDamageRaw":208,"healthRegen":-15,"manaSteal":-12,"lifeSteal":230,"speed":25,"identified":false},
{"name":"Anaerobic","type":"leggings","level":104,"tier":"Legendary","majorIds":[],"strength":60,"agility":60,"strengthPoints":12,"health":3850,"earthDefense":100,"waterDefense":-150,"airDefense":100,"eDamPct-base":24,"aDamPct-base":32,"atkTier-base":-1,"mr-base":8,"ref-base":48,"spRaw1-base":-5,"category":"armor","displayName":"Anaerobic","bonusEarthDamage":24,"bonusAirDamage":32,"attackSpeedBonus":-1,"manaRegen":8,"reflection":48,"spellCostRaw1":-8,"identified":false},
{"name":"Danse Macabre","type":"relik","level":102,"tier":"Rare","sockets":1,"majorIds":[],"classRequirement":"Shaman","dexterity":55,"defense":50,"damage":"0-0","earthDamage":"0-0","thunderDamage":"24-214","waterDamage":"0-0","fireDamage":"97-141","airDamage":"0-0","attackSpeed":"VERY_FAST","sdRaw-base":184,"atkTier-base":1,"hpBonus-base":-1150,"hprPct-base":-204,"ms-base":13,"spRaw1-base":-7,"category":"weapon","displayName":"Danse Macabre","basedps":238,"spellDamageRaw":184,"attackSpeedBonus":1,"healthBonus":-1150,"healthRegen":-204,"manaSteal":13,"spellCostRaw1":-7,"identified":false},
{"name":"Darkness's Dogma","type":"bow","level":103,"tier":"Rare","sockets":3,"majorIds":[],"classRequirement":"Archer","intelligence":60,"defense":50,"damage":"0-0","earthDamage":"0-0","thunderDamage":"0-0","waterDamage":"600-650","fireDamage":"550-700","airDamage":"0-0","attackSpeed":"SUPER_SLOW","hpBonus-base":1500,"wDefPct-base":-50,"fDefPct-base":-50,"ms-base":13,"ls-base":-700,"ref-base":25,"category":"weapon","displayName":"Darkness's Dogma","basedps":1250,"healthBonus":1500,"bonusWaterDefense":-50,"bonusFireDefense":-50,"manaSteal":13,"lifeSteal":-700,"reflection":25,"identified":false},
{"name":"Frameshift","type":"wand","level":104,"tier":"Rare","sockets":3,"majorIds":[],"classRequirement":"Mage","strength":40,"defense":60,"defensePoints":20,"damage":"0-0","earthDamage":"150-210","thunderDamage":"0-0","waterDamage":"0-0","fireDamage":"160-200","airDamage":"0-0","attackSpeed":"VERY_SLOW","wDamPct-base":-30,"mdPct-base":25,"mr-base":7,"ls-base":380,"spRaw1-base":-4,"category":"weapon","displayName":"Frameshift","basedps":360,"bonusWaterDamage":-30,"damageBonus":25,"manaRegen":7,"lifeSteal":380,"spellCostRaw1":-4,"identified":false},
{"name":"Helminth","type":"spear","level":102,"tier":"Rare","sockets":2,"majorIds":[],"classRequirement":"Warrior","dexterity":65,"damage":"0-0","earthDamage":"0-0","thunderDamage":"1-199","waterDamage":"0-0","fireDamage":"0-0","airDamage":"0-0","attackSpeed":"SUPER_FAST","tDamPct-base":20,"atkTier-base":1,"hpBonus-base":-1250,"wDefPct-base":-35,"aDefPct-base":-35,"ls-base":500,"category":"weapon","displayName":"Helminth","basedps":100,"bonusThunderDamage":20,"attackSpeedBonus":1,"healthBonus":-1250,"bonusWaterDefense":-35,"bonusAirDefense":-35,"lifeSteal":500,"identified":false},
{"name":"Lanternfly Leg","type":"dagger","level":101,"tier":"Rare","sockets":3,"majorIds":[],"classRequirement":"Assassin","defense":50,"agility":50,"damage":"150-210","earthDamage":"0-0","thunderDamage":"0-0","waterDamage":"0-0","fireDamage":"0-0","airDamage":"0-0","attackSpeed":"FAST","fDamPct-base":23,"aDamPct-base":23,"hpBonus-base":1000,"jh-base":1,"spd-base":30,"spRaw2-base":-2,"category":"weapon","displayName":"Lanternfly Leg","basedps":180,"bonusFireDamage":23,"bonusAirDamage":23,"healthBonus":1000,"jumpHeight":1,"speed":30,"spellCostRaw2":-4,"identified":false},
{"name":"Dissonance","type":"helmet","level":103,"tier":"Unique","sockets":2,"majorIds":[],"dexterity":50,"intelligence":50,"health":3050,"thunderDefense":100,"waterDefense":100,"airDefense":-175,"tDamPct-base":12,"wDamPct-base":20,"sdPct-base":20,"ls-base":-275,"spd-base":-20,"sprint-base":20,"lb-base":20,"category":"armor","displayName":"Dissonance","bonusThunderDamage":12,"bonusWaterDamage":20,"spellDamage":20,"lifeSteal":-275,"speed":-20,"sprint":20,"lootBonus":20,"identified":false},
{"name":"Roridula","type":"chestplate","level":104,"tier":"Unique","sockets":2,"majorIds":[],"strength":55,"intelligence":55,"strengthPoints":10,"health":3675,"earthDefense":150,"fireDefense":-150,"tDamPct-base":-30,"wDamPct-base":25,"ms-base":8,"spd-base":15,"spPct4-base":14,"xpb-base":25,"category":"armor","displayName":"Roridula","bonusThunderDamage":-30,"bonusWaterDamage":25,"manaSteal":8,"speed":15,"spellCostPct4":14,"xpBonus":25,"identified":false},
{"name":"Atomizer","type":"leggings","level":102,"tier":"Unique","sockets":3,"majorIds":[],"agility":75,"agilityPoints":8,"health":3450,"waterDefense":120,"fireDefense":120,"airDefense":200,"poison-base":600,"wDefPct-base":31,"fDefPct-base":31,"hprPct-base":37,"thorns-base":25,"jh-base":1,"category":"armor","displayName":"Atomizer","poison":600,"bonusWaterDefense":31,"bonusFireDefense":31,"healthRegen":37,"thorns":25,"jumpHeight":1,"identified":false},
{"name":"Wasteland Azalea","type":"boots","level":101,"tier":"Unique","sockets":3,"majorIds":[],"strength":45,"agility":50,"health":2750,"earthDefense":75,"fireDefense":-75,"eDamPct-base":25,"aDamPct-base":25,"sdRaw-base":140,"atkTier-base":-1,"poison-base":500,"sprint-base":-15,"spRaw3-base":-6,"category":"armor","displayName":"Wasteland Azalea","bonusEarthDamage":25,"bonusAirDamage":25,"spellDamageRaw":140,"attackSpeedBonus":-1,"poison":500,"sprint":-15,"spellCostRaw3":-6,"identified":false},
{"name":"Tranquility","type":"ring","level":101,"tier":"Unique","majorIds":[],"dexterity":45,"intelligence":45,"strengthPoints":-3,"dexterityPoints":-3,"health":550,"waterDefense":50,"fireDefense":50,"sdPct-base":5,"hprPct-base":17,"spd-base":-7,"category":"accessory","displayName":"Tranquility","spellDamage":5,"healthRegen":17,"speed":-7,"identified":false},
{"name":"Misalignment","type":"bracelet","level":101,"tier":"Unique","majorIds":[],"strength":35,"dexterity":45,"dexterityPoints":3,"intelligencePoints":3,"eDamPct-base":6,"tDamPct-base":6,"wDamPct-base":10,"mr-base":3,"category":"accessory","displayName":"Misalignment","bonusEarthDamage":6,"bonusThunderDamage":6,"bonusWaterDamage":10,"manaRegen":3,"identified":false},
{"name":"Grafted Eyestalk","type":"necklace","level":101,"tier":"Unique","majorIds":[],"defense":40,"agility":40,"defensePoints":5,"agilityPoints":5,"health":-600,"earthDefense":-40,"thunderDefense":-40,"sdPct-base":8,"hprPct-base":-11,"spRaw1-base":-1,"category":"accessory","displayName":"Grafted Eyestalk","spellDamage":8,"healthRegen":-12,"spellCostRaw1":-1,"identified":false},
{"name":"Forbearance","type":"ring","level":105,"tier":"Fabled","majorIds":[],"dexterity":60,"intelligence":60,"dexterityPoints":6,"intelligencePoints":6,"tDamPct-base":-15,"wDamPct-base":-15,"mr-base":4,"ls-base":120,"category":"accessory","displayName":"Forbearance","bonusThunderDamage":-15,"bonusWaterDamage":-15,"manaRegen":4,"lifeSteal":120,"identified":false},
{"name":"Ingress","type":"ring","level":105,"tier":"Fabled","majorIds":[],"strength":55,"agility":55,"dexterityPoints":4,"intelligencePoints":2,"defensePoints":4,"earthDefense":55,"airDefense":55,"eDamPct-base":8,"aDamPct-base":8,"sdRaw-base":55,"category":"accessory","displayName":"Ingress","bonusEarthDamage":8,"bonusAirDamage":8,"spellDamageRaw":55,"identified":false},
{"name":"Breakthrough","type":"bracelet","level":105,"tier":"Fabled","majorIds":[],"intelligence":45,"agility":45,"strengthPoints":-4,"dexterityPoints":-4,"defensePoints":-6,"earthDefense":-45,"thunderDefense":-45,"fireDefense":-30,"sdPct-base":13,"sdRaw-base":75,"ms-base":6,"spRaw2-base":-4,"category":"accessory","displayName":"Breakthrough","spellDamage":13,"spellDamageRaw":75,"manaSteal":6,"spellCostRaw2":-4,"identified":false},
{"name":"Detachment","type":"bracelet","level":105,"tier":"Fabled","majorIds":[],"dexterity":55,"agility":60,"thunderDefense":60,"airDefense":60,"mdRaw-base":-85,"sdRaw-base":-65,"spd-base":13,"spPct4-base":-13,"category":"accessory","displayName":"Detachment","damageBonusRaw":-85,"spellDamageRaw":-65,"speed":13,"spellCostPct4":-13,"identified":false},
{"name":"Exhibition","type":"necklace","level":105,"tier":"Fabled","majorIds":[],"intelligence":80,"earthDefense":-30,"thunderDefense":-30,"waterDefense":60,"fireDefense":-30,"airDefense":-30,"mr-base":-4,"spRaw1-base":-2,"spRaw2-base":-2,"spRaw3-base":-2,"spRaw4-base":-2,"category":"accessory","displayName":"Exhibition","manaRegen":-4,"spellCostRaw1":-2,"spellCostRaw2":-2,"spellCostRaw3":-2,"spellCostRaw4":-2,"identified":false},
{"name":"Simulacrum","type":"necklace","level":105,"tier":"Fabled","majorIds":[],"strength":55,"defense":45,"health":-800,"earthDefense":-70,"fireDefense":-90,"sdRaw-base":150,"hprRaw-base":-150,"mr-base":5,"spd-base":8,"category":"accessory","displayName":"Simulacrum","spellDamageRaw":150,"healthRegenRaw":-150,"manaRegen":5,"speed":8,"identified":false}
]}

117
py_script/merge_items.py Normal file
View file

@ -0,0 +1,117 @@
"""
Used to process the raw item data pulled from the API.
Usage:
- python process_items.py [infile] [outfile]
OR
- python process_items.py [infile and outfile]
"""
import json
import sys
import os
import base64
import argparse
from items_common import translate_mappings, delete_keys
parser = argparse.ArgumentParser(description="Process raw pulled item data.")
parser.add_argument('infile', help='input file to read data from')
parser.add_argument('outfile', help='output file to dump clean data into')
args = parser.parse_args()
infile, outfile = args.infile, args.outfile
with open(infile, "r") as in_file:
data = json.loads(in_file.read())
items = data["items"]
if "request" in data:
del data["request"]
with open("./clean.json", "r") as oldfile:
old_data = json.load(oldfile)
old_items = old_data['items']
id_map = {item["name"]: item["id"] for item in old_items}
with open("id_map_tmp.json", "r") as idmap_file:
id_map = json.load(idmap_file)
used_ids = set([v for k, v in id_map.items()])
max_id = 0
known_item_names = set()
for item in items:
known_item_names.add(item["name"])
# TEMP wynn2 migration
mul_keys = {
"spPct1": 0.7,
"spPct2": 0.7,
"spPct3": 0.7,
"spPct4": 0.7,
"spRaw1": 5,
"spRaw2": 5,
"spRaw3": 5,
"spRaw4": 5,
"mr": 5,
"ms": 5
}
remap_items = []
#old_items_map = dict()
import math
for item in old_items:
for k, v in mul_keys.items():
if k in item:
item[k] = math.floor(round(item[k] * v))
if "remapID" in item:
remap_items.append(item)
elif item["name"] not in known_item_names:
items.append(item)
#print(f'Unknown old item: {item["name"]}!!!')
#old_items_map[item["name"]] = item
for item in items:
for key in delete_keys:
if key in item:
del item[key]
for k in list(item.keys()):
if (item[k] == 0 or item[k] is None):
del item[k]
for k, v in translate_mappings.items():
if k in item:
item[v] = item[k]
del item[k]
if not (item["name"] in id_map):
while max_id in used_ids:
max_id += 1
used_ids.add(max_id)
id_map[item["name"]] = max_id
print(f'New item: {item["name"]} (id: {max_id})')
item["id"] = id_map[item["name"]]
item["type"] = item["type"].lower()
if "displayName" in item:
item_name = item["displayName"]
else:
item_name = item["name"]
items.extend(remap_items)
#write items back into data
data["items"] = items
data["sets"] = old_data["sets"]
#save id map
with open("id_map_tmp.json","w") as id_mapfile:
json.dump(id_map, id_mapfile, indent=2)
#write the data back to the outfile
with open(outfile, "w+") as out_file:
json.dump(data, out_file)

View file

@ -15,6 +15,7 @@ import sys
import os import os
import base64 import base64
import argparse import argparse
from items_common import translate_mappings, delete_keys
parser = argparse.ArgumentParser(description="Process raw pulled item data.") parser = argparse.ArgumentParser(description="Process raw pulled item data.")
parser.add_argument('infile', help='input file to read data from') parser.add_argument('infile', help='input file to read data from')
@ -30,108 +31,6 @@ items = data["items"]
if "request" in data: if "request" in data:
del data["request"] del data["request"]
translate_mappings = {
#"name": "name",
#"displayName": "displayName",
#"tier": "tier",
#"set": "set",
"sockets": "slots",
#"type": "type",
#"armorType": "armorType", (deleted)
"armorColor": "color", #(deleted)
"addedLore": "lore", #(deleted)
#"material": "material", (deleted)
"dropType": "drop",
#"quest": "quest",
"restrictions": "restrict",
"damage": "nDam",
"fireDamage": "fDam",
"waterDamage": "wDam",
"airDamage": "aDam",
"thunderDamage": "tDam",
"earthDamage": "eDam",
"attackSpeed": "atkSpd",
"health": "hp",
"fireDefense": "fDef",
"waterDefense": "wDef",
"airDefense": "aDef",
"thunderDefense": "tDef",
"earthDefense": "eDef",
"level": "lvl",
"classRequirement": "classReq",
"strength": "strReq",
"dexterity": "dexReq",
"intelligence": "intReq",
"agility": "agiReq",
"defense": "defReq",
"healthRegen": "hprPct",
"manaRegen": "mr",
"spellDamage": "sdPct",
"damageBonus": "mdPct",
"lifeSteal": "ls",
"manaSteal": "ms",
"xpBonus": "xpb",
"lootBonus": "lb",
"reflection": "ref",
"strengthPoints": "str",
"dexterityPoints": "dex",
"intelligencePoints": "int",
"agilityPoints": "agi",
"defensePoints": "def",
#"thorns": "thorns",
"exploding": "expd",
"speed": "spd",
"attackSpeedBonus": "atkTier",
#"poison": "poison",
"healthBonus": "hpBonus",
"soulPoints": "spRegen",
"emeraldStealing": "eSteal",
"healthRegenRaw": "hprRaw",
"spellDamageRaw": "sdRaw",
"damageBonusRaw": "mdRaw",
"bonusFireDamage": "fDamPct",
"bonusWaterDamage": "wDamPct",
"bonusAirDamage": "aDamPct",
"bonusThunderDamage": "tDamPct",
"bonusEarthDamage": "eDamPct",
"bonusFireDefense": "fDefPct",
"bonusWaterDefense": "wDefPct",
"bonusAirDefense": "aDefPct",
"bonusThunderDefense": "tDefPct",
"bonusEarthDefense": "eDefPct",
"accessoryType": "type",
"identified": "fixID",
#"skin": "skin",
#"category": "category",
"spellCostPct1": "spPct1",
"spellCostRaw1": "spRaw1",
"spellCostPct2": "spPct2",
"spellCostRaw2": "spRaw2",
"spellCostPct3": "spPct3",
"spellCostRaw3": "spRaw3",
"spellCostPct4": "spPct4",
"spellCostRaw4": "spRaw4",
"rainbowSpellDamageRaw": "rainbowRaw",
#"sprint": "sprint",
"sprintRegen": "sprintReg",
"jumpHeight": "jh",
"lootQuality": "lq",
"gatherXpBonus": "gXp",
"gatherSpeed": "gSpd",
}
delete_keys = [
#"addedLore",
#"skin",
#"armorType",
#"armorColor",
#"material"
]
with open("../clean.json", "r") as oldfile: with open("../clean.json", "r") as oldfile:
old_data = json.load(oldfile) old_data = json.load(oldfile)
old_items = old_data['items'] old_items = old_data['items']
@ -188,6 +87,8 @@ items.extend(remap_items)
#write items back into data #write items back into data
data["items"] = items data["items"] = items
data["sets"] = old_data["sets"]
#save id map #save id map
with open("id_map.json","w") as id_mapfile: with open("id_map.json","w") as id_mapfile:
json.dump(id_map, id_mapfile, indent=2) json.dump(id_map, id_mapfile, indent=2)