diff --git a/build.js b/build.js index cb87ae8..6a14ee0 100644 --- a/build.js +++ b/build.js @@ -49,58 +49,67 @@ class Build{ /*Construct a build. */ - constructor(level,helmet,chestplate,leggings,boots,ring1,ring2,bracelet,necklace,weapon,powders){ + constructor(level,equipment, powders){ // NOTE: powders is just an array of arrays of powder IDs. Not powder objects. this.powders = powders - if(helmet.type.valueOf() != "helmet".valueOf()){ - throw new TypeError("No such helmet named ", helmet.name); - }else{ + if(itemMap.get(equipment[0]) && itemMap.get(equipment[0]).type === "helmet") { + const helmet = itemMap.get(equipment[0]); this.powders[0] = this.powders[0].slice(0,helmet.slots); this.helmet = expandItem(helmet, this.powders[0]); - } - if(chestplate.type.valueOf() != "chestplate"){ - throw new TypeError("No such chestplate named ", chestplate.name); }else{ + throw new TypeError("No such helmet named ", equipment[0]); + } + if(itemMap.get(equipment[1]).type === "chestplate") { + const chestplate = itemMap.get(equipment[1]); this.powders[1] = this.powders[1].slice(0,chestplate.slots); this.chestplate = expandItem(chestplate, this.powders[1]); - } - if(leggings.type.valueOf() != "leggings"){ - throw new TypeError("No such leggings named ", leggings.name); }else{ + throw new TypeError("No such chestplate named ", equipment[1]); + } + if(itemMap.get(equipment[2]).type === "leggings") { + const leggings = itemMap.get(equipment[2]); this.powders[2] = this.powders[2].slice(0,leggings.slots); this.leggings = expandItem(leggings, this.powders[2]); - } - if(boots.type.valueOf() != "boots"){ - throw new TypeError("No such boots named ", boots.name); }else{ + throw new TypeError("No such leggings named ", equipment[2]); + } + if(itemMap.get(equipment[3]).type === "boots") { + const boots = itemMap.get(equipment[3]); this.powders[3] = this.powders[3].slice(0,boots.slots); this.boots = expandItem(boots, this.powders[3]); - } - if(ring1.type.valueOf() != "ring"){ - throw new TypeError("No such ring named ", ring1.name); }else{ - this.ring1 = expandItem(ring1, []); + throw new TypeError("No such boots named ", equipment[3]); } - if(ring2.type.valueOf() != "ring"){ - throw new TypeError("No such ring named ", ring2.name); + if(itemMap.get(equipment[4]).type === "ring") { + const ring = itemMap.get(equipment[4]); + this.ring1 = expandItem(ring, []) }else{ - this.ring2 = expandItem(ring2, []); + throw new TypeError("No such ring named ", equipment[4]); } - if(bracelet.type.valueOf() != "bracelet"){ - throw new TypeError("No such bracelet named ", bracelet.name); + if(itemMap.get(equipment[5]).type === "ring") { + const ring = itemMap.get(equipment[5]); + this.ring2 = expandItem(ring, []) }else{ - this.bracelet = expandItem(bracelet, []); + throw new TypeError("No such ring named ", equipment[5]); } - if(necklace.type.valueOf() != "necklace"){ - throw new TypeError("No such necklace named ", necklace.name); + if(itemMap.get(equipment[6]).type === "bracelet") { + const bracelet = itemMap.get(equipment[6]); + this.bracelet = expandItem(bracelet, []) }else{ - this.necklace = expandItem(necklace, []); + throw new TypeError("No such bracelet named ", equipment[6]); } - if(weapon.type.valueOf() == "wand" || weapon.type.valueOf() == "bow" || weapon.type.valueOf() == "dagger" || weapon.type.valueOf() == "spear" || weapon.type.valueOf() == "relik"){ + if(itemMap.get(equipment[7]).type === "necklace") { + const necklace = itemMap.get(equipment[7]); + this.necklace = expandItem(necklace, []) + }else{ + throw new TypeError("No such necklace named ", equipment[7]); + } + if(itemMap.get(equipment[8]).category === "weapon") { + const weapon = itemMap.get(equipment[8]); this.powders[4] = this.powders[4].slice(0,weapon.slots); this.weapon = expandItem(weapon, this.powders[4]); }else{ - throw new TypeError("No such weapon named ", weapon.name); + throw new TypeError("No such weapon named ", equipment[8]); } if(level < 1){ //Should these be constants? this.level = 1; @@ -162,7 +171,10 @@ class Build{ } // 0 for melee damage. - let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], stats.get("mdRaw"), stats.get("mdPct"), 0, this.weapon, this.damageMultiplier, this.total_skillpoints); + let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], stats.get("mdRaw"), stats.get("mdPct"), 0, this.weapon, this.total_skillpoints); + + //TODO: Account for strength (this.damageMultiplier). + let totalDamNorm = results[0]; let totalDamCrit = results[1]; let damages_results = results[2]; diff --git a/damage_calc.js b/damage_calc.js index 18f6958..93ba751 100644 --- a/damage_calc.js +++ b/damage_calc.js @@ -1,6 +1,6 @@ // Calculate spell damage given a spell elemental conversion table, and a spell multiplier. // If spell mult is 0, its melee damage and we don't multiply by attack speed. -function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, spellMultiplier, weapon, damageMultiplier, total_skillpoints) { +function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, spellMultiplier, weapon, total_skillpoints) { // Array of neutral + ewtfa damages. Each entry is a pair (min, max). let damages = []; for (const damage_string of stats.get("damageRaw")) { @@ -42,7 +42,7 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, damages[0][1] *= neutralRemaining / 100; console.log(damages); - let damageMult = damageMultiplier; + let damageMult = 1; // If we are doing melee calculations: if (spellMultiplier == 0) { spellMultiplier = 1; @@ -77,9 +77,7 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, totalDamCrit[0] += damages_results[i][2]; totalDamCrit[1] += damages_results[i][3]; } - for (let i in damages_results[0]) { - // Never account for attack speed. - damages_results[0][i] += rawModifier * damageMultiplier; - } + damages_results[0][0] += rawModifier; + damages_results[0][1] += rawModifier; return [totalDamNorm, totalDamCrit, damages_results]; } diff --git a/display.js b/display.js index 2008c7d..0e3ac75 100644 --- a/display.js +++ b/display.js @@ -60,7 +60,7 @@ function displayExpandedItem(item, parent_id){ stats.set("atkSpd", item.get("atkSpd")); stats.set("damageBonus", [0, 0, 0, 0, 0]); stats.set("damageRaw", [item.get("nDam"), item.get("eDam"), item.get("tDam"), item.get("wDam"), item.get("fDam"), item.get("aDam")]); - let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, item, 1, [0, 0, 0, 0, 0]); + let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, item, [0, 0, 0, 0, 0]); let damages = results[2]; let damage_keys = [ "nDam_", "eDam_", "tDam_", "wDam_", "fDam_", "aDam_" ]; for (const i in damage_keys) { @@ -76,8 +76,8 @@ function displayExpandedItem(item, parent_id){ "#ldiv", "!elemental", "hp", - "nDam_", "eDam_", "tDam_", "wDam_", "fDam_", "aDam_", - "eDef", "tDef", "wDef", "fDef", "aDef", + "nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_", + "fDef", "wDef", "aDef", "tDef", "eDef", "!elemental", "#ldiv", "classReq", @@ -98,8 +98,8 @@ function displayExpandedItem(item, parent_id){ "spd", "atkTier", "!elemental", - "eDamPct", "tDamPct", "wDamPct", "fDamPct", "aDamPct", - "eDefPct", "tDefPct", "wDefPct", "fDefPct", "aDefPct", + "fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct", + "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "!elemental", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "rainbowRaw", @@ -115,7 +115,7 @@ function displayExpandedItem(item, parent_id){ "quest", "restrict"]; - let idPrefixes = {"displayName": "", "lvl":"Combat Level Min: ", "classReq":"Class Req: ","strReq":"Strength Min: ","dexReq":"Dexterity Min: ","intReq":"Intelligence Min: ","defReq":"Defense Min: ","agiReq":"Agility Min: ", "nDam_":"Neutral Damage: ", "eDam_":"Earth Damage: ", "tDam_":"Thunder Damage: ", "wDam_":"Water Damage: ", "fDam_":"Fire Damage: ", "aDam_":"Air Damage: ", "atkSpd":"Attack Speed: ", "hp":"Health : ", "eDef":"Earth Defense: ", "tDef":"Thunder Defense: ", "wDef":"Water Defense: ", "fDef":"Fire Defense: ", "aDef":"Air Defense: ", "str":"Strength: ", "dex":"Dexterity: ", "int":"Intelligence: ", "def":"Defense: ","agi":"Agility: ", "hpBonus":"Health Bonus: ", "hprRaw":"Health Regen Raw: ", "hprPct":"Health Regen %: ", "sdRaw":"Raw Spell Damage: ", "sdPct":"Spell Damage %: ", "mdRaw":"Main Attack Neutral Damage: ", "mdPct":"Main Attack Damage %: ", "mr":"Mana Regen: ", "ms":"Mana Steal: ", "ref":"Reflection: ", "ls":"Life Steal: ", "poison":"Poison: ", "thorns":"Thorns: ", "exploding":"Expoding: ", "spd":"Walk Speed Bonus: ", "atkTier":"Attack Speed Bonus: ", "eDamPct":"Earth Damage %: ", "tDamPct":"Thunder Damage %: ", "wDamPct":"Water Damage %: ", "fDamPct":"Fire Damage %: ", "aDamPct":"Air Damage %: ", "eDefPct":"Earth Defense %: ", "tDefPct":"Thunder Defense %: ", "wDefPct":"Water Defense %: ", "fDefPct":"Fire Defense %: ", "aDefPct":"Air Defense %: ", "spPct1":"1st Spell Cost %: ", "spRaw1":"1st Spell Cost Raw: ", "spPct2":"2nd Spell Cost %: ", "spRaw2":"2nd Spell Cost Raw: ", "spPct3":"3rd Spell Cost %: ", "spRaw3":"3rd Spell Cost Raw: ", "spPct4":"4th Spell Cost %: ", "spRaw4":"4th Spell Cost Raw: ", "rainbowRaw":"Rainbow Spell Damage Raw: ", "sprint":"Sprint Bonus: ", "sprintReg":"Sprint Regen Bonus: ", "jh":"Jump Height: ", "xpb":"Combat XP Bonus: ", "lb":"Loot Bonus: ", "lq":"Loot Quality: ", "spRegen":"Soul Point Regen: ", "eSteal":"Stealing: ", "gXp":"Gathering XP Bonus: ", "gSpd":"Gathering Speed Bonus: ", "slots":"Powder Slots: ", "set":"Set: ", "quest":"Quest Req: ", "restrict":""}; + let idPrefixes = {"displayName": "", "lvl":"Combat Level Min: ", "classReq":"Class Req: ","strReq":"Strength Min: ","dexReq":"Dexterity Min: ","intReq":"Intelligence Min: ","defReq":"Defense Min: ","agiReq":"Agility Min: ", "nDam_":"Neutral Damage: ", "eDam_":"Earth Damage: ", "tDam_":"Thunder Damage: ", "wDam_":"Water Damage: ", "fDam_":"Fire Damage: ", "aDam_":"Air Damage: ", "atkSpd":"Attack Speed: ", "hp":"Health : ", "eDef":"Earth Defense: ", "tDef":"Thunder Defense: ", "wDef":"Water Defense: ", "fDef":"Fire Defense: ", "aDef":"Air Defense: ", "str":"Strength: ", "dex":"Dexterity: ", "int":"Intelligence: ", "def":"Defense: ","agi":"Agility: ", "hpBonus":"Health Bonus: ", "hprRaw":"Health Regen Raw: ", "hprPct":"Health Regen %: ", "sdRaw":"Raw Spell Damage: ", "sdPct":"Spell Damage %: ", "mdRaw":"Main Attack Neutral Damage: ", "mdPct":"Main Attack Damage %: ", "mr":"Mana Regen: ", "ms":"Mana Steal: ", "ref":"Reflection: ", "ls":"Life Steal: ", "poison":"Poison: ", "thorns":"Thorns: ", "exploding":"Exploding: ", "spd":"Walk Speed Bonus: ", "atkTier":"Attack Speed Bonus: ", "eDamPct":"Earth Damage %: ", "tDamPct":"Thunder Damage %: ", "wDamPct":"Water Damage %: ", "fDamPct":"Fire Damage %: ", "aDamPct":"Air Damage %: ", "eDefPct":"Earth Defense %: ", "tDefPct":"Thunder Defense %: ", "wDefPct":"Water Defense %: ", "fDefPct":"Fire Defense %: ", "aDefPct":"Air Defense %: ", "spPct1":"1st Spell Cost %: ", "spRaw1":"1st Spell Cost Raw: ", "spPct2":"2nd Spell Cost %: ", "spRaw2":"2nd Spell Cost Raw: ", "spPct3":"3rd Spell Cost %: ", "spRaw3":"3rd Spell Cost Raw: ", "spPct4":"4th Spell Cost %: ", "spRaw4":"4th Spell Cost Raw: ", "rainbowRaw":"Rainbow Spell Damage Raw: ", "sprint":"Sprint Bonus: ", "sprintReg":"Sprint Regen Bonus: ", "jh":"Jump Height: ", "xpb":"Combat XP Bonus: ", "lb":"Loot Bonus: ", "lq":"Loot Quality: ", "spRegen":"Soul Point Regen: ", "eSteal":"Stealing: ", "gXp":"Gathering XP Bonus: ", "gSpd":"Gathering Speed Bonus: ", "slots":"Powder Slots: ", "set":"Set: ", "quest":"Quest Req: ", "restrict":""}; let idSuffixes = {"displayName": "", "lvl":"", "classReq":"","strReq":"","dexReq":"","intReq":"","defReq":"","agiReq":"", "nDam_":"", "eDam_":"", "tDam_":"", "wDam_":"", "fDam_":"", "aDam_":"", "atkSpd":"", "hp":"", "eDef":"", "tDef":"", "wDef":"", "fDef":"", "aDef":"", "str":"", "dex":"", "int":"", "def":"","agi":"", "hpBonus":"", "hprRaw":"", "hprPct":"%", "sdRaw":"", "sdPct":"%", "mdRaw":"", "mdPct":"%", "mr":"/4s", "ms":"/4s", "ref":"%", "ls":"/4s", "poison":"/3s", "thorns":"%", "exploding":"%", "spd":"%", "atkTier":" tier", "eDamPct":"%", "tDamPct":"%", "wDamPct":"%", "fDamPct":"%", "aDamPct":"%", "eDefPct":"%", "tDefPct":"%", "wDefPct":"%", "fDefPct":"%", "aDefPct":"%", "spPct1":"%", "spRaw1":"", "spPct2":"%", "spRaw2":"", "spPct3":"%", "spRaw3":"", "spPct4":"%", "spRaw4":"", "rainbowRaw":"", "sprint":"%", "sprintReg":"%", "jh":"", "xpb":"%", "lb":"%", "lq":"%", "spRegen":"%", "eSteal":"%", "gXp":"%", "gSpd":"%", "slots":"", "set":" set.", "quest":"", "restrict":""}; function apply_elemental_format(p_elem, id, suffix) { @@ -176,7 +176,14 @@ function displayExpandedItem(item, parent_id){ apply_elemental_format(p_elem, id, item.get(id)); } else { - p_elem.textContent = idPrefixes[id].concat(item.get(id), idSuffixes[id]); + if (id === "slots") { + // HACK TO MAKE POWDERS DISPLAY NICE!! TODO + p_elem.textContent = idPrefixes[id].concat(item.get(id), idSuffixes[id]) + + " [ " + item.get("powders").map(x => powderNames.get(x)) + " ]"; + } + else { + p_elem.textContent = idPrefixes[id].concat(item.get(id), idSuffixes[id]); + } } active_elem.appendChild(p_elem); } @@ -212,6 +219,7 @@ function displayExpandedItem(item, parent_id){ let desc_elem = document.createElement('td'); desc_elem.classList.add('center'); + //TODO elemental format jank if (elemental_format) { apply_elemental_format(desc_elem, id); } diff --git a/index.html b/index.html index ab62eda..e23f782 100644 --- a/index.html +++ b/index.html @@ -241,6 +241,24 @@