From 12bda093b222a3fc706723062d8845547787bd9a Mon Sep 17 00:00:00 2001 From: ferricles Date: Sun, 17 Jan 2021 17:26:39 -0800 Subject: [PATCH] dummy commit + setup for upcoming stuff --- builder.js | 3 +- display.js | 144 +++++++++++++++++++++++++++++++- index.html | 1 + load.js | 75 +++++++++++++++-- narrow.css | 3 + styles.css | 20 ++++- transform_combine.py | 193 ++++++++++++++++++++++++++++++++++++++++++- wide.css | 16 ++++ 8 files changed, 438 insertions(+), 17 deletions(-) diff --git a/builder.js b/builder.js index 721b071..f98889c 100644 --- a/builder.js +++ b/builder.js @@ -11,7 +11,6 @@ console.log(url_tag); * END testing section */ -const BUILD_VERSION = "6.9.2"; function setTitle() { document.getElementById("header").textContent = "WynnBuilder version "+BUILD_VERSION+" (db version "+DB_VERSION+")"; @@ -234,7 +233,7 @@ function init() { if (item !== undefined) { document.getElementById("weapon-slots").textContent = item.slots + " slots"; } - else { + else { document.getElementById("weapon-slots").textContent = "X slots"; } }); diff --git a/display.js b/display.js index 1b4ec39..f411080 100644 --- a/display.js +++ b/display.js @@ -59,10 +59,58 @@ function expandItem(item, powders){ expandedItem.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (expandedItem.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - powder["defMinus"]); } } - + //console.log(expandedItem); return expandedItem; } +/* Takes in an ingredient object and returns an equivalent Map(). +*/ +function expandIngredient(ing) { + let expandedIng = new Map(); + let mapIds = ['consumableIDs', 'itemIDs', 'posMods']; + for (const id of mapIds) { + let idMap = new Map(); + for (const key of Object.keys(ing[id])) { + idMap.set(key, ing[id][key]); + } + expandedIng.set(id, idMap); + } + let normIds = ['lvl','name','tier','skills']; + for (const id of normIds) { + expandedIng.set(id, ing[id]); + } + //now the actually hard one + let idMap = new Map(); + idMap.set("minRolls", new Map()); + idMap.set("maxRolls", new Map()); + for (const field of ingFields) { + let val = (ing['ids'][field] || 0); + idMap.get("minRolls").set(field, val); + idMap.get("maxRolls").set(field, val); + } + expandedIng.set("ids",idMap); + //console.log(expandedIng); + return expandedIng; +} + +/* Takes in a recipe object and returns an equivalent Map(). +*/ +function expandRecipe(recipe) { + let expandedRecipe = new Map(); + let normIDs = ["id", "skill", "type"]; + for (const id of normIDs) { + expandedRecipe.set(id,recipe[id]); + } + let rangeIDs = ["durability", "healthOrDamage", "lvl", "duration", "basicDuration"]; + for (const id of rangeIDs) { + if(recipe[id]){ + expandedRecipe.set(id, [recipe[id]['minimum'], recipe[id]['maximum']]); + } + } + expandedRecipe.set("materials", [ new Map([ ["item", recipe['materials'][0]['item']], ["amount", recipe['materials'][0]['amount']] ]) , new Map([ ["item", recipe['materials'][1]['item']], ["amount",recipe['materials'][0]['amount'] ] ]) ]); + //console.log(expandedRecipe); + return expandedRecipe; +} /*An independent helper function that rounds a rolled ID to the nearest integer OR brings the roll away from 0. * @param id @@ -272,6 +320,7 @@ function displayBuildStats(parent_id,build){ } } + function displayExpandedItem(item, parent_id){ // Commands to "script" the creation of nice formatting. // #commands create a new element. @@ -555,6 +604,98 @@ function displayExpandedItem(item, parent_id){ parent_div.append(item_desc_elem); } } +function displayCraftStats(craft, parent_id) { + +} + +function displayExpandedRecipe(recipe, parent_id) { + +} + + +function displayExpandedIngredient(ingred, parent_id) { + let elem = document.getElementById(parent_id); + let display_order = [ + "#cdiv", + "name", //tier will be displayed w/ name + "#table", + "ids", + "#ldiv", + "posMods", + "itemIDs", + "consumableIDs", + "#ldiv", + "lvl", + "skills", + ] + let id_display_commands = [ //all center div! + "eDefPct", + "tDefPct", + "wDefPct", + "fDefPct", + "aDefPct", + "eDamPct", + "tDamPct", + "wDamPct", + "fDamPct", + "aDamPct", + "str", + "dex", + "int", + "agi", + "def", + "hpBonus", + "mr", + "ms", + "ls", + "hprRaw", + "hprPct", + "sdRaw", + "sdPct", + "mdRaw", + "mdPct", + "xpb", + "lb", + "lq", + "ref", + "thorns", + "expd", + "spd", + "atkTier", + "poison", + "spRegen", + "eSteal", + "spRaw1", + "spRaw2", + "spRaw3", + "spRaw4", + "spPct1", + "spPct2", + "spPct3", + "spPct4", + "jh", + "sprint", + "sprintReg", + "gXp", + "gSpd", + ]; + if (command.charAt(0) === "#") { + if (command === "#cdiv") { + active_elem = document.createElement('div'); + active_elem.classList.add('itemcenter'); + } + else if (command === "#ldiv") { + active_elem = document.createElement('div'); + active_elem.classList.add('itemleft'); + } + else if (command === "#table") { + active_elem = document.createElement('table'); + active_elem.classList.add('itemtable'); + } + parent_div.appendChild(active_elem); + } + +} function displayNextCosts(parent_id, build) { let p_elem = document.getElementById(parent_id); @@ -630,6 +771,7 @@ function displayNextCosts(parent_id, build) { } } + function displayFixedID(active, id, value, elemental_format, style) { if (style) { /*if(reversedIDs.filter(e => e !== "atkTier").includes(id)){ diff --git a/index.html b/index.html index ca90b19..f334437 100644 --- a/index.html +++ b/index.html @@ -571,6 +571,7 @@ + diff --git a/load.js b/load.js index cae2e53..08d9cae 100644 --- a/load.js +++ b/load.js @@ -1,18 +1,24 @@ const DB_VERSION = 19; +const BUILD_VERSION = "6.9.2"; + // @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js let db; let reload = false; let items; let sets; +let ings; +let recipes; /* * Load item set from local DB. Calls init() on success. */ async function load_local(init_func) { - let get_tx = db.transaction(['item_db', 'set_db'], 'readonly'); + let get_tx = db.transaction(['item_db', 'set_db', 'ing_db', 'recipe_db'], 'readonly'); let sets_store = get_tx.objectStore('set_db'); let get_store = get_tx.objectStore('item_db'); + let ings_store = get_tx.objectStore('ing_db'); + let recipes_store = get_tx.objectStore('recipe_db'); let request = get_store.getAll(); request.onerror = function(event) { console.log("Could not read local item db..."); @@ -38,8 +44,25 @@ async function load_local(init_func) { console.log(sets); init_func(); } + } } + let request3 = ings_store.getAll(); + request3.onerror = function(event) { + console.log("Could not read local ingredient db..."); + } + request3.onsuccess = function(event) { + console.log("Successfully read local ingredient db."); + ings = request3.result; + } + let request4 = recipes_store.getAll(); + request4.onerror = function(event) { + console.log("Could not read local recipe db..."); + } + request4.onsuccess = function(event) { + console.log("Successfully read local recipe db."); + recipes = request4.result; + } await get_tx.complete; db.close(); } @@ -64,18 +87,32 @@ async function load(init_func) { let getUrl = window.location; let baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]; let url = baseUrl + "/compress.json"; + url = url.replace("/crafter.html", ""); //JANK let result = await (await fetch(url)).json(); items = result.items; sets = result.sets; + url = url.replace("/compress.json", "/ingreds_compress.json"); + result = await (await fetch(url)).json(); + ings = result.ingredients; + url = url.replace("/ingreds_compress.json", "/recipes_compress.json"); + result = await (await fetch(url)).json(); + recipes = result.recipes; // https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/clear let clear_tx = db.transaction(['item_db', 'set_db'], 'readwrite'); let clear_items = clear_tx.objectStore('item_db'); let clear_sets = clear_tx.objectStore('item_db'); - + let clear_tx2 = db.transaction(['ing_db'], 'readwrite'); + let clear_ings = clear_tx2.objectStore('ing_db'); + let clear_tx3 = db.transaction(['recipe_db'], 'readwrite'); + let clear_recipes = clear_tx3.objectStore('recipe_db'); await clear_items.clear(); await clear_sets.clear(); + await clear_ings.clear(); + await clear_recipes.clear(); await clear_tx.complete; + await clear_tx2.complete; + await clear_tx3.complete; let add_tx = db.transaction(['item_db', 'set_db'], 'readwrite'); let items_store = add_tx.objectStore('item_db'); @@ -88,7 +125,20 @@ async function load(init_func) { for (const set in sets) { add_promises.push(sets_store.add(sets[set], set)); } + + let add_tx2 = db.transaction(['ing_db'], 'readwrite'); + let ings_store = add_tx2.objectStore('ing_db'); + for (const ing in ings) { + add_promises.push(ings_store.add(ings[ing], ing)); + } + let add_tx3 = db.transaction(['recipe_db'], 'readwrite'); + let recipes_store = add_tx3.objectStore('recipe_db'); + for (const recipe in recipes) { + add_promises.push(recipes_store.add(recipes[recipe], recipe)); + } add_promises.push(add_tx.complete); + add_promises.push(add_tx2.complete); + add_promises.push(add_tx3.complete); Promise.all(add_promises).then((values) => { db.close(); init_func(); @@ -96,11 +146,11 @@ async function load(init_func) { } function load_init(init_func) { - let request = window.indexedDB.open('item_db', DB_VERSION); - + + let request = window.indexedDB.open("ing_db", DB_VERSION) request.onerror = function() { console.log("DB failed to open..."); - }; + } request.onsuccess = function() { db = request.result; @@ -131,9 +181,22 @@ function load_init(init_func) { catch (error) { console.log("Could not delete set DB. This is probably fine"); } - + try { + db.deleteObjectStore('ing_db'); + } + catch (error) { + console.log("Could not delete ingredient DB. This is probably fine"); + } + try { + db.deleteObjectStore('recipe_db'); + } + catch (error) { + console.log("Could not delete recipe DB. This is probably fine"); + } db.createObjectStore('item_db'); db.createObjectStore('set_db'); + db.createObjectStore('ing_db'); + db.createObjectStore('recipe_db'); console.log("DB setup complete..."); } diff --git a/narrow.css b/narrow.css index c1bac21..2288727 100644 --- a/narrow.css +++ b/narrow.css @@ -13,6 +13,9 @@ gap: 5px; grid-auto-rows: minmax(60px, auto); } +.container { + +} .build, .spells .misc { padding: 2%; diff --git a/styles.css b/styles.css index 0ae4224..339041a 100644 --- a/styles.css +++ b/styles.css @@ -44,7 +44,7 @@ div { grid-auto-rows: minmax(60px, auto); } -.equipment, .skillpoints, .center, .header, .all, .nocolor{ +.equipment, .skillpoints, .center, .header, .all, .nocolor, .crafted, .crafter{ background: #121516; color: #aaa; } @@ -68,7 +68,12 @@ a.link{ .center { text-align: center; } - +table.center{ + margin: 10px; + margin-left:auto; + margin-right:auto; + gap: 10px; +} .right { text-align: right; } @@ -78,7 +83,7 @@ a.link{ text-align: left; } -.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order, .build-overall, .build-melee-stats, .build-defense-stats, .spell-info, .set-info, .powder-special, .powder-special-stats, .int-info { +.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order, .build-overall, .build-melee-stats, .build-defense-stats, .spell-info, .set-info, .powder-special, .powder-special-stats, .int-info, .crafter, .recipe-stats, .craft-stats, .ing-stats { color: #aaa; background: #121516; border: 3px solid #BCBCBC; @@ -162,7 +167,7 @@ a.link{ .Damage { color: rgb(255, 198, 85)} .Mana { color: #5ff;} -.Mana:after { content: "\2749"} +.Mana:after { content: "\273A"} .Health { color: #a00; @@ -286,3 +291,10 @@ button.toggleOn{ text-align: center; transform: translateX(calc(50vw - 50%)); } + +.Star { + color:rgb(255, 198, 85) +} +.Star:after { + content: "\272B"; +} \ No newline at end of file diff --git a/transform_combine.py b/transform_combine.py index af8f6e1..9554a2d 100644 --- a/transform_combine.py +++ b/transform_combine.py @@ -16,6 +16,14 @@ with open("dump.json", "r") as infile: items = data["items"] del data["request"] +with open("recipes_compress.json", "r") as infile: + recipe_data = json.loads(infile.read()) +recipes = recipe_data["recipes"] +#this data does not have request :) +with open("ingreds_compress.json", "r") as infile: + ing_data = json.loads(infile.read()) +ings = ing_data["ingredients"] +#this data does not have request :) import os sets = dict() item_set_map = dict() @@ -31,7 +39,7 @@ for filename in os.listdir('sets'): data["sets"] = sets -translate_mappings = { +translate_mappings = { #this is used for items. #"name": "name", #"displayName": "displayName", #"tier": "tier", @@ -132,13 +140,142 @@ delete_keys = [ "material" ] +ing_translate_mappings = { + #"name" : "name", + #"tier" :"tier", + "level" : "lvl", + #"skills" : "skills", + "identifications" : "ids", + "itemOnlyIDs" : "itemIDs", + "consumableOnlyIDs" : "consumableIDs", + "ingredientPositionModifiers" : "posMods", +} +ing_metaID_mappings = { +#item only IDs + "durabilityModifier": "dura", + "strengthRequirement": "strReq", + "dexterityRequirement": "dexReq", + "intelligenceRequirement": "intReq", + "defenceRequirement": "defReq", + "agilityRequirement": "agiReq", + "attackSpeedModifier": "atkTier", + "powderSlotModifier": "slotMod", +#consumable only IDs + "duration": "dura", + #"charges": "charges", +#position modifiers + #"left": "left", + #"right": "right", + #"above": "above", + #"under": "under", + #"touching": "touching", + #"notTouching": "notTouching", +} +ing_id_mappings = { #specifically for the id field of an ingredient. + #"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": "fDefPct", + "WATERDEFENSE": "wDefPct", + "AIRDEFENSE": "aDefPct", + "THUNDERDEFENSE": "tDefPct", + "EARTHDEFENSE": "eDefPct", + #"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", + "LOOT_QUALITY": "lq", + "REFLECTION": "ref", + "STRENGTHPOINTS": "str", + "DEXTERITYPOINTS": "dex", + "INTELLIGENCEPOINTS": "int", + "AGILITYPOINTS": "agi", + "DEFENSEPOINTS": "def", + "THORNS": "thorns", + "EXPLODING": "expd", + "SPEED": "spd", + "ATTACKSPEED": "atkTier", + "POISON": "poison", + "HEALTHBONUS": "hpBonus", + "SOULPOINTS": "spRegen", + "EMERALDSTEALING": "eSteal", + "HEALTHREGENRAW": "hprRaw", + "SPELLDAMAGERAW": "sdRaw", + "DAMAGEBONUSRAW": "mdRaw", + "FIREDAMAGEBONUS": "fDamPct", + "WATERDAMAGEBONUS": "wDamPct", + "AIRDAMAGEBONUS": "aDamPct", + "THUNDERDAMAGEBONUS": "tDamPct", + "EARTHDAMAGEBONUS": "eDamPct", + #"accessoryType": "type", + #"identified": "fixID", + #"skin": "skin", + #"category": "category", + #THESE ARE NOT IN ANY INGREDIENT YET. THEY MAY NOT HAVE THE CORRECT ID NAME + "SPELLCOSTPCT1": "spPct1", + "SPELLCOSTRAW1": "spRaw1", + "SPELLCOSTPCT2": "spPct2", + "SPELLCOSTRAW2": "spRaw2", + "SPELLCOSTPCT3": "spPct3", + "SPELLCOSTRAW3": "spRaw3", + "SPELLCOSTPCT4": "spPct4", + "SPELLCOSTRAW4": "spRaw4", + "JUMPHEIGHT": "jh", + #"rainbowSpellDamageRaw": "rainbowRaw", + "SPRINT": "sprint", + "SPRINGREGEN": "sprintReg", + "GATHERXPBONUS": "gXp", + "GATHERSPEED": "gSpd", + #"lootQuality": "lq", +} +ing_delete_keys = [ + "sprite", + +] + +recipe_translate_mappings = { + "level" : "lvl", +} +recipe_delete_keys = [ #lol + +] + 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)} - +# wtf is this hpp texture_names = [] @@ -162,13 +299,61 @@ for item in items: if item["name"] in item_set_map: item["set"] = item_set_map[item["name"]] +print(ings[0]) +for ing in ings: + for key in ing_delete_keys: + if key in ing: + del ing[key] + + for k, v in ing_translate_mappings.items(): + if k in ing: + ing[v] = ing[k] + del ing[k] + + for k, v in ing_metaID_mappings.items(): + if k in ing['itemIDs']: + print(ing['itemIDs']) + ing['itemIDs'][v] = ing['itemIDs'][k] + del ing['itemIDs'][k] + elif k in ing['consumableIDs']: + ing['consumableIDs'][v] = ing['consumableIDs'][k] + del ing['consumableIDs'][k] + '''elif k in ing.posMods: #Not subbing, if we do sub uncomment this. + ing.posMods[v] = ing.posMods[k] + del ing.posMods[k] ''' + + for k, v in ing_id_mappings.items(): + if k in ing['ids']: #yes this is dumb + ing['ids'][v] = ing['ids'][k] + del ing['ids'][k] + + +for recipe in recipes: + for key in recipe_delete_keys: + if key in recipe: + del recipe[key] + + for k, v in recipe_translate_mappings.items(): + if k in recipe: + recipe[v] = recipe[k] + del recipe[k] + + with open("1_20_ci.json", "r") as ci_file: ci_items = json.load(ci_file) items.extend(ci_items) -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) with open("clean.json", "w") as outfile: json.dump(data, outfile, indent=2) with open("compress.json", "w") as outfile: - json.dump(data, outfile) + json.dump(data, outfile)''' +with open("ingreds_clean.json", "w") as outfile: + json.dump(ing_data, outfile, indent = 2) +with open("ingreds_compress2.json", "w") as outfile: + json.dump(ing_data, outfile) +with open("recipes_clean.json", "w") as outfile: + json.dump(recipe_data, outfile, indent = 2) +with open("recipes_compress2.json", "w") as outfile: + json.dump(recipe_data, outfile) \ No newline at end of file diff --git a/wide.css b/wide.css index 39fb232..64508b7 100644 --- a/wide.css +++ b/wide.css @@ -12,6 +12,22 @@ gap: 5px; grid-auto-rows: minmax(60px, auto); } +.container { + padding: 2% 4% 4%; + display: grid; + grid-template-columns: 1fr 0.7fr 0.7fr; + grid-auto-columns: minmax(200px, auto); + gap: 5px; + grid-auto-rows: minmax(60px, auto); +} +.ingredients { + padding: 2% 4% 4%; + display: grid; + grid-template-columns: repeat(2, 1fr); + grid-auto-columns: minmax(200px, auto); + gap: 5px; + grid-auto-rows: minmax(60px, auto); +} .build, .spells, .misc { padding: 2%;