2021-01-06 06:10:27 +00:00
|
|
|
import json
|
|
|
|
|
|
|
|
with open("dump.json", "r") as infile:
|
|
|
|
data = json.loads(infile.read())
|
|
|
|
|
|
|
|
items = data["items"]
|
2021-01-06 12:48:41 +00:00
|
|
|
del data["request"]
|
2021-01-06 06:10:27 +00:00
|
|
|
|
2021-01-10 01:33:42 +00:00
|
|
|
import os
|
2021-01-10 01:54:54 +00:00
|
|
|
sets = dict()
|
|
|
|
item_set_map = dict()
|
2021-01-10 01:33:42 +00:00
|
|
|
for filename in os.listdir('sets'):
|
2021-01-10 01:54:54 +00:00
|
|
|
if "json" not in filename:
|
|
|
|
continue
|
2021-01-10 02:16:19 +00:00
|
|
|
set_name = filename[1:].split(".")[0].replace("+", " ").replace("%27", "'")
|
2021-01-10 01:54:54 +00:00
|
|
|
with open("sets/"+filename) as set_info:
|
|
|
|
set_obj = json.load(set_info)
|
|
|
|
for item in set_obj["items"]:
|
|
|
|
item_set_map[item] = set_name
|
|
|
|
sets[set_name] = set_obj
|
|
|
|
|
|
|
|
data["sets"] = sets
|
2021-01-10 01:33:42 +00:00
|
|
|
|
2021-01-06 06:10:27 +00:00
|
|
|
translate_mappings = {
|
2021-01-06 12:48:41 +00:00
|
|
|
#"name": "name",
|
|
|
|
#"displayName": "displayName",
|
|
|
|
#"tier": "tier",
|
|
|
|
#"set": "set",
|
2021-01-06 06:10:27 +00:00
|
|
|
"sockets": "slots",
|
2021-01-06 12:48:41 +00:00
|
|
|
#"type": "type",
|
2021-01-07 02:00:21 +00:00
|
|
|
#"armorType": "armorType", (deleted)
|
|
|
|
#"armorColor": "color", (deleted)
|
|
|
|
#"addedLore": "lore", (deleted)
|
|
|
|
#"material": "material", (deleted)
|
2021-01-06 12:48:41 +00:00
|
|
|
"dropType": "drop",
|
|
|
|
#"quest": "quest",
|
|
|
|
"restrictions": "restrict",
|
2021-01-06 06:10:27 +00:00
|
|
|
"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",
|
2021-01-06 12:48:41 +00:00
|
|
|
"spellDamage": "sdPct",
|
|
|
|
"damageBonus": "mdPct",
|
2021-01-06 06:10:27 +00:00
|
|
|
"lifeSteal": "ls",
|
|
|
|
"manaSteal": "ms",
|
|
|
|
"xpBonus": "xpb",
|
|
|
|
"lootBonus": "lb",
|
|
|
|
"reflection": "ref",
|
|
|
|
"strengthPoints": "str",
|
|
|
|
"dexterityPoints": "dex",
|
|
|
|
"intelligencePoints": "int",
|
|
|
|
"agilityPoints": "agi",
|
|
|
|
"defensePoints": "def",
|
|
|
|
#"thorns": "thorns",
|
2021-01-09 11:15:28 +00:00
|
|
|
"exploding": "expd",
|
2021-01-06 06:10:27 +00:00
|
|
|
"speed": "spd",
|
2021-01-06 12:48:41 +00:00
|
|
|
"attackSpeedBonus": "atkTier",
|
2021-01-06 06:10:27 +00:00
|
|
|
#"poison": "poison",
|
|
|
|
"healthBonus": "hpBonus",
|
|
|
|
"soulPoints": "spRegen",
|
2021-01-06 12:48:41 +00:00
|
|
|
"emeraldStealing": "eSteal",
|
2021-01-06 06:10:27 +00:00
|
|
|
"healthRegenRaw": "hprRaw",
|
2021-01-06 12:48:41 +00:00
|
|
|
"spellDamageRaw": "sdRaw",
|
|
|
|
"damageBonusRaw": "mdRaw",
|
2021-01-06 06:10:27 +00:00
|
|
|
"bonusFireDamage": "fDamPct",
|
|
|
|
"bonusWaterDamage": "wDamPct",
|
|
|
|
"bonusAirDamage": "aDamPct",
|
|
|
|
"bonusThunderDamage": "tDamPct",
|
|
|
|
"bonusEarthDamage": "eDamPct",
|
|
|
|
"bonusFireDefense": "fDefPct",
|
|
|
|
"bonusWaterDefense": "wDefPct",
|
|
|
|
"bonusAirDefense": "aDefPct",
|
|
|
|
"bonusThunderDefense": "tDefPct",
|
|
|
|
"bonusEarthDefense": "eDefPct",
|
2021-01-06 12:48:41 +00:00
|
|
|
"accessoryType": "type",
|
2021-01-06 06:10:27 +00:00
|
|
|
"identified": "fixID",
|
2021-01-06 12:48:41 +00:00
|
|
|
#"skin": "skin",
|
|
|
|
#"category": "category",
|
2021-01-06 06:10:27 +00:00
|
|
|
|
2021-01-06 12:48:41 +00:00
|
|
|
"spellCostPct1": "spPct1",
|
|
|
|
"spellCostRaw1": "spRaw1",
|
|
|
|
"spellCostPct2": "spPct2",
|
|
|
|
"spellCostRaw2": "spRaw2",
|
|
|
|
"spellCostPct3": "spPct3",
|
|
|
|
"spellCostRaw3": "spRaw3",
|
|
|
|
"spellCostPct4": "spPct4",
|
|
|
|
"spellCostRaw4": "spRaw4",
|
2021-01-06 06:10:27 +00:00
|
|
|
|
2021-01-06 12:48:41 +00:00
|
|
|
"rainbowSpellDamageRaw": "rainbowRaw",
|
2021-01-06 06:10:27 +00:00
|
|
|
"sprint": "sprint",
|
|
|
|
"sprintRegen": "sprintReg",
|
|
|
|
"jumpHeight": "jh",
|
|
|
|
"lootQuality": "lq",
|
2021-01-06 12:48:41 +00:00
|
|
|
|
|
|
|
"gatherXpBonus": "gXp",
|
|
|
|
"gatherSpeed": "gSpd",
|
2021-01-06 06:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete_keys = [
|
|
|
|
"addedLore",
|
|
|
|
"skin",
|
|
|
|
"armorType",
|
2021-01-07 02:00:21 +00:00
|
|
|
"armorColor",
|
|
|
|
"material"
|
2021-01-06 06:10:27 +00:00
|
|
|
]
|
|
|
|
|
2021-01-07 08:34:31 +00:00
|
|
|
import os
|
|
|
|
if os.path.exists("id_map.json"):
|
|
|
|
with open("id_map.json","r") as id_mapfile:
|
|
|
|
id_map = json.load(id_mapfile)
|
|
|
|
else:
|
|
|
|
id_map = {item["name"]: i for i, item in enumerate(items)}
|
|
|
|
|
|
|
|
|
2021-01-06 06:10:27 +00:00
|
|
|
for item in items:
|
|
|
|
for key in delete_keys:
|
|
|
|
if key in item:
|
|
|
|
del item[key]
|
|
|
|
|
|
|
|
for k, v in translate_mappings.items():
|
|
|
|
if k in item:
|
|
|
|
item[v] = item[k]
|
|
|
|
del item[k]
|
|
|
|
|
2021-01-07 08:34:31 +00:00
|
|
|
if not (item["name"] in id_map):
|
2021-01-08 03:02:07 +00:00
|
|
|
id_map[item["name"]] = len(id_map)
|
2021-01-07 08:34:31 +00:00
|
|
|
print(f'New item: {item["name"]}')
|
|
|
|
item["id"] = id_map[item["name"]]
|
|
|
|
|
2021-01-06 12:48:41 +00:00
|
|
|
item["type"] = item["type"].lower()
|
2021-01-10 01:54:54 +00:00
|
|
|
if item["name"] in item_set_map:
|
|
|
|
item["set"] = item_set_map[item["name"]]
|
2021-01-06 12:48:41 +00:00
|
|
|
|
2021-01-07 08:34:31 +00:00
|
|
|
with open("id_map.json","w") as id_mapfile:
|
|
|
|
json.dump(id_map, id_mapfile, indent=2)
|
2021-01-06 06:10:27 +00:00
|
|
|
with open("clean.json", "w") as outfile:
|
2021-01-07 08:34:31 +00:00
|
|
|
json.dump(data, outfile, indent=2)
|
2021-01-06 06:10:27 +00:00
|
|
|
with open("compress.json", "w") as outfile:
|
2021-01-07 08:34:31 +00:00
|
|
|
json.dump(data, outfile)
|