2023-12-30 02:33:04 +00:00
|
|
|
let recipeTypes = ["HELMET","CHESTPLATE","LEGGINGS","BOOTS","RELIK","WAND","SPEAR","DAGGER","BOW","RING","NECKLACE","BRACELET","POTION", "SCROLL","FOOD"];
|
2021-04-30 10:36:25 +00:00
|
|
|
let levelTypes = ["1-3","3-5","5-7","7-9","10-13","13-15","15-17","17-19","20-23","23-25","25-27","27-29","30-33","33-35","35-37","37-39","40-43","43-45","45-47","47-49","50-53","53-55","55-57","57-59","60-63","63-65","65-67","67-69","70-73","73-75","75-77","77-79","80-83","83-85","85-87","87-89","90-93","93-95","95-97","97-99","100-103","103-105",]
|
2021-01-30 08:50:25 +00:00
|
|
|
|
2021-04-30 10:36:25 +00:00
|
|
|
function encodeCraft(craft) {
|
|
|
|
if (craft) {
|
|
|
|
let atkSpds = ["SLOW","NORMAL","FAST"];
|
|
|
|
let craft_string = "1" +
|
|
|
|
Base64.fromIntN(craft.ingreds[0].get("id"), 2) +
|
|
|
|
Base64.fromIntN(craft.ingreds[1].get("id"), 2) +
|
|
|
|
Base64.fromIntN(craft.ingreds[2].get("id"), 2) +
|
|
|
|
Base64.fromIntN(craft.ingreds[3].get("id"), 2) +
|
|
|
|
Base64.fromIntN(craft.ingreds[4].get("id"), 2) +
|
|
|
|
Base64.fromIntN(craft.ingreds[5].get("id"), 2) +
|
|
|
|
Base64.fromIntN(craft.recipe.get("id"),2) +
|
|
|
|
Base64.fromIntN(craft.mat_tiers[0] + (craft.mat_tiers[1]-1)*3, 1) + //this maps tiers [a,b] to a+3b.
|
|
|
|
Base64.fromIntN(atkSpds.indexOf(craft["atkSpd"]),1);
|
|
|
|
return craft_string;
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2021-01-29 22:11:57 +00:00
|
|
|
|
|
|
|
//constructs a craft from a hash 'CR-qwoefsabaoe' or 'qwoefsaboe'
|
2021-01-30 08:50:25 +00:00
|
|
|
function getCraftFromHash(hash) {
|
|
|
|
let name = hash.slice();
|
2021-03-14 07:55:08 +00:00
|
|
|
try {
|
|
|
|
if (name.slice(0,3) === "CR-") {
|
|
|
|
name = name.substring(3);
|
|
|
|
} else {
|
|
|
|
throw new Error("Not a crafted item!");
|
2021-01-30 08:50:25 +00:00
|
|
|
}
|
2021-03-14 07:55:08 +00:00
|
|
|
version = name.substring(0,1);
|
|
|
|
name = name.substring(1);
|
|
|
|
if (version === "1") {
|
|
|
|
let ingreds = [];
|
|
|
|
for (let i = 0; i < 6; i ++ ) {
|
|
|
|
ingreds.push( expandIngredient(ingMap.get(ingIDMap.get(Base64.toInt(name.substring(2*i,2*i+2))))) );
|
|
|
|
}
|
|
|
|
let recipe = expandRecipe(recipeMap.get(recipeIDMap.get(Base64.toInt(name.substring(12,14)))));
|
|
|
|
|
|
|
|
tierNum = Base64.toInt(name.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(name.substring(15));
|
|
|
|
let atkSpds = ["SLOW","NORMAL","FAST"];
|
|
|
|
let attackSpeed = atkSpds[atkSpd];
|
|
|
|
return new Craft(recipe,mat_tiers,ingreds,attackSpeed,"1"+name);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
2021-04-30 10:36:25 +00:00
|
|
|
console.log(error);
|
2021-03-14 07:55:08 +00:00
|
|
|
return undefined;
|
2021-01-29 22:11:57 +00:00
|
|
|
}
|
2021-01-30 08:50:25 +00:00
|
|
|
|
2021-03-14 07:55:08 +00:00
|
|
|
|
2021-01-29 22:11:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-19 17:32:27 +00:00
|
|
|
/* Creates a crafted item object.
|
|
|
|
*/
|
|
|
|
class Craft{
|
|
|
|
/* Constructs a craft.
|
|
|
|
@param recipe: Helmet-1-3 (id), etc. A recipe object.
|
|
|
|
@param mat_tiers: [1->3, 1->3]. An array with 2 numbers.
|
|
|
|
@param ingreds: []. An array with 6 entries, each with an ingredient Map.
|
|
|
|
*/
|
2021-01-28 00:52:34 +00:00
|
|
|
constructor(recipe, mat_tiers, ingreds, attackSpeed, hash) {
|
2021-01-19 17:32:27 +00:00
|
|
|
this.recipe = recipe;
|
|
|
|
this.mat_tiers = mat_tiers;
|
|
|
|
this.ingreds = ingreds;
|
|
|
|
this.statMap = new Map(); //can use the statMap as an expanded Item
|
2021-01-21 18:30:22 +00:00
|
|
|
this.atkSpd = attackSpeed;
|
2021-03-14 07:55:08 +00:00
|
|
|
this.hash = "CR-" + hash;
|
2021-01-19 17:32:27 +00:00
|
|
|
this.initCraftStats();
|
2021-02-05 18:09:36 +00:00
|
|
|
this.statMap.set("hash", this.hash);
|
2021-01-19 17:32:27 +00:00
|
|
|
}
|
2021-01-29 22:11:57 +00:00
|
|
|
|
2021-01-30 08:50:25 +00:00
|
|
|
applyPowders() {
|
2021-09-25 18:57:57 +00:00
|
|
|
if (this.statMap.get("category") === "armor" || this.statMap.get("category" === "accessory")) {
|
2021-01-30 08:50:25 +00:00
|
|
|
//double apply armor powders
|
|
|
|
for(const id of this.statMap.get("powders")){
|
|
|
|
let powder = powderStats[id];
|
|
|
|
let name = powderNames.get(id);
|
|
|
|
this.statMap.set(name.charAt(0) + "Def", (this.statMap.get(name.charAt(0)+"Def") || 0) + 2 * powder["defPlus"]);
|
|
|
|
this.statMap.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5] + "Def", (this.statMap.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 4 )% 5]+"Def") || 0) - 2 * powder["defMinus"]);
|
|
|
|
}
|
|
|
|
}else if (this.statMap.get("category") === "weapon") {
|
|
|
|
//do nothing - weapon powders are handled in displayExpandedItem
|
|
|
|
}
|
|
|
|
}
|
2021-01-28 00:52:34 +00:00
|
|
|
setHash(hash) {
|
2021-03-14 07:55:08 +00:00
|
|
|
this.hash = "CR-" + hash;
|
|
|
|
this.statMap.set("name", this.hash);
|
|
|
|
this.statMap.set("displayName", this.hash);
|
2021-02-05 18:09:36 +00:00
|
|
|
this.statMap.set("hash", this.hash);
|
2021-01-28 00:52:34 +00:00
|
|
|
}
|
2021-01-19 17:32:27 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
initCraftStats(){
|
2021-01-30 08:50:25 +00:00
|
|
|
|
2021-01-19 17:32:27 +00:00
|
|
|
let statMap = new Map();
|
|
|
|
statMap.set("minRolls", new Map());
|
|
|
|
statMap.set("maxRolls", new Map());
|
2021-03-14 07:55:08 +00:00
|
|
|
statMap.set("name", this.hash);
|
|
|
|
statMap.set("displayName", this.hash);
|
2021-01-19 17:32:27 +00:00
|
|
|
statMap.set("tier", "Crafted");
|
|
|
|
statMap.set("type", this.recipe.get("type").toLowerCase());
|
|
|
|
statMap.set("duration", [this.recipe.get("duration")[0], this.recipe.get("duration")[1]]); //[low, high]
|
|
|
|
statMap.set("durability", [this.recipe.get("durability")[0], this.recipe.get("durability")[1]]);
|
2021-03-14 07:55:08 +00:00
|
|
|
statMap.set("lvl", this.recipe.get("lvl")[1]);
|
|
|
|
statMap.set("lvlLow", this.recipe.get("lvl")[0]);
|
2021-01-19 17:32:27 +00:00
|
|
|
statMap.set("nDam", 0);
|
2021-01-30 08:50:25 +00:00
|
|
|
statMap.set("hp",0);
|
|
|
|
statMap.set("hpLow",0);
|
2021-01-28 00:52:34 +00:00
|
|
|
for (const e of skp_elements) {
|
|
|
|
statMap.set(e + "Dam", "0-0");
|
|
|
|
statMap.set(e + "Def", 0);
|
|
|
|
}
|
|
|
|
for (const e of skp_order) {
|
|
|
|
statMap.set(e + "Req", 0)
|
2021-01-30 08:50:25 +00:00
|
|
|
statMap.set(e, 0);
|
2021-01-28 00:52:34 +00:00
|
|
|
}
|
2021-01-30 08:50:25 +00:00
|
|
|
let allNone = true;
|
2021-01-19 17:32:27 +00:00
|
|
|
if (armorTypes.includes(statMap.get("type")) || weaponTypes.includes(statMap.get("type"))) {
|
2021-01-30 08:50:25 +00:00
|
|
|
statMap.set("category","weapon");
|
2021-01-19 17:32:27 +00:00
|
|
|
if(this.recipe.get("lvl")[0] < 30) {
|
|
|
|
statMap.set("slots", 1);
|
2021-01-30 08:50:25 +00:00
|
|
|
} else if (this.recipe.get("lvl")[0] < 70) {
|
2021-01-19 17:32:27 +00:00
|
|
|
statMap.set("slots", 2);
|
|
|
|
} else{
|
|
|
|
statMap.set("slots", 3);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
statMap.set("slots", 0);
|
|
|
|
}
|
|
|
|
if (consumableTypes.includes(statMap.get("type"))) {
|
2021-01-30 08:50:25 +00:00
|
|
|
statMap.set("category","consumable");
|
2021-01-19 17:32:27 +00:00
|
|
|
if(this.recipe.get("lvl")[0] < 30) {
|
|
|
|
statMap.set("charges", 1);
|
2021-01-30 08:50:25 +00:00
|
|
|
} else if (this.recipe.get("lvl")[0] < 70) {
|
2021-01-19 17:32:27 +00:00
|
|
|
statMap.set("charges", 2);
|
|
|
|
} else{
|
|
|
|
statMap.set("charges", 3);
|
|
|
|
}
|
|
|
|
//no ingredient consumables ALWAYS have 3 charges.
|
2021-01-30 08:50:25 +00:00
|
|
|
|
2021-01-19 17:32:27 +00:00
|
|
|
for(const ingred of this.ingreds) {
|
|
|
|
if(ingred.get("name") !== "No Ingredient") {
|
|
|
|
allNone = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (allNone) {
|
|
|
|
statMap.set("charges", 3);
|
|
|
|
statMap.set("hp", this.recipe.get("healthOrDamage").join("-"));
|
2021-01-19 18:30:47 +00:00
|
|
|
statMap.set("duration", this.recipe.get("basicDuration"));
|
2021-01-19 17:32:27 +00:00
|
|
|
}
|
|
|
|
statMap.set("category","consumable");
|
|
|
|
} else {
|
2021-01-28 00:52:34 +00:00
|
|
|
statMap.set("charges", 0);
|
2021-01-19 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (armorTypes.includes(statMap.get("type"))) {
|
|
|
|
statMap.set("hp", this.recipe.get("healthOrDamage").join("-"));
|
|
|
|
statMap.set("category","armor");
|
|
|
|
} else if (weaponTypes.includes(statMap.get("type"))) {
|
|
|
|
statMap.set("nDam", this.recipe.get("healthOrDamage").join("-"));
|
|
|
|
for (const e of skp_elements) {
|
|
|
|
statMap.set(e + "Dam", "0-0");
|
2021-01-28 00:52:34 +00:00
|
|
|
statMap.set(e + "DamLow", "0-0");
|
2021-01-19 17:32:27 +00:00
|
|
|
}
|
|
|
|
statMap.set("category","weapon");
|
2021-01-21 18:30:22 +00:00
|
|
|
statMap.set("atkSpd",this.atkSpd);
|
2021-01-19 17:32:27 +00:00
|
|
|
}
|
2021-01-30 08:50:25 +00:00
|
|
|
if (accessoryTypes.includes(statMap.get("type"))) {
|
|
|
|
statMap.set("category", "accessory");
|
|
|
|
}
|
2021-01-28 00:52:34 +00:00
|
|
|
statMap.set("powders",[]);
|
2021-01-21 21:15:05 +00:00
|
|
|
|
2021-01-19 17:32:27 +00:00
|
|
|
/* Change certain IDs based on material tier.
|
|
|
|
healthOrDamage changes.
|
|
|
|
duration and durability change. (but not basicDuration)
|
|
|
|
|
|
|
|
*/
|
2021-01-21 21:15:05 +00:00
|
|
|
let matmult = 1;
|
2021-02-05 18:17:46 +00:00
|
|
|
let tierToMult = [0,1,1.25,1.4];
|
|
|
|
let tiers = this.mat_tiers.slice();
|
|
|
|
let amounts = this.recipe.get("materials").map(x=> x.get("amount"));
|
|
|
|
//Mat Multipliers - should work!
|
|
|
|
matmult = (tierToMult[tiers[0]]*amounts[0] + tierToMult[tiers[1]]*amounts[1]) / (amounts[0]+amounts[1]);
|
|
|
|
|
2021-01-21 21:15:05 +00:00
|
|
|
let low = this.recipe.get("healthOrDamage")[0];
|
|
|
|
let high = this.recipe.get("healthOrDamage")[1];
|
|
|
|
if (statMap.get("category") === "consumable") {
|
2021-01-30 08:50:25 +00:00
|
|
|
if(allNone) {
|
2021-01-21 21:15:05 +00:00
|
|
|
statMap.set("hp", Math.floor( low * matmult )+ "-" + Math.floor( high * matmult ));
|
|
|
|
}
|
2021-05-06 03:12:23 +00:00
|
|
|
statMap.set("duration", [Math.round( statMap.get("duration")[0] * matmult ), Math.round( statMap.get("duration")[1] * matmult )]);
|
2021-01-21 21:15:05 +00:00
|
|
|
} else {
|
|
|
|
//durability modifier
|
2021-05-06 03:12:23 +00:00
|
|
|
statMap.set("durability", [Math.round( statMap.get("durability")[0] * matmult ), Math.round( statMap.get("durability")[1] * matmult )]);
|
2021-01-21 21:15:05 +00:00
|
|
|
}
|
|
|
|
if (statMap.get("category") === "weapon") {
|
|
|
|
//attack damages oh boy
|
2021-02-12 17:00:06 +00:00
|
|
|
let ratio = 2.05;
|
2021-01-28 00:52:34 +00:00
|
|
|
if (this['atkSpd'] === "SLOW") {
|
2021-01-21 21:15:05 +00:00
|
|
|
ratio /= 1.5;
|
2021-01-28 00:52:34 +00:00
|
|
|
} else if (this['atkSpd'] === "NORMAL") {
|
2021-01-21 21:15:05 +00:00
|
|
|
ratio = 1;
|
2021-01-28 00:52:34 +00:00
|
|
|
} else if (this['atkSpd'] === "FAST") {
|
2021-01-21 21:15:05 +00:00
|
|
|
ratio /= 2.5;
|
|
|
|
}
|
2021-01-29 22:11:57 +00:00
|
|
|
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];
|
2021-01-28 00:52:34 +00:00
|
|
|
/*
|
|
|
|
* APPLY POWDERS - MAY NOT BE CORRECT
|
|
|
|
*/
|
2021-01-29 22:11:57 +00:00
|
|
|
let powders = [];
|
2021-01-28 00:52:34 +00:00
|
|
|
for (let n in this.ingreds) {
|
|
|
|
let ingred = this.ingreds[n];
|
|
|
|
if (ingred.get("isPowder")) {
|
2021-01-29 22:11:57 +00:00
|
|
|
powders.push(ingred.get("pid"));
|
2021-01-28 00:52:34 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-27 22:41:57 +00:00
|
|
|
// 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 );
|
|
|
|
// }
|
|
|
|
statMap.set("ingredPowders", powders);
|
2021-01-28 00:52:34 +00:00
|
|
|
|
2021-01-29 22:11:57 +00:00
|
|
|
/* 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);
|
2021-03-14 07:55:08 +00:00
|
|
|
statMap.set("nDamBaseLow", nDamBaseLow);
|
|
|
|
statMap.set("nDamBaseHigh", nDamBaseHigh);
|
2021-01-29 22:11:57 +00:00
|
|
|
statMap.set("nDamLow", low1+"-"+low2);
|
|
|
|
statMap.set("nDam", high1+"-"+high2);
|
|
|
|
for (const e in skp_elements) {
|
2021-03-14 07:55:08 +00:00
|
|
|
statMap.set(skp_elements[e]+"DamBaseLow", elemDamBaseLow[e]);
|
|
|
|
statMap.set(skp_elements[e]+"DamBaseHigh", elemDamBaseHigh[e]);
|
2021-01-29 22:11:57 +00:00
|
|
|
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);
|
|
|
|
}
|
2021-01-28 00:52:34 +00:00
|
|
|
} else if (statMap.get("category") === "armor") {
|
2021-09-25 18:57:57 +00:00
|
|
|
low = Math.floor(low * matmult);
|
|
|
|
high = Math.floor(high * matmult);
|
|
|
|
statMap.set("hp",high);
|
|
|
|
statMap.set("hpLow",low);
|
|
|
|
}
|
|
|
|
if (statMap.get("category") === "armor" || statMap.get("category") == "accessory") {
|
2021-01-28 00:52:34 +00:00
|
|
|
for (let n in this.ingreds) {
|
|
|
|
let ingred = this.ingreds[n];
|
|
|
|
if (ingred.get("isPowder")) {
|
|
|
|
let powder = powderStats[ingred.get("pid")];
|
|
|
|
let name = powderNames.get(ingred.get("pid"));
|
|
|
|
statMap.set(name.charAt(0) + "Def", (statMap.get(name.charAt(0)+"Def") || 0) + powder["defPlus"]);
|
|
|
|
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"]);
|
|
|
|
}
|
|
|
|
}
|
2021-01-21 21:15:05 +00:00
|
|
|
}
|
|
|
|
/* END SECTION */
|
2021-01-19 17:32:27 +00:00
|
|
|
|
2021-02-12 17:00:06 +00:00
|
|
|
|
2021-01-19 17:32:27 +00:00
|
|
|
let eff = [[100,100],[100,100],[100,100]];
|
|
|
|
for (let n in this.ingreds) {
|
|
|
|
let ingred = this.ingreds[n];
|
|
|
|
//i and j will refer to the eff matrix.
|
|
|
|
let i = Math.floor(n / 2);
|
|
|
|
let j = n % 2;
|
|
|
|
for (const [key,value] of ingred.get("posMods")) {
|
|
|
|
if(value == 0) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
if (key === "above") {
|
|
|
|
for (let k = i-1; k > -1; k--) {
|
|
|
|
eff[k][j] += value;
|
|
|
|
}
|
|
|
|
} else if (key === "under") {
|
|
|
|
for (let k = i+1; k < 3; k++) {
|
|
|
|
eff[k][j] += value;
|
|
|
|
}
|
|
|
|
} else if (key === "left") {
|
|
|
|
if (j == 1) {
|
|
|
|
eff[i][j-1] += value;
|
|
|
|
}
|
|
|
|
} else if (key === "right") {
|
|
|
|
if (j == 0) {
|
|
|
|
eff[i][j+1] += value;
|
|
|
|
}
|
|
|
|
} else if (key === "touching") {
|
|
|
|
for (let k in eff) {
|
|
|
|
for (let l in eff[k]) {
|
|
|
|
if ( (Math.abs(k-i) == 1 && Math.abs (l-j) == 0) || (Math.abs(k-i) == 0 && Math.abs (l-j) == 1) ) {
|
|
|
|
eff[k][l] += value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (key === "notTouching") {
|
|
|
|
for (let k in eff) {
|
|
|
|
for (let l in eff[k]) {
|
|
|
|
if ( (Math.abs(k-i) > 1) || (Math.abs(k-i) == 1 && Math.abs(l-j) == 1) ) {
|
|
|
|
eff[k][l] += value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log("Something went wrong. Please contact hppeng.");
|
|
|
|
//wtf happened
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 19:53:41 +00:00
|
|
|
|
2021-01-19 17:32:27 +00:00
|
|
|
//apply ingredient effectivness - on ids, and reqs (itemIDs). NOT on durability, duration, or charges.
|
|
|
|
let eff_flat = eff.flat();
|
2021-01-20 05:59:17 +00:00
|
|
|
statMap.set("ingredEffectiveness", eff_flat);
|
2021-01-19 17:32:27 +00:00
|
|
|
//console.log(eff_flat);
|
|
|
|
//apply ingredient ids
|
|
|
|
for (const n in this.ingreds) {
|
|
|
|
let ingred = this.ingreds[n];
|
|
|
|
let eff_mult = (eff_flat[n] / 100).toFixed(2);
|
|
|
|
for (const [key, value] of ingred.get("itemIDs")) {
|
2021-01-30 08:50:25 +00:00
|
|
|
if(key !== "dura" && !consumableTypes.includes(statMap.get("type"))) { //consumables NEVER get reqs
|
2021-01-28 00:52:34 +00:00
|
|
|
if (!ingred.get("isPowder")) {
|
2021-01-30 08:50:25 +00:00
|
|
|
statMap.set(key, Math.round(statMap.get(key) + value*eff_mult));
|
2021-01-28 00:52:34 +00:00
|
|
|
} else {
|
2021-01-30 08:50:25 +00:00
|
|
|
statMap.set(key, Math.round(statMap.get(key) + value));
|
2021-01-28 00:52:34 +00:00
|
|
|
}
|
2021-01-19 17:32:27 +00:00
|
|
|
} else { //durability, NOT affected by effectiveness
|
|
|
|
statMap.set("durability", statMap.get("durability").map(x => x + value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const [key,value] of ingred.get("consumableIDs")) {
|
|
|
|
//neither duration nor charges are affected by effectiveness
|
|
|
|
if(key === "dura") {
|
|
|
|
statMap.set("duration", statMap.get("duration").map(x => x + value));
|
|
|
|
} else{
|
|
|
|
statMap.set(key, statMap.get("charges") + value);
|
|
|
|
}
|
|
|
|
}
|
2021-02-25 06:03:44 +00:00
|
|
|
for (const [key,value] of ingred.get("ids").get("maxRolls")) {
|
2021-01-19 17:32:27 +00:00
|
|
|
if (value && value != 0) {
|
2021-02-25 06:03:44 +00:00
|
|
|
let rolls = [ingred.get("ids").get("minRolls").get(key), value];
|
2021-01-29 22:11:57 +00:00
|
|
|
rolls = rolls.map(x => Math.floor(x * eff_mult)).sort(function(a, b){return a - b});
|
2021-01-19 17:32:27 +00:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-20 05:59:17 +00:00
|
|
|
for (const d in statMap.get("durability")) {
|
2021-01-30 08:50:25 +00:00
|
|
|
if(statMap.get("durability")[d] < 1) { statMap.get("durability")[d] = 1;}
|
|
|
|
else {
|
|
|
|
statMap.get("durability")[d] = Math.floor(statMap.get("durability")[d]);
|
|
|
|
}
|
2021-01-20 05:59:17 +00:00
|
|
|
}
|
|
|
|
for (const d in statMap.get("duration")) {
|
2021-02-03 17:47:48 +00:00
|
|
|
if(!allNone && statMap.get("duration")[d] < 10) { statMap.get("duration")[d] = 10;}
|
2021-01-20 05:59:17 +00:00
|
|
|
}
|
|
|
|
if(statMap.has("charges") && statMap.get("charges") < 1 ) { statMap.set("charges",1)}
|
2021-01-30 08:50:25 +00:00
|
|
|
|
|
|
|
statMap.set("reqs",[0,0,0,0,0]);
|
|
|
|
statMap.set("skillpoints", [0,0,0,0,0]);
|
|
|
|
for (const e in skp_order) {
|
|
|
|
statMap.set(skp_order[e], statMap.get("maxRolls").has(skp_order[e]) ? statMap.get("maxRolls").get(skp_order[e]) : 0);
|
|
|
|
statMap.get("skillpoints")[e] = statMap.get("maxRolls").has(skp_order[e]) ? statMap.get("maxRolls").get(skp_order[e]) : 0;
|
|
|
|
statMap.get("reqs")[e] = statMap.has(skp_order[e]+"Req") && !consumableTypes.includes(statMap.get("type"))? statMap.get(skp_order[e]+"Req") : 0;
|
|
|
|
}
|
|
|
|
for (const id of rolledIDs) {
|
|
|
|
if (statMap.get("minRolls").has(id)) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
statMap.get("minRolls").set(id,0);
|
|
|
|
statMap.get("maxRolls").set(id,0);
|
|
|
|
}
|
|
|
|
}
|
2021-01-30 11:06:16 +00:00
|
|
|
|
|
|
|
statMap.set("crafted", true);
|
2021-01-19 17:32:27 +00:00
|
|
|
this.statMap = statMap;
|
|
|
|
}
|
2022-07-29 05:48:01 +00:00
|
|
|
|
|
|
|
copy() {
|
|
|
|
return new Craft(this.recipe, this.mat_tiers, this.ingreds, this.atkSpd, this.hash.slice(3));
|
|
|
|
}
|
2021-01-30 11:06:16 +00:00
|
|
|
}
|