diff --git a/customizer.html b/customizer.html index ca7f339..17eb6ef 100644 --- a/customizer.html +++ b/customizer.html @@ -1810,42 +1810,44 @@

Options

-

-
+

Fixed IDs:

+
-
+
-
-
Fixed IDs:
+
+ +

-
+
-
+
-
- -

+
+
-
+
Base Item:
-
+
-
+
diff --git a/customizer.js b/customizer.js index 2125fe9..411cce9 100644 --- a/customizer.js +++ b/customizer.js @@ -708,4 +708,39 @@ function _init_customizer() { load_ing_init(init_customizer); } +/** Saves the current user's item as a JSON file. + * Starts a JSON download. + */ +function saveAsJSON() { + let CI = {}; + for (const [id, val] of player_custom_item.statMap) { + if (id === "minRolls" || id === "maxRolls") { + continue; + } else { + val ? CI[reversetranslations.get(id) ? reversetranslations.get(id) : id] = val : "" ; + } + } + if (player_custom_item.statMap.get("minRolls")) { + for (const [id, min] of player_custom_item.statMap.get("minRolls")) { + const max = player_custom_item.statMap.get("maxRolls").get(id); + if (min && max) { + console.log(reversetranslations); + CI[reversetranslations.get(id) ? reversetranslations.get(id) : id] = [min,max]; + } + } + } + + console.log(CI); + //yuck + let filename = player_custom_item.statMap.get("displayName"); + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(CI, null, 2))); + element.setAttribute('download', filename + ".json"); + + element.style.display = 'none'; + document.body.appendChild(element); + element.click(); + document.body.removeChild(element); +} + load_init(_init_customizer); diff --git a/script.py b/script.py index 687cbbb..e90655d 100644 --- a/script.py +++ b/script.py @@ -1,14 +1,9 @@ -from PIL import Image +import requests +import json +response = requests.get("https://api.wynncraft.com/public_api.php?action=itemDB&search=atlas").json() +atlas = response['items'][0] -#imgs = ["Content_Dungeon.png", "Content_CorruptedDungeon.png", "Content_Quest.png", "Merchant_Emerald.png", "NPC_Blacksmith.png", "NPC_ItemIdentifier.png", "NPC_PowderMaster.png", "Merchant_Potion.png", "Merchant_Armour.png", "Merchant_Weapon.png", "Merchant_Liquid.png", "Merchant_Other.png", "Merchant_Scroll.png", "Merchant_Accessory.png", "Merchant_Tool.png", "painting.png", "Profession_Weaponsmithing.png", "Profession_Armouring.png", "Profession_Alchemism.png", "Profession_Jeweling.png", "Profession_Tailoring.png", "Profession_Scribing.png", "Profession_Cooking.png", "Profession_Woodworking.png", "Content_Miniquest.png", "Special_RootsOfCorruption.png", "Special_FastTravel.png", "Special_LightRealm.png", "Special_Rune.png", "Content_UltimateDiscovery.png", "Merchant_KeyForge.png", "NPC_GuildMaster.png", "Content_GrindSpot.png", "Content_Cave.png", "NPC_TradeMarket.png", "Content_BossAltar.png", "Content_Raid.png", "Merchant_Dungeon.png", "tnt.png", "Merchant_Seasail.png", "Merchant_Horse.png"] -imgs = ["Merchant_Emerald.png", "NPC_Blacksmith.png", "NPC_ItemIdentifier.png", "NPC_PowderMaster.png", "Merchant_Potion.png", "Merchant_Armour.png", "Merchant_Weapon.png", "Merchant_Liquid.png", "Merchant_Other.png", "Merchant_Scroll.png", "Merchant_Accessory.png", "Merchant_Tool.png", "painting.png", "Profession_Weaponsmithing.png", "Profession_Armouring.png", "Profession_Alchemism.png", "Profession_Jeweling.png", "Profession_Tailoring.png", "Profession_Scribing.png", "Profession_Cooking.png", "Profession_Woodworking.png", "Special_RootsOfCorruption.png", "Special_LightRealm.png", "Content_UltimateDiscovery.png", "Merchant_KeyForge.png", "NPC_GuildMaster.png", "Content_GrindSpot.png", "NPC_TradeMarket.png", "Content_Raid.png", "Merchant_Dungeon.png", "tnt.png", "Merchant_Seasail.png", "Merchant_Horse.png"] +with open('test.json',"w") as outfile: + json.dump(atlas, outfile, indent = 2) -im1 = Image.open("./media/icons/maplocstemp/Content_GrindSpot.png") -for name in imgs: - img = im1.copy() - img.save("./media/icons/maplocstemp/" + name, "PNG") - -# img = Image.new(mode = "RGB", size = (32,32)) -# img.putalpha(0) -# for name in imgs: -# img.save("./media/icons/maplocstemp/" + name, "PNG") +print(atlas) diff --git a/translations.txt b/translations.txt index 82f4912..b4ed6da 100644 --- a/translations.txt +++ b/translations.txt @@ -1,5 +1,3 @@ -Mapping from API name to shortened names - "name": "name", "displayName": "displayName", "tier": "tier", @@ -68,7 +66,6 @@ Mapping from API name to shortened names "identified": "fixID", "skin": "skin", "category": "category", - "spellCostPct1": "spPct1", "spellCostRaw1": "spRaw1", "spellCostPct2": "spPct2", @@ -77,12 +74,10 @@ Mapping from API name to shortened names "spellCostRaw3": "spRaw3", "spellCostPct4": "spPct4", "spellCostRaw4": "spRaw4", - "rainbowSpellDamageRaw": "rainbowRaw", "sprint": "sprint", "sprintRegen": "sprintReg", "jumpHeight": "jh", "lootQuality": "lq", - "gatherXpBonus": "gXp", "gatherSpeed": "gSpd", diff --git a/utils.js b/utils.js index 722ae6a..abfaa89 100644 --- a/utils.js +++ b/utils.js @@ -22,7 +22,18 @@ let itemTypes = armorTypes.concat(accessoryTypes).concat(weaponTypes); let elementIcons = ["\u2724","\u2726", "\u2749", "\u2739", "\u274b" ]; let skpReqs = skp_order.map(x => x + "Req"); - +//File reading for ID translations for JSON purposes +let reversetranslations; +let translations; +function setRevTrans(revTransText) { + reversetranslations = new Map(revTransText.replaceAll(" ", "").replaceAll("\"", "").replaceAll("\n","").replaceAll("\r","").split(",").map(x => x.split(":").reverse())) +} +function setTrans(transText) { + translations = new Map(transText.replaceAll(" ", "").replaceAll("\"", "").replaceAll("\n","").replaceAll("\r","").split(",").map(x => x.split(":"))) +} +fetch('translations.txt').then(response => response.text()).then(data => {setRevTrans(data)}); +fetch('translations.txt').then(response => response.text()).then(data => {setTrans(data);}); +console.log(translations); function clamp(num, low, high){ return Math.min(Math.max(num, low), high);