created separate files for merging sets and tomes into item DB
This commit is contained in:
parent
48554a5e36
commit
1880854064
4 changed files with 61 additions and 14 deletions
|
@ -221,8 +221,11 @@ function init_maps() {
|
||||||
["accessory", "bracelet", "No Bracelet"],
|
["accessory", "bracelet", "No Bracelet"],
|
||||||
["accessory", "necklace", "No Necklace"],
|
["accessory", "necklace", "No Necklace"],
|
||||||
["weapon", "dagger", "No Weapon"],
|
["weapon", "dagger", "No Weapon"],
|
||||||
|
["tome", "weaponTome", "No Weapon Tome"],
|
||||||
|
["tome", "armorTome", "No Armour Tome"],
|
||||||
|
["tome", "guildTome", "No Guild Tome"]
|
||||||
];
|
];
|
||||||
for (let i = 0; i < 9; i++) {
|
for (let i = 0; i < 12; i++) {
|
||||||
let item = Object();
|
let item = Object();
|
||||||
item.slots = 0;
|
item.slots = 0;
|
||||||
item.category = noneItems[i][0];
|
item.category = noneItems[i][0];
|
||||||
|
|
|
@ -9,6 +9,7 @@ AMBIVALENCE IS REMOVED!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
with open("dump.json", "r") as infile:
|
with open("dump.json", "r") as infile:
|
||||||
data = json.load(infile)
|
data = json.load(infile)
|
||||||
|
@ -18,23 +19,14 @@ with open("updated.json", "r") as oldfile:
|
||||||
|
|
||||||
items = data["items"]
|
items = data["items"]
|
||||||
old_items = old_data["items"]
|
old_items = old_data["items"]
|
||||||
|
old_tomes = old_data["tomes"]
|
||||||
if "request" in data:
|
if "request" in data:
|
||||||
del data["request"]
|
del data["request"]
|
||||||
|
|
||||||
# import os
|
#this script does not change sets or tomes. use the dedicated set and tome update scripts to update.
|
||||||
# sets = dict()
|
|
||||||
# for filename in os.listdir('sets'):
|
|
||||||
# if "json" not in filename:
|
|
||||||
# continue
|
|
||||||
# set_name = filename[1:].split(".")[0].replace("+", " ").replace("%27", "'")
|
|
||||||
# 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
|
|
||||||
data["sets"] = old_data["sets"]
|
data["sets"] = old_data["sets"]
|
||||||
|
data["tomes"] = old_data["tomes"]
|
||||||
|
|
||||||
item_set_map = dict()
|
item_set_map = dict()
|
||||||
for set_name, set_data in data["sets"].items():
|
for set_name, set_data in data["sets"].items():
|
||||||
for item_name in set_data["items"]:
|
for item_name in set_data["items"]:
|
||||||
|
|
25
py_script/update_sets_in_items.py
Normal file
25
py_script/update_sets_in_items.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
'''takes the data in updated.json and the jsons in the sets folder to update the sets in the db.'''
|
||||||
|
|
||||||
|
with open("updated.json", "r") as oldfile:
|
||||||
|
data = json.load(oldfile)
|
||||||
|
|
||||||
|
#This probably does not work. I have not checked :)
|
||||||
|
sets = dict()
|
||||||
|
for filename in os.listdir('sets'):
|
||||||
|
if "json" not in filename:
|
||||||
|
continue
|
||||||
|
set_name = filename[1:].split(".")[0].replace("+", " ").replace("%27", "'")
|
||||||
|
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
|
||||||
|
|
||||||
|
with open("clean.json", "w") as outfile:
|
||||||
|
json.dump(data, outfile, indent=2)
|
||||||
|
with open("compress.json", "w") as outfile:
|
||||||
|
json.dump(data, outfile)
|
27
py_script/update_tomes_in_items.py
Normal file
27
py_script/update_tomes_in_items.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
'''takes the data in updated.json and tomes.json to update the tomes in the db.'''
|
||||||
|
|
||||||
|
with open("updated.json", "r") as oldfile:
|
||||||
|
data = json.load(oldfile)
|
||||||
|
with open("tomes.json", "r") as tomesfile:
|
||||||
|
tome_data = json.load(tomesfile)
|
||||||
|
|
||||||
|
#This probably does not work. I have not checked :)
|
||||||
|
tomes = dict()
|
||||||
|
for filename in os.listdir('sets'):
|
||||||
|
if "json" not in filename:
|
||||||
|
continue
|
||||||
|
set_name = filename[1:].split(".")[0].replace("+", " ").replace("%27", "'")
|
||||||
|
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
|
||||||
|
|
||||||
|
with open("clean.json", "w") as outfile:
|
||||||
|
json.dump(data, outfile, indent=2)
|
||||||
|
with open("compress.json", "w") as outfile:
|
||||||
|
json.dump(data, outfile)
|
Loading…
Reference in a new issue