diff --git a/builder.js b/builder.js
index 66473d6..fc8d67b 100644
--- a/builder.js
+++ b/builder.js
@@ -3,7 +3,7 @@ const url_tag = location.hash.slice(1);
console.log(url_base);
console.log(url_tag);
-const BUILD_VERSION = "6.9.10";
+const BUILD_VERSION = "6.9.11";
function setTitle() {
let text;
diff --git a/craft.js b/craft.js
index 1705920..f1b1e52 100644
--- a/craft.js
+++ b/craft.js
@@ -2,6 +2,33 @@ let armorTypes = [ "helmet", "chestplate", "leggings", "boots" ];
let accessoryTypes = [ "ring", "bracelet", "necklace" ];
let weaponTypes = [ "wand", "spear", "bow", "dagger", "relik" ];
let consumableTypes = [ "potion", "scroll", "food"]
+
+//constructs a craft from a hash 'CR-qwoefsabaoe' or 'qwoefsaboe'
+function createCraft(hash) {
+ let name = hash;
+ if (name.slice(0,3) === "CR-") {
+ name = name.substring(3);
+ }
+ this.hash = name;
+ ingreds = [];
+ /*for (let i = 0; i < 6; i ++ ) {
+ ingreds.push( ingIDMap.get(Base64.toInt(name.substring(2*i,2*i+2))) );
+ }
+ let recipe = recipeIDMap.get(Base64.toInt(tag.substring(12,14)));
+ recipesName = recipe.split("-");
+ setValue("recipe-choice",recipesName[0]);
+ setValue("level-choice",recipesName[1]+"-"+recipesName[2]);
+ tierNum = Base64.toInt(tag.substring(14,15));
+ let mat_tiers = [];
+ mat_tiers.push(tierNum % 3 == 0 ? 3 : tierNum % 3);
+ mat_tiers.push(Math.floor((tierNum-0.5) / 3)+1); //Trying to prevent round-off error, don't yell at me
+ let atkSpd = Base64.toInt(tag.substring(15));
+ let atkSpds = ["SLOW,NORMAL,FAST"];
+ let attackSpeed atkSpds[atkSpd];
+ */
+}
+
+
/* Creates a crafted item object.
*/
class Craft{
@@ -19,12 +46,12 @@ class Craft{
this.hash = hash;
this.initCraftStats();
}
+
+
setHash(hash) {
this.hash = hash;
- console.log(hash);
this.statMap.set("displayName", "CR-" + this.hash);
- console.log(this.statMap.get("displayName"));
}
/* Get all stats for this build. Stores in this.statMap.
@pre The craft itself should be valid. No checking of validity of pieces is done here.
@@ -107,12 +134,12 @@ class Craft{
*/
let matmult = 1;
- let sorted = this.mat_tiers.slice().sort();
+ let sorted = this.mat_tiers.slice().sort(function(a, b){return a - b});
//TODO - MAT MULTIPLIERS ARE SUS FOR NON-MIXING TIERS.
if( sorted[0] == 1 && sorted[1] == 1) {
matmult = 1;
} else if( sorted[0] == 1 && sorted[1] == 2) {
- matmult = 1.10;
+ matmult = 1.09;
}else if( sorted[0] == 1 && sorted[1] == 3) {
matmult = 1.15;
}else if( sorted[0] == 2 && sorted[1] == 2) {
@@ -145,57 +172,51 @@ class Craft{
} else if (this['atkSpd'] === "FAST") {
ratio /= 2.5;
}
- low = Math.floor(low * matmult);
- high = Math.floor(high * matmult);
- low = Math.floor(low * ratio);
- high = Math.floor(high * ratio);
- let low1 = Math.floor(low * 0.9);
- let low2 = Math.floor(low * 1.1);
- let high1 = Math.floor(high * 0.9);
- let high2 = Math.floor(high * 1.1);
-
- statMap.set("nDamLow", low1 + "-" + low2); //jank
- statMap.set("nDam", high1 + "-" + high2);
-
+ let nDamBaseLow = Math.floor(low * matmult);
+ let nDamBaseHigh = Math.floor(high * matmult);
+ nDamBaseLow = Math.floor(nDamBaseLow * ratio);
+ nDamBaseHigh = Math.floor(nDamBaseHigh * ratio);
+ let elemDamBaseLow = [0,0,0,0,0];
+ let elemDamBaseHigh = [0,0,0,0,0];
/*
* APPLY POWDERS - MAY NOT BE CORRECT
*/
- let mockItem = new Map();
- mockItem.set("type",statMap.get("type"));
- mockItem.set("atkSpd",statMap.get("atkSpd"));
- mockItem.set("nDam", high1 + "-" + high2);
- for (const e of skp_elements) {
- mockItem.set(e+"Dam","0-0");
- }
- mockItem.set("powders",[]);
+ let powders = [];
for (let n in this.ingreds) {
let ingred = this.ingreds[n];
if (ingred.get("isPowder")) {
- mockItem.get("powders").push(ingred.get("pid"));
+ powders.push(ingred.get("pid"));
}
}
- let stats = new Map();
- stats.set("atkSpd", mockItem.get("atkSpd"));
- stats.set("damageBonus", [0, 0, 0, 0, 0]);
- stats.set("damageRaw", [mockItem.get("nDam"), mockItem.get("eDam"), mockItem.get("tDam"), mockItem.get("wDam"), mockItem.get("fDam"), mockItem.get("aDam")]);
- let damage_keys = [ "nDam", "eDam", "tDam", "wDam", "fDam", "aDam" ]; //affects base damage directly.
- let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, mockItem, [0, 0, 0, 0, 0], 1, undefined);
- let damages = results[2];
- for (const i in damage_keys) {
- statMap.set(damage_keys[i], damages[i][0]+"-"+damages[i][1]);
- }
- //second go-through: for the low roll.
- mockItem.set("nDam", low1 + "-" + low2);
- for (const e of skp_elements) {
- mockItem.set(e+"Dam","0-0");
- }
- stats.set("damageRaw", [mockItem.get("nDam"), mockItem.get("eDam"), mockItem.get("tDam"), mockItem.get("wDam"), mockItem.get("fDam"), mockItem.get("aDam")]);
- results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, mockItem, [0, 0, 0, 0, 0], 1, undefined);
- damages = results[2];
- for (const i in damage_keys) {
- statMap.set(damage_keys[i]+"Low", damages[i][0]+"-"+damages[i][1]);
+ for (const p of powders) {
+ /* Powders as ingredients in crafted weapons are different than powders applied to non-crafted weapons. Thanks to nbcss for showing me the math.
+ */
+ let powder = powderStats[p]; //use min, max, and convert
+ let element = Math.floor((p+0.01)/6); //[0,4], the +0.01 attempts to prevent division error
+ let diffLow = Math.floor(nDamBaseLow * powder.convert/100);
+ nDamBaseLow -= diffLow;
+ elemDamBaseLow[element] += diffLow + Math.floor( (powder.min + powder.max) / 2 );
+ let diffHigh = Math.floor(nDamBaseHigh * powder.convert/100);
+ nDamBaseHigh -= diffHigh;
+ elemDamBaseHigh[element] += diffHigh + Math.floor( (powder.min + powder.max) / 2 );
}
+ /* I create a separate variable for each low damage range because we need one damage range to calculate damage with, and it's custom to use the maximum range of the range range.
+ */
+ let low1 = Math.floor(nDamBaseLow * 0.9);
+ let low2 = Math.floor(nDamBaseLow * 1.1);
+ let high1 = Math.floor(nDamBaseHigh * 0.9);
+ let high2 = Math.floor(nDamBaseHigh * 1.1);
+ statMap.set("nDamLow", low1+"-"+low2);
+ statMap.set("nDam", high1+"-"+high2);
+ for (const e in skp_elements) {
+ low1 = Math.floor(elemDamBaseLow[e] * 0.9);
+ low2 = Math.floor(elemDamBaseLow[e] * 1.1);
+ high1 = Math.floor(elemDamBaseHigh[e] * 0.9);
+ high2 = Math.floor(elemDamBaseHigh[e] * 1.1);
+ statMap.set(skp_elements[e]+"DamLow", low1+"-"+low2);
+ statMap.set(skp_elements[e]+"Dam",high1+"-"+high2);
+ }
} else if (statMap.get("category") === "armor") {
for (let n in this.ingreds) {
let ingred = this.ingreds[n];
@@ -206,6 +227,9 @@ class Craft{
statMap.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (statMap.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - powder["defMinus"]);
}
}
+ low = Math.floor(low * matmult);
+ high = Math.floor(high * matmult);
+ statMap.set("hp",low+"-"+high);
}
/* END SECTION */
@@ -290,7 +314,7 @@ class Craft{
for (const [key,value] of ingred.get("ids").get("minRolls")) {
if (value && value != 0) {
let rolls = [value,ingred.get("ids").get("maxRolls").get(key)];
- rolls = rolls.map(x => Math.floor(x * eff_mult)).sort();
+ rolls = rolls.map(x => Math.floor(x * eff_mult)).sort(function(a, b){return a - b});
statMap.get("minRolls").set(key, (statMap.get("minRolls").get(key)) ? statMap.get("minRolls").get(key) + rolls[0] : rolls[0]);
statMap.get("maxRolls").set(key, (statMap.get("maxRolls").get(key)) ? statMap.get("maxRolls").get(key) + rolls[1] : rolls[1]);
}
diff --git a/crafter.js b/crafter.js
index fda60ac..d7b275e 100644
--- a/crafter.js
+++ b/crafter.js
@@ -9,7 +9,7 @@ console.log(url_tag);
-const BUILD_VERSION = "6.9.9";
+const BUILD_VERSION = "6.9.11";
/*
* END testing section
*/
@@ -29,7 +29,7 @@ function setTitle() {
document.getElementById("header").textContent = "WynnCrafter version "+BUILD_VERSION+" (ingredient db version "+ING_DB_VERSION+")";
document.getElementById("header").classList.add("funnynumber");
let disclaimer = document.createElement("p");
- disclaimer.textContent = "THIS CRAFTER IS INCOMPLETE. The effect of material tiers on crated items is not 100% tested and accurate. If you know how the math behind it works, please contact ferricles on forums, discord, or ingame.";
+ disclaimer.textContent = "THIS CRAFTER IS NEARLY COMPLETE. The effect of material tiers on crafted items is not 100% tested and accurate. If you know how the math behind it works OR if you have a crafted item whose stats contradict this crafter, please contact ferricles on forums, discord, or ingame.";
document.getElementById("header").append(disclaimer);
}
setTitle();
@@ -42,6 +42,7 @@ let recipeList = [];
let ingIDMap = new Map();
let recipeIDMap = new Map();
+
function init() {
//no ing
let ing = Object();
@@ -53,9 +54,10 @@ function init() {
ing.itemIDs = {"dura": 0, "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,};
ing.consumableIDs = {"dura": 0, "charges": 0};
ing.posMods = {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0};
+ ing.id = 4000;
ingMap.set(ing["name"], ing);
ingList.push(ing["name"]);
- ingIDMap.set(ingList.length-1, ing["name"]);
+ ingIDMap.set(ing["id"], ing["name"]);
let numerals = new Map([[1, "I"], [2, "II"], [3, "III"], [4, "IV"], [5, "V"], [6, "VI"]]);
for (let i = 0; i < 5; i ++) {
for (const powderIng of powderIngreds) {
@@ -67,6 +69,7 @@ function init() {
ing.ids = {};
ing.isPowder = true;
ing.pid = 6*i + powderIngreds.indexOf(powderIng);
+ ing.id = 4001 + ing.pid;
ing.itemIDs = {"dura": powderIng["durability"], "strReq": 0, "dexReq": 0,"intReq": 0,"defReq": 0,"agiReq": 0,};
switch(i) {
case 0:
@@ -89,6 +92,7 @@ function init() {
ing.posMods = {"left": 0, "right": 0, "above": 0, "under": 0, "touching": 0, "notTouching": 0};
ingMap.set(ing["name"],ing);
ingList.push(ing["name"]);
+ ingIDMap.set(ing["id"], ing["name"]);
}
}
@@ -96,10 +100,12 @@ function init() {
for (const ing of ings) {
ingMap.set(ing["name"], ing);
ingList.push(ing["name"]);
+ ingIDMap.set(ing["id"], ing["name"]);
}
for (const recipe of recipes) {
- recipeMap.set(recipe["id"], recipe);
- recipeList.push(recipe["id"]);
+ recipeMap.set(recipe["name"], recipe);
+ recipeList.push(recipe["name"]);
+ recipeIDMap.set(recipe["id"],recipe["name"]);
}
console.log("all ingredients");
console.log(ings);
@@ -107,6 +113,8 @@ function init() {
console.log(recipes);
console.log(ingList);
console.log(recipeList);
+ console.log(ingIDMap);
+ console.log(recipeIDMap);
document.getElementById("recipe-choice").addEventListener("change", (event) => {
updateMaterials();
@@ -117,6 +125,7 @@ function init() {
populateFields();
decodeCraft(url_tag);
+
}
function updateMaterials() {
let recipeName = getValue("recipe-choice") ? getValue("recipe-choice") : "Potion";
@@ -229,13 +238,13 @@ function encodeCraft() {
if (player_craft) {
let atkSpds = ["SLOW","NORMAL","FAST"];
let craft_string = "1_" +
- Base64.fromIntN(ingList.indexOf(player_craft.ingreds[0].get("name")), 2) +
- Base64.fromIntN(ingList.indexOf(player_craft.ingreds[1].get("name")), 2) +
- Base64.fromIntN(ingList.indexOf(player_craft.ingreds[2].get("name")), 2) +
- Base64.fromIntN(ingList.indexOf(player_craft.ingreds[3].get("name")), 2) +
- Base64.fromIntN(ingList.indexOf(player_craft.ingreds[4].get("name")), 2) +
- Base64.fromIntN(ingList.indexOf(player_craft.ingreds[5].get("name")), 2) +
- Base64.fromIntN(recipeList.indexOf(player_craft.recipe.get("id")),2) +
+ Base64.fromIntN(player_craft.ingreds[0].get("id"), 2) +
+ Base64.fromIntN(player_craft.ingreds[1].get("id"), 2) +
+ Base64.fromIntN(player_craft.ingreds[2].get("id"), 2) +
+ Base64.fromIntN(player_craft.ingreds[3].get("id"), 2) +
+ Base64.fromIntN(player_craft.ingreds[4].get("id"), 2) +
+ Base64.fromIntN(player_craft.ingreds[5].get("id"), 2) +
+ Base64.fromIntN(player_craft.recipe.get("id"),2) +
Base64.fromIntN(player_craft.mat_tiers[0] + (player_craft.mat_tiers[1]-1)*3, 1) + //this maps tiers [a,b] to a+3b.
Base64.fromIntN(atkSpds.indexOf(player_craft["atkSpd"]),1);
return craft_string;
@@ -244,16 +253,17 @@ function encodeCraft() {
}
function decodeCraft(url_tag) {
if (url_tag) {
- console.log(url_tag);
let info = url_tag.split("_");
let version = info[0];
let tag = info[1];
if (version === "1") {
ingreds = [];
for (let i = 0; i < 6; i ++ ) {
- setValue("ing-choice-"+(i+1), ingList[Base64.toInt(tag.substring(2*i,2*i+2))]);
+ setValue("ing-choice-"+(i+1), ingIDMap.get(Base64.toInt(tag.substring(2*i,2*i+2))));
+ console.log(Base64.toInt(tag.substring(2*i,2*i+2)));
}
- recipe = recipeList[Base64.toInt(tag.substring(12,14))];
+ recipe = recipeIDMap.get(Base64.toInt(tag.substring(12,14)));
+ console.log(Base64.toInt(tag.substring(12,14)));
recipesName = recipe.split("-");
setValue("recipe-choice",recipesName[0]);
setValue("level-choice",recipesName[1]+"-"+recipesName[2]);
@@ -264,7 +274,6 @@ function decodeCraft(url_tag) {
toggleMaterial("mat-1-"+mat_tiers[0]);
toggleMaterial("mat-2-"+mat_tiers[1]);
atkSpd = Base64.toInt(tag.substring(15));
- console.log(atkSpd);
let atkSpdButtons = ["slow-atk-button", "normal-atk-button", "fast-atk-button"];
toggleAtkSpd(atkSpdButtons[atkSpd]);
@@ -323,11 +332,38 @@ function copyRecipe(){
function shareRecipe(){
if (player_craft) {
let copyString = url_base+location.hash + "\n";
- let name = player_craft.recipe.get("id").split("-");
+ let name = player_craft.recipe.get("name").split("-");
copyString += " > " + name[0] + " " + "Lv. " + name[1] + "-" + name[2] + " (" + player_craft.mat_tiers[0] + "\u272B, " + player_craft.mat_tiers[1] + "\u272B)\n";
- copyString += " > [" + player_craft.ingreds[0].get("name") + " | " + player_craft.ingreds[1].get("name") + "\n";
- copyString += " > " + player_craft.ingreds[2].get("name") + " | " + player_craft.ingreds[3].get("name") + "\n";
- copyString += " > " + player_craft.ingreds[4].get("name") + " | " + player_craft.ingreds[5].get("name") + "]";
+ let names = [
+ player_craft.ingreds[0].get("name"),
+ player_craft.ingreds[1].get("name"),
+ player_craft.ingreds[2].get("name"),
+ player_craft.ingreds[3].get("name"),
+ player_craft.ingreds[4].get("name"),
+ player_craft.ingreds[5].get("name")
+ ];
+ //fancy justify code that doesn't work properly b/c most font isn't monospaced
+ let buffer1 = Math.max(names[0].length,names[2].length,names[4].length);
+ let buffer2 = Math.max(names[1].length,names[3].length,names[5].length);
+ for (let i in names) {
+ let name = names[i];
+ let spaces;
+ if (i % 2 == 0) { //buffer 1
+ spaces = buffer1 - name.length;
+ } else { //buffer 2
+ spaces = buffer2 - name.length;
+ }
+ for (let j = 0; j < spaces; j ++) {
+ if (j % 2 == 0) {
+ names[i]+=" ";
+ } else {
+ names[i] = " "+names[i];
+ }
+ }
+ }
+ copyString += " > [" + names[0] + " | " + names[1] + "\n";
+ copyString += " > " + names[2] + " | " + names[3] + "\n";
+ copyString += " > " + names[4] + " | " + names[5] + "]";
copyTextToClipboard(copyString);
document.getElementById("share-button").textContent = "Copied!";
}
diff --git a/display.js b/display.js
index ac5df43..588aa70 100644
--- a/display.js
+++ b/display.js
@@ -86,7 +86,7 @@ function expandIngredient(ing) {
}
expandedIng.set(id, idMap);
}
- let normIds = ['lvl','name','tier','skills'];
+ let normIds = ['lvl','name','tier','skills','id'];
for (const id of normIds) {
expandedIng.set(id, ing[id]);
}
@@ -112,7 +112,7 @@ function expandIngredient(ing) {
*/
function expandRecipe(recipe) {
let expandedRecipe = new Map();
- let normIDs = ["id", "skill", "type"];
+ let normIDs = ["name", "skill", "type","id"];
for (const id of normIDs) {
expandedRecipe.set(id,recipe[id]);
}
@@ -577,12 +577,10 @@ function displayExpandedItem(item, parent_id){
if (item.get("tier") !== " ") {
p_elem.classList.add(item.get("tier"));
}
- if (["potion", "scroll", "food"].includes(item.get("type"))){
- let b = document.createElement("b");
- b.textContent = "[" + item.get("charges") + "/" + item.get("charges") + "]";
- b.classList.add("spaceleft");
- p_elem.appendChild(b);
- }
+ if(item.get("tier") === "Crafted") {
+ p_elem.classList.add("smalltitle");
+ p_elem.classList.remove("title");
+ }
p_elem.append(document.createElement("br"));
let img = document.createElement("img");
img.src = "/media/items/generic-" + item.get("type") + ".png";
@@ -773,6 +771,10 @@ function displayExpandedItem(item, parent_id){
dura = item.get("duration");
dura_elem.textContent = "Duration: "
suffix = " sec."
+ let charges = document.createElement("b");
+ charges.textContent = "Charges: " + item.get("charges");
+ charges.classList.add("spaceleft");
+ active_elem.appendChild(charges);
}
dura_elem.textContent += dura[0]+"-"+dura[1] + suffix;
active_elem.append(dura_elem);
diff --git a/index.html b/index.html
index e160c52..0de9786 100644
--- a/index.html
+++ b/index.html
@@ -1004,8 +1004,11 @@
-
+
+