From a78ecb800efc05258c7c1334d403eafc60afa1fb Mon Sep 17 00:00:00 2001 From: b Date: Sat, 23 Jan 2021 21:58:53 -0600 Subject: [PATCH 1/2] Update item searcher stuff --- crafter.html | 22 ++++++++++--------- crafter.js | 4 ++-- index.html | 17 ++++++++++----- items-narrow.css | 7 ++++++ items-wide.css | 8 +++++++ items.html | 47 ++++++++++++++++++++++++++++++---------- items.js | 29 ++++++++++++++++++++----- load.js | 2 +- media/icons/atlas64.png | Bin 0 -> 358 bytes query.js | 34 +++++++++++++++++++++++++---- updated.json | 2 +- 11 files changed, 131 insertions(+), 41 deletions(-) create mode 100644 items-narrow.css create mode 100644 items-wide.css create mode 100755 media/icons/atlas64.png diff --git a/crafter.html b/crafter.html index 12fbe32..95d11ce 100644 --- a/crafter.html +++ b/crafter.html @@ -17,22 +17,24 @@
- +
WynnBuilder
-
+ - - -
WynnCrafter
-
+ + +
WynnCrafter
+ + + + +
WynnAtlas
+
- -

- Forum thread (instructions/help) -

+
diff --git a/crafter.js b/crafter.js index cd428ce..57d8981 100644 --- a/crafter.js +++ b/crafter.js @@ -27,7 +27,7 @@ let ingFields = ["fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "hprPct" let player_craft; function setTitle() { - document.getElementById("header").textContent = "WynnBuilder version "+BUILD_VERSION+" (ingredient db version "+ING_DB_VERSION+")"; + document.getElementById("header").textContent = "WynnCrafter version "+BUILD_VERSION+" (ingredient db version "+ING_DB_VERSION+")"; document.getElementById("header").classList.add("funnynumber"); } setTitle(); @@ -261,4 +261,4 @@ function resetFields() { calculateCraft(); } -load_ing_init(init); \ No newline at end of file +load_ing_init(init); diff --git a/index.html b/index.html index db3a283..279c331 100644 --- a/index.html +++ b/index.html @@ -20,15 +20,20 @@
diff --git a/items-narrow.css b/items-narrow.css new file mode 100644 index 0000000..dc4a7f6 --- /dev/null +++ b/items-narrow.css @@ -0,0 +1,7 @@ +.items { + padding: 0%; + display: grid; + grid-template-columns: repeat(1, 1fr); + width: 100%; + gap: 5px; +} diff --git a/items-wide.css b/items-wide.css new file mode 100644 index 0000000..0353758 --- /dev/null +++ b/items-wide.css @@ -0,0 +1,8 @@ +.items { + padding: 0%; + display: grid; + grid-template-columns: repeat(5, 1fr); + width: 100%; + gap: 5px; + grid-template-rows: masonry; +} diff --git a/items.html b/items.html index f5f128b..6253188 100644 --- a/items.html +++ b/items.html @@ -1,35 +1,58 @@ + + + + + Wynn Clientside - -
- Made by: hppeng and ferricles -
-
- Additional credits +



-
-
-
item
-
+
+ diff --git a/items.js b/items.js index 2973536..0a0419f 100644 --- a/items.js +++ b/items.js @@ -1,11 +1,30 @@ +function applyQuery(items, query) { + return items.filter(query.filter, query).sort(query.compare); +} + +function displayItems(items_copy) { + let items_parent = document.getElementById("main"); + for (let i in items_copy) { + let item = items_copy[i]; + let box = document.createElement("div"); + box.classList.add("box"); + box.id = "item"+i; + items_parent.appendChild(box); + displayExpandedItem(expandItem(item, []), box.id); + } +} + function init() { let items_copy = items.slice(); - let query = new NameQuery("Bob's"); - items_copy = items_copy.filter(query.filter, query).sort(query.compare); - let item = items_copy[0]; - console.log(item); - displayExpandedItem(expandItem(item, []), "test"); + //let query = new NameQuery("Bob's"); + let query1 = new IdQuery("poison"); + items_copy = applyQuery(items_copy, query1); + + let query2 = new TypeQuery("boots"); + items_copy = applyQuery(items_copy, query2); + + displayItems(items_copy); } load_init(init); diff --git a/load.js b/load.js index 1a65771..c60237b 100644 --- a/load.js +++ b/load.js @@ -64,7 +64,7 @@ function clean_item(item) { async function load(init_func) { let getUrl = window.location; - let baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]; + let baseUrl = getUrl.protocol + "//" + getUrl.host + "/";// + getUrl.pathname.split('/')[1]; let url = baseUrl + "/compress.json"; let result = await (await fetch(url)).json(); items = result.items; diff --git a/media/icons/atlas64.png b/media/icons/atlas64.png new file mode 100755 index 0000000000000000000000000000000000000000..5e5d552a0b185b988192c07f8a26a7effb6abe63 GIT binary patch literal 358 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`032l#}z0%-{e2?q^^1qBQzW(Z_BF#Na>@c+X>pm=%DhsQvQvn0qb_&*dd z1p8MAfdmUYB8wRq_zr_Gxzg z?)0}V;AC*t6SQ>hpAz%^(i2_FM(JrmLdzMZT$tYZ_T&RGhG`57<@z~{*RCnx o5sA#q_|sVYApG2chX*9`84aQfoeDm`26~0T)78&qol`;+0B2o^WdHyG literal 0 HcmV?d00001 diff --git a/query.js b/query.js index c0d974c..c3bc06f 100644 --- a/query.js +++ b/query.js @@ -1,8 +1,4 @@ -/** - * @description A query into the item - * @module ItemNotFound - */ class NameQuery { constructor(string) { this.queryString = string; @@ -19,3 +15,33 @@ class NameQuery { return a < b; } } + +class TypeQuery { + constructor(type) { + this.type = type; + } + + filter(item) { + if (item.remapID === undefined) { + return (item.type === this.type); + } + return false; + } + + compare(a, b) { + return a < b; + } +} + +class IdQuery { + constructor(id) { + this.id = id; + this.compare = function(a, b) { + return b[id] - a[id]; + }; + } + + filter(item) { + return (this.id in item) && (item[this.id]); + } +} diff --git a/updated.json b/updated.json index 9b19c46..e938bc2 100644 --- a/updated.json +++ b/updated.json @@ -257086,7 +257086,7 @@ "tier": "Fabled", "type": "spear", "name": "Rhythm of Seasons", - "displayName": "Rhythm of Seasons", + "displayName": "Rhythm of the Seasons", "set": null, "quest": null, "classReq": null, From e9f8da4dc8815d4cca469787ed7b024ee974c22b Mon Sep 17 00:00:00 2001 From: b Date: Sun, 24 Jan 2021 04:09:59 -0600 Subject: [PATCH 2/2] WynnAtlas v0 --- items-narrow.css | 16 ++++++++- items-wide.css | 18 +++++++++- items.html | 27 +++++++++++++-- items.js | 19 +++++++++-- query.js | 36 +++++++++++++------- translations.txt | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ wide.css | 2 +- 7 files changed, 185 insertions(+), 21 deletions(-) create mode 100644 translations.txt diff --git a/items-narrow.css b/items-narrow.css index dc4a7f6..b50a0b1 100644 --- a/items-narrow.css +++ b/items-narrow.css @@ -1,7 +1,21 @@ .items { + grid-column: 1; padding: 0%; display: grid; - grid-template-columns: repeat(1, 1fr); + grid-template-columns: repeat(auto-fill, 1fr); width: 100%; gap: 5px; } + +.itemsearch { + padding: 0%; + display: grid; + grid-template-columns: 1fr; + width: 100%; + gap: 5px; + grid-template-rows: masonry; +} + +.search { + grid-column: 1; +} diff --git a/items-wide.css b/items-wide.css index 0353758..04449fa 100644 --- a/items-wide.css +++ b/items-wide.css @@ -1,8 +1,24 @@ .items { + grid-column: 2; padding: 0%; display: grid; - grid-template-columns: repeat(5, 1fr); + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); width: 100%; gap: 5px; grid-template-rows: masonry; } + +.itemsearch { + padding: 0%; + display: grid; + grid-template-columns: 1fr 4fr; + width: 100%; + gap: 5px; +} + +.search { + grid-column: 1; + position: sticky; + margin-bottom: auto; + top: 10px; +} diff --git a/items.html b/items.html index 6253188..81d91e1 100644 --- a/items.html +++ b/items.html @@ -47,9 +47,30 @@


-
-
-
+
+ +
+
diff --git a/items.js b/items.js index 0a0419f..d6b48d1 100644 --- a/items.js +++ b/items.js @@ -15,13 +15,28 @@ function displayItems(items_copy) { } } +function doItemSearch() { + window.scrollTo(0, 0); + let input_json = document.getElementById("query-json").value; + let input = JSON.parse(input_json); + let items_copy = items.slice(); + document.getElementById("main").textContent = ""; + for (const _query of input) { + const query = queryTypeMap.get(_query.queryType)(_query.value); + items_copy = applyQuery(items_copy, query); + } + document.getElementById("summary").textContent = items_copy.length + " results." + displayItems(items_copy); +} + function init() { + return; let items_copy = items.slice(); //let query = new NameQuery("Bob's"); - let query1 = new IdQuery("poison"); + let query1 = new IdQuery("sdRaw"); items_copy = applyQuery(items_copy, query1); - let query2 = new TypeQuery("boots"); + let query2 = new TypeQuery("helmet"); items_copy = applyQuery(items_copy, query2); displayItems(items_copy); diff --git a/query.js b/query.js index c3bc06f..2f6f4fe 100644 --- a/query.js +++ b/query.js @@ -1,25 +1,21 @@ +let queryTypeMap = new Map(); class NameQuery { - constructor(string) { - this.queryString = string; - } + constructor(string) { this.queryString = string.toLowerCase(); } filter(item) { if (item.remapID === undefined) { - return (item.displayName.includes(this.queryString)); + return (item.displayName.toLowerCase().includes(this.queryString)); } return false; } - compare(a, b) { - return a < b; - } + compare(a, b) { return a < b; } } +queryTypeMap.set("name", function(s) { return new NameQuery(s); } ); class TypeQuery { - constructor(type) { - this.type = type; - } + constructor(type) { this.type = type; } filter(item) { if (item.remapID === undefined) { @@ -28,10 +24,23 @@ class TypeQuery { return false; } - compare(a, b) { - return a < b; - } + compare(a, b) { return a < b; } } +queryTypeMap.set("type", function(s) { return new TypeQuery(s); } ); + +class CategoryQuery { + constructor(category) { this.category = category; } + + filter(item) { + if (item.remapID === undefined) { + return (item.category === this.category); + } + return false; + } + + compare(a, b) { return a < b; } +} +queryTypeMap.set("category", function(s) { return new CategoryQuery(s); } ); class IdQuery { constructor(id) { @@ -45,3 +54,4 @@ class IdQuery { return (this.id in item) && (item[this.id]); } } +queryTypeMap.set("stat", function(s) { return new IdQuery(s); } ); diff --git a/translations.txt b/translations.txt new file mode 100644 index 0000000..82f4912 --- /dev/null +++ b/translations.txt @@ -0,0 +1,88 @@ +Mapping from API name to shortened names + +"name": "name", +"displayName": "displayName", +"tier": "tier", +"set": "set", +"sockets": "slots", +"type": "type", +"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", diff --git a/wide.css b/wide.css index a96d397..0c826a0 100644 --- a/wide.css +++ b/wide.css @@ -15,7 +15,7 @@ } .sticky-box { position: sticky; - top: 0; + top: 10px; } .summary { padding: 2% 2% 0%;