From 231b0459602a09dd8bd2f6c31d5f792193bc02e6 Mon Sep 17 00:00:00 2001 From: b Date: Sat, 9 Jan 2021 17:31:14 -0600 Subject: [PATCH] Fix skillpoint weapon bug for real, formatting changes --- damage_calc.js | 6 +++++- display.js | 16 ++++++++-------- index.html | 18 +++++++++--------- skillpoints.js | 9 ++++++--- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/damage_calc.js b/damage_calc.js index 17195e9..cbb03a1 100644 --- a/damage_calc.js +++ b/damage_calc.js @@ -64,7 +64,7 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, } for (let i in damages) { - let damageBoost = 1 + skillBoost[i] + staticBoost; + let damageBoost = Math.max(1 + skillBoost[i] + staticBoost, 0); damages_results.push([ Math.max(damages[i][0] * damageBoost * damageMult, 0), // Normal min Math.max(damages[i][1] * damageBoost * damageMult, 0), // Normal max @@ -80,6 +80,10 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, damages_results[0][1] += rawModifier; damages_results[0][2] += rawModifier; damages_results[0][3] += rawModifier; + if (totalDamNorm[0] < 0) totalDamNorm[0] = 0; + if (totalDamNorm[1] < 0) totalDamNorm[1] = 0; + if (totalDamCrit[0] < 0) totalDamCrit[0] = 0; + if (totalDamCrit[1] < 0) totalDamCrit[1] = 0; return [totalDamNorm, totalDamCrit, damages_results]; } diff --git a/display.js b/display.js index b619a3b..95684e9 100644 --- a/display.js +++ b/display.js @@ -1,7 +1,7 @@ let nonRolledIDs = ["name", "displayName", "tier", "set", "slots", "type", "material", "drop", "quest", "restrict", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "atkSpd", "hp", "fDef", "wDef", "aDef", "tDef", "eDef", "lvl", "classReq", "strReq", "dexReq", "intReq", "defReq", "agiReq","str", "dex", "int", "agi", "def", "fixID", "category", "id", "skillpoints", "reqs", "nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_"]; let rolledIDs = ["hprPct", "mr", "sdPct", "mdPct", "ls", "ms", "xpb", "lb", "ref", "thorns", "expd", "spd", "atkTier", "poison", "hpBonus", "spRegen", "eSteal", "hprRaw", "sdRaw", "mdRaw", "fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct", "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "rainbowRaw", "sprint", "sprintReg", "jh", "lq", "gXp", "gSpd"]; -let reversedIDs = [ "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4" ]; +let reversedIDs = [ "atkTier", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4" ]; function expandItem(item, powders){ let minRolls = new Map(); @@ -260,7 +260,12 @@ function displayExpandedItem(item, parent_id){ else { let id = command; if(nonRolledIDs.includes(id) && item.get(id)){//nonRolledID & non-0/non-null/non-und ID - displayFixedID(active_elem, id, item.get(id), elemental_format); + let p_elem = displayFixedID(active_elem, id, item.get(id), elemental_format); + 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 if(rolledIDs.includes(id)&& item.get("minRolls").get(id)){ // && item.get("maxRolls").get(id) ){//rolled ID & non-0/non-null/non-und ID let style = "positive"; @@ -268,12 +273,7 @@ function displayExpandedItem(item, parent_id){ style = "negative"; } if (fix_id) { - let p_elem = displayFixedID(active_elem, id, item.get("minRolls").get(id), elemental_format, style); - if (id === "slots") { - // HACK TO MAKE POWDERS DISPLAY NICE!! TODO - p_elem.textContent = idPrefixes[id].concat(value, idSuffixes[id]) + - " [ " + item.get("powders").map(x => powderNames.get(x)) + " ]"; - } + displayFixedID(active_elem, id, item.get("minRolls").get(id), elemental_format, style); } else { let row = document.createElement('tr'); diff --git a/index.html b/index.html index d940742..3a7677e 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@
- +
@@ -40,7 +40,7 @@
- +
@@ -55,7 +55,7 @@
- +
@@ -70,7 +70,7 @@
- +
@@ -84,31 +84,31 @@
- +
- +
- +
- +

- +
diff --git a/skillpoints.js b/skillpoints.js index 85a768a..f783807 100644 --- a/skillpoints.js +++ b/skillpoints.js @@ -35,7 +35,7 @@ function calculate_skillpoints(equipment, weapon) { let applied = [0, 0, 0, 0, 0]; let total = 0; for (let i = 0; i < 5; i++) { - if (item.get("skillpoints")[i] < 0 && skillpoint_filter[i]) { + if (item.get("skillpoints")[i] < 0 && skillpoint_filter[i] === true) { applied[i] -= item.get("skillpoints")[i]; total -= item.get("skillpoints")[i]; } @@ -121,7 +121,8 @@ function calculate_skillpoints(equipment, weapon) { // } // } // } - result = apply_to_fit(skillpoints, weapon, allFalse); + let pre = skillpoints.slice(); + result = apply_to_fit(skillpoints, weapon, allFalse.slice()); needed_skillpoints = result[0]; total_diff = result[1]; for (let i = 0; i < 5; ++i) { @@ -133,6 +134,8 @@ function calculate_skillpoints(equipment, weapon) { total_applied += total_diff; if (total_applied < best_total) { + console.log(pre); + console.log(skillpoints); best = permutation; final_skillpoints = skillpoints; best_skillpoints = skillpoints_applied; @@ -143,7 +146,7 @@ function calculate_skillpoints(equipment, weapon) { } else { best_total = 0; - result = apply_to_fit(final_skillpoints, weapon); + result = apply_to_fit(final_skillpoints, weapon, allFalse.slice()); needed_skillpoints = result[0]; total_diff = result[1]; for (let i = 0; i < 5; ++i) {