Add new items, move python scripts, allow leading and trailing whitespace in input fields

This commit is contained in:
b 2021-05-01 07:19:33 -07:00
parent 64206d661d
commit e9ae79a047
31 changed files with 114935 additions and 274568 deletions

View file

@ -3,9 +3,7 @@ const url_tag = location.hash.slice(1);
// console.log(url_tag); // console.log(url_tag);
const BUILD_VERSION = "7.0.3"; const BUILD_VERSION = "7.0.4";
function setTitle() { function setTitle() {
let text; let text;
@ -423,16 +421,17 @@ function calculateBuild(save_skp, skp){
*/ */
let equipment = [ null, null, null, null, null, null, null, null, null ]; let equipment = [ null, null, null, null, null, null, null, null, null ];
for (let i in equipment) { for (let i in equipment) {
let equip = getValue(equipmentInputs[i]); let equip = getValue(equipmentInputs[i]).trim();
if (equip === "") { equip = "No " + equipment_names[i] } if (equip === "") { equip = "No " + equipment_names[i] }
equipment[i] = equip; equipment[i] = equip;
setValue(equipmentInputs[i], equip);
} }
let powderings = []; let powderings = [];
let errors = []; let errors = [];
for (const i in powderInputs) { for (const i in powderInputs) {
// read in two characters at a time. // read in two characters at a time.
// TODO: make this more robust. // TODO: make this more robust.
let input = getValue(powderInputs[i]); let input = getValue(powderInputs[i]).trim();
let powdering = []; let powdering = [];
let errorederrors = []; let errorederrors = [];
while (input) { while (input) {

109800
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

@ -1,5 +0,0 @@
import sys
import json
infile = sys.argv[1]
outfile = sys.argv[2]
json.dump(json.load(open(infile)), open(outfile, "w"))

View file

@ -628,7 +628,9 @@ function saveAsJSON() {
let CI = {}; let CI = {};
for (const [id, val] of player_custom_item.statMap) { for (const [id, val] of player_custom_item.statMap) {
console.log(id); console.log(id);
let skipIds = ["minRolls", "maxRolls", "skillpoints", "reqs", "custom", "crafted", "restrict", "hash", "nDam_", "tDam_", "eDam_", "wDam_", "fDam_", "aDam_"] let skipIds = ["minRolls", "maxRolls", "skillpoints", "reqs", "custom", "crafted", "restrict", "hash",
"nDam_", "tDam_", "eDam_", "wDam_", "fDam_", "aDam_",
"powders", "durability", "duration" ]
if (skipIds.includes(id)) { if (skipIds.includes(id)) {
continue; continue;
} else { } else {

View file

@ -139,7 +139,7 @@ let items_expanded;
function doItemSearch() { function doItemSearch() {
window.scrollTo(0, 0); window.scrollTo(0, 0);
let queries = []; let queries = [];
queries.push(new NameQuery(document.getElementById("name-choice").value)); queries.push(new NameQuery(document.getElementById("name-choice").value.trim()));
let categoryOrType = document.getElementById("category-choice").value; let categoryOrType = document.getElementById("category-choice").value;
if (itemTypes.includes(categoryOrType)) { if (itemTypes.includes(categoryOrType)) {

View file

@ -1,4 +1,4 @@
const DB_VERSION = 38; const DB_VERSION = 39;
// @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;

View file

@ -0,0 +1,8 @@
import sys
import json
infile = sys.argv[1]
outfile = sys.argv[2]
if len(sys.argv) > 3 and sys.argv[3] == "decompress":
json.dump(json.load(open(infile)), open(outfile, "w"), indent=4)
else:
json.dump(json.load(open(infile)), open(outfile, "w"))

14
py_script/grab_sets.sh Normal file
View file

@ -0,0 +1,14 @@
#!/bin/bash
#while read line; do
# curl "https://www.wynndata.tk/sets/${line}" > "sets/${line}"
#done < sets_list.txt
#
#ls sets/ | while read line; do
# grep "Set Items:" "sets/${line}" > "sets/_${line}"
#done
rm sets/*.json
ls sets/ | grep "_" | while read line; do
python3 parse_set_individual.py "sets/${line}"
done

36
py_script/image_get.py Normal file
View file

@ -0,0 +1,36 @@
import os
import json
weapon_types = ["wand", "bow", "spear", "dagger", "relik"]
element_types = ["generic", "fire", "water", "air", "thunder", "earth"] # default1 default2
armor_types = ["helmet", "chestplate", "leggings", "boots"]
armor_tiers = ["leather", "golden", "chain", "iron", "diamond"]
_base_url = "https://www.wynndata.tk/assets/images/items/v4/"
root_loc = "textures/items/"
def grab_texture(base_url, file_name, target_loc):
os.system("curl "+base_url+file_name+" > "+target_loc+"/"+file_name)
#os.system("mv "+target_loc+file_name+" "+target_loc+"/"+file_name)
for wep in weapon_types:
base_url = _base_url+"/"+wep+"/"
target_loc = root_loc+wep
os.system("mkdir "+target_loc)
for elem in element_types:
for i in range(1,4):
file_name = wep+"--"+elem+str(i)+".png"
grab_texture(base_url, file_name, target_loc)
for i in ["default1", "default2"]:
file_name = wep+"--"+i+".png"
grab_texture(base_url, file_name, target_loc)
for armor in armor_types:
base_url = _base_url+armor+"/"
target_loc = root_loc+armor
os.system("mkdir "+target_loc)
for tier in armor_tiers:
file_name = armor+"--"+tier+".png"
grab_texture(base_url, file_name, target_loc)

51
py_script/json_diff.py Normal file
View file

@ -0,0 +1,51 @@
import sys
import json
f1 = sys.argv[1]
f2 = sys.argv[2]
json1 = json.load(open(f1))
json2 = json.load(open(f2))
def shorten(v):
if len(v) > 100:
return v[:100] + "..."
return v
def is_basic(t):
return t is int or t is str or t is float or t is bool or t is list
def object_diff(obj1, obj2, path):
for (k, v) in obj1.items():
if k in obj2:
obj = obj2[k]
type1 = type(v)
type2 = type(obj)
if type1 != type2:
print(f"{path}.{k}: Type difference [{str(type1)} != {str(type2)}]")
elif type1 is list and type2 is list and not is_basic(type(v[0])):
print(f"Encountered object list {path}.{k}, enter match key: ", end="", file=sys.stderr)
key = input()
if (key == ""):
if v != obj:
print(f"{path}.{k}: Value difference")
print(f" Left: {shorten(str(v))}")
print(f" Right: {shorten(str(obj))}")
else:
left = {x[key]: x for x in obj1[k]}
right = {x[key]: x for x in obj2[k]}
object_diff(left, right, path+"."+k)
elif (type1 is list and is_basic(type(v[0]))) or is_basic(type1) or v is None or obj2 is None:
if v != obj:
print(f"{path}.{k}: Value difference")
print(f" Left: {shorten(str(v))}")
print(f" Right: {shorten(str(obj))}")
else:
object_diff(v, obj, path+"."+k)
else:
print(f"{path}.{k}: Contained in left but not right")
print(f" Value: {shorten(str(v))}")
for (k, v) in obj2.items():
if k not in obj1:
print(f"{path}.{k}: Contained in right but not left")
print(f" Value: {shorten(str(v))}")
object_diff(json1, json2, "$")

17
py_script/json_to_yaml.py Normal file
View file

@ -0,0 +1,17 @@
"""
README:
Python 3 required.
pyyaml required (pip3 install pyyaml, or pip install pyyaml)
USAGE:
python3 json_to_yaml.py <infile> <outfile>
"""
import sys
import json
import yaml
yaml.dump(json.load(open(sys.argv[1])), open(sys.argv[2], "w"), default_flow_style=False)

View file

@ -0,0 +1,95 @@
import sys
set_infile = sys.argv[1]
print("-------------------------------")
print(set_infile)
print("-------------------------------")
id_reverse_map = {
"% Health Regen": "hprPct",
"/4s Mana Regen": "mr",
"% Spell Damage": "sdPct",
"% Main Attack Damage": "mdPct",
"/4s Life Steal": "ls",
"/4s Mana Steal": "ms",
"% XP Bonus": "xpb",
"% Loot Bonus": "lb",
"% Reflection": "ref",
"Strength": "str",
"Dexterity": "dex",
"Intelligence": "int",
"Agility": "agi",
"Defense": "def",
"% Thorns": "thorns",
"% Exploding": "expd",
"% Walk Speed": "spd",
"tier Attack Speed": "atkTier",
"/3s Poison": "poison",
"Health": "hpBonus",
"% Soul Point Regen": "spRegen",
"% Stealing": "eSteal",
"Health Regen": "hprRaw",
"Spell Damage": "sdRaw",
"Main Attack Damage": "mdRaw",
"% Fire Damage": "fDamPct",
"% Water Damage": "wDamPct",
"% Air Damage": "aDamPct",
"% Thunder Damage": "tDamPct",
"% Earth Damage": "eDamPct",
"% Fire Defense": "fDefPct",
"% Water Defense": "wDefPct",
"% Air Defense": "aDefPct",
"% Thunder Defense": "tDefPct",
"% Earth Defense": "eDefPct",
"% 1st Spell Cost": "spPct1",
"1st Spell Cost": "spRaw1",
"% 2nd Spell Cost": "spPct2",
"2nd Spell Cost": "spRaw2",
"% 3rd Spell Cost": "spPct3",
"3rd Spell Cost": "spRaw3",
"% 4th Spell Cost": "spPct4",
"4th Spell Cost": "spRaw4",
"rainbowSpellDamageRaw": "rainbowRaw",
"% Sprint": "sprint",
"% Sprint Regen": "sprintReg",
"Jump Height": "jh",
"lootQuality": "lq",
"gatherXpBonus": "gXp",
"gatherSpeed": "gSpd",
}
with open(set_infile, "r") as setFile:
set_data = setFile.read()
set_items, set_bonus = set_data.split("Set Bonuses:")
items = [x.split("<",1)[0].strip() for x in set_items.split("name Set'>")[1:]]
print(items)
set_increment = set_bonus.split("div class='set-box'>")[1:]
set_bonuses = []
import re
number_regex = re.compile(r"([+-]\d+)(.*)")
for set_bonus in set_increment:
print(len(set_bonuses)+1, "items:")
bonuses = dict()
if "Set Bonus" in set_bonus:
bonus_string = set_bonus.split("Set Bonus:</i></p>")[1]
for bonus in bonus_string.split("</p><p>")[:-1]:
val_bunch, label = bonus.split("</span> ")
if "i class" in label:
_, two, three = label.split(">")
label = two.split("<")[0][2:] + three
value = val_bunch.split(">")[-1]
print(value, label);
value_combine = value+" "+label
result = re.match(number_regex, value_combine)
number = result.group(1)
key = result.group(2).strip()
bonuses[id_reverse_map[key]] = int(number)
set_bonuses.append(bonuses)
import json
with open(set_infile+".json", "w") as outFile:
json.dump({"items": items, "bonuses": set_bonuses}, outFile, indent=2)

4
py_script/parse_sets.py Normal file
View file

@ -0,0 +1,4 @@
with open("sets.txt", "r") as setsFile:
sets_split = (x.split("'", 2)[1][2:] for x in setsFile.read().split("a href=")[1:])
with open("sets_list.txt", "w") as outFile:
outFile.write("\n".join(sets_split))

8
py_script/tmp.py Normal file
View file

@ -0,0 +1,8 @@
#for i in range(0, 360, 5):
# print(f"tp @s ~ ~ ~ {i} 0\n"+
#"""execute at @s run summon armor_stand ^ ^ ^0.8 {Tags:["aura_vector"],Invisible:1b}
#execute as @e[tag=aura_vector,limit=1,sort=nearest] at @s run tp @s ~ ~ ~ facing entity @e[tag=aura_execute,limit=1,sort=nearest]""")
for i in range(2, 21):
print("execute as @s[scores={"+f"auraTimer={i}"+"}] run execute as @e[tag=aura_vector] at @s run tp @s ^ ^ ^"+f"-{'{0:3.1f}'.format(0.8*(i-1))}")

View file

@ -159,13 +159,25 @@ max_id = 0
known_item_names = set() known_item_names = set()
for item in items:
known_item_names.add(item["name"])
old_items_map = dict()
remap_items = []
for item in old_items:
if "remapID" in item:
remap_items.append(item)
elif item["name"] not in known_item_names:
print(f'Unknown old item: {item["name"]}!!!')
old_items_map[item["name"]] = item
for item in items: for item in items:
for key in delete_keys: for key in delete_keys:
if key in item: if key in item:
del item[key] del item[key]
for k in list(item.keys()): for k in list(item.keys()):
if item[k] == 0 and not k in must_mappings: if (item[k] == 0 or item[k] is None) and not k in must_mappings:
del item[k] del item[k]
for k, v in translate_mappings.items(): for k, v in translate_mappings.items():
@ -181,17 +193,19 @@ for item in items:
print(f'New item: {item["name"]} (id: {max_id})') print(f'New item: {item["name"]} (id: {max_id})')
item["id"] = id_map[item["name"]] item["id"] = id_map[item["name"]]
known_item_names.add(item["name"])
item["type"] = item["type"].lower() item["type"] = item["type"].lower()
if item["name"] in item_set_map: if "displayName" in item:
item["set"] = item_set_map[item["name"]] item_name = item["displayName"]
else:
item_name = item["name"]
if item_name in item_set_map:
item["set"] = item_set_map[item_name]
if item["name"] in old_items_map:
old_item = old_items_map[item["name"]]
if "hideSet" in old_item:
item["hideSet"] = old_item["hideSet"]
for item in old_items: items.extend(remap_items)
if "remapID" in item:
items.append(item)
elif item["name"] not in known_item_names:
print(f'Unknown old item: {item["name"]}!!!')
with open("clean.json", "w") as outfile: with open("clean.json", "w") as outfile:
json.dump(data, outfile, indent=2) json.dump(data, outfile, indent=2)

17
py_script/yaml_to_json.py Normal file
View file

@ -0,0 +1,17 @@
"""
README:
Python 3 required.
pyyaml required (pip3 install pyyaml, or pip install pyyaml)
USAGE:
python3 yaml_to_json.py <infile> <outfile>
"""
import sys
import json
import yaml
json.dump(yaml.load(open(sys.argv[1])), open(sys.argv[2], "w"), indent=2)

View file

@ -1,6 +1,7 @@
Version 0: http://localhost:8000/#0_0K30oY09X2SJ2SK2SL2SM2SN0QQ Version 0: http://localhost:8000/#0_0K30oY09X2SJ2SK2SL2SM2SN0QQ
Version 1: http://localhost:8000/#1_0690px0CE0QR0050050K40BR0Qk00001004fI Version 1: http://localhost:8000/#1_0690px0CE0QR0050050K40BR0Qk00001004fI
Version 2: http://localhost:8000/#2_2SG2SH2SI2SJ2SK0K22SM2SN05n000t210t0000000 Version 2: http://localhost:8000/#2_2SG2SH2SI2SJ2SK0K22SM2SN05n000t210t0000000
Version 3: https://localhost:8000/#3_0250px0uX0K50K20OK0OJ00A0Qe1z+m21001M1g0000100nZ6 Version 3: http://localhost:8000/#3_0250px0uX0K50K20OK0OJ00A0Qe1z+m21001M1g0000100nZ6
Version 3: https://localhost:8000/#3_0K60iv0CE0Qt0BK0BK0K40Jc0uG160V050o1L1g00001003C6 Version 3: http://localhost:8000/#3_0K60iv0CE0Qt0BK0BK0K40Jc0uG160V050o1L1g00001003C6
Version 4: https://localhost:8000/#4_-1+W+W+W+W+W+W9g91-1+W+W+W+W+W+W9d91-1+W+W+W+W+W+W9i9--1+W+W+W+W+W+W9a91-1+W+W+W+W+W+W9m91-1+W+W+W+W+W+W9m91-1+W+W+W+W+W+W9c91-1+W+W+W+W+W+W9n91-1+W+W+W+W+W+W9q9100000000001g000010036C Version 4: http://localhost:8000/#4_-1+W+W+W+W+W+W9g91-1+W+W+W+W+W+W9d91-1+W+W+W+W+W+W9i9--1+W+W+W+W+W+W9a91-1+W+W+W+W+W+W9m91-1+W+W+W+W+W+W9m91-1+W+W+W+W+W+W9c91-1+W+W+W+W+W+W9n91-1+W+W+W+W+W+W9q9100000000001g000010036C
Version 5 (CI): http://localhost:8000/index.html#5_0lS0JX0u50tv00nCI-10000MFlipped%20Lapis%20Ring0200540M01010V010m0K20OL0og00-CI-110230401030570A07287-3530F40M0201d0c07287-3530w023zu100202e-Y0i211q-Y1g00000

279388
updated.json

File diff suppressed because it is too large Load diff