From 8754b060be6db945ed78df62a4c49a0b8298ff35 Mon Sep 17 00:00:00 2001 From: ferricles Date: Fri, 15 Jan 2021 10:20:17 -0800 Subject: [PATCH 1/4] fixed spell + powder special boosts not unapplying on updating stats or build. --- builder.js | 44 +++++++++++++++++++--------------- display.js | 70 +++++++++++++++++++++++++++++++++++++++++++++++------- index.html | 5 +++- styles.css | 5 +++- 4 files changed, 94 insertions(+), 30 deletions(-) diff --git a/builder.js b/builder.js index 25d0631..ddc406f 100644 --- a/builder.js +++ b/builder.js @@ -389,10 +389,6 @@ function encodeBuild() { function calculateBuild(save_skp, skp){ try { - for (const boost of ["vanish", "warscream", "yourtotem", "allytotem", "bash"]) { - let elem = document.getElementById(boost+"-boost"); - elem.classList.remove("toggleOn"); - } let specialNames = ["Quake", "Chain_Lightning", "Curse", "Courage", "Air_Prison"]; for (const sName of specialNames) { for (let i = 1; i < 6; i++) { @@ -417,6 +413,7 @@ function calculateBuild(save_skp, skp){ } } if(player_build){ + updateBoosts("skip"); updatePowderSpecials("skip"); } //updatePowderSpecials("skip"); //jank pt 1 @@ -508,11 +505,7 @@ function calculateBuild(save_skp, skp){ /* Updates all build statistics based on (for now) the skillpoint input fields and then calculates build stats. */ function updateStats() { - //direct copy of the ext buff un-check code from calculateBuild(). Redo if possible. - for (const boost of ["vanish", "warscream", "yourtotem", "allytotem", "bash"]) { - let elem = document.getElementById(boost+"-boost"); - elem.classList.remove("toggleOn"); - } + let specialNames = ["Quake", "Chain_Lightning", "Curse", "Courage", "Air_Prison"]; for (const sName of specialNames) { for (let i = 1; i < 6; i++) { @@ -536,9 +529,7 @@ function updateStats() { } } } - if(player_build){ - updatePowderSpecials("skip"); - } + //WILL BREAK WEBSITE IF NO BUILD HAS BEEN INITIALIZED! @HPP let skillpoints = player_build.total_skillpoints; @@ -561,12 +552,17 @@ function updateStats() { } player_build.assigned_skillpoints += delta_total; calculateBuildStats(); + if(player_build){ + updatePowderSpecials("skip"); + updateBoosts("skip"); + } } /* Updates all spell boosts */ function updateBoosts(buttonId) { - let elem = document.getElementById(buttonId); - let name = buttonId.split("-")[0]; + let elem = document.getElementById(buttonId); + let name = buttonId.split("-")[0]; + if(buttonId !== "skip") { if (elem.classList.contains("toggleOn")) { player_build.damageMultiplier -= damageMultipliers.get(name); if (name === "warscream") { @@ -581,6 +577,16 @@ function updateBoosts(buttonId) { elem.classList.add("toggleOn"); } updatePowderSpecials("skip"); //jank pt 1 + } else { + for (const [key, value] of damageMultipliers) { + let elem = document.getElementById(key + "-boost") + if (elem.classList.contains("toggleOn")) { + elem.classList.remove("toggleOn"); + player_build.damageMultiplier -= value; + if (key === "warscream") { player_build.defenseMultiplier -= .10 } + } + } + } calculateBuildStats(); } @@ -588,6 +594,7 @@ function updateBoosts(buttonId) { */ function updatePowderSpecials(buttonId){ //console.log(player_build.statMap); + let name = (buttonId).split("-")[0]; let power = (buttonId).split("-")[1]; // [1, 5] let specialNames = ["Quake", "Chain Lightning", "Curse", "Courage", "Air Prison"]; @@ -666,9 +673,7 @@ function updatePowderSpecials(buttonId){ } displayPowderSpecials(document.getElementById("powder-special-stats"), powderSpecials, player_build); - if (name !== "skip") { - calculateBuildStats(); //also make damage boosts apply ;-; - } + calculateBuildStats(); //also make damage boosts apply ;-; } /* Calculates all build statistics and updates the entire display. */ @@ -768,8 +773,9 @@ function calculateBuildStats() { displayExpandedItem(player_build.items[i], buildFields[i]); } - displayBuildStats(player_build, "build-overall-stats"); - displaySetBonuses(player_build, "set-info"); + displayBuildStats("build-overall-stats",player_build); + displaySetBonuses("set-info",player_build); + displayNextCosts("int-info",player_build); let meleeStats = player_build.getMeleeStats(); displayMeleeDamage(document.getElementById("build-melee-stats"), document.getElementById("build-melee-statsAvg"), meleeStats); diff --git a/display.js b/display.js index 13ceb11..e68eea1 100644 --- a/display.js +++ b/display.js @@ -95,7 +95,7 @@ function apply_elemental_format(p_elem, id, suffix) { p_elem.appendChild(i_elem2); } -function displaySetBonuses(build, parent_id) { +function displaySetBonuses(parent_id,build) { setHTML(parent_id, ""); let parent_div = document.getElementById(parent_id); @@ -134,7 +134,7 @@ function displaySetBonuses(build, parent_id) { } } -function displayBuildStats(build, parent_id){ +function displayBuildStats(parent_id,build){ // Commands to "script" the creation of nice formatting. // #commands create a new element. // !elemental is some janky hack for elemental damage. @@ -556,6 +556,54 @@ function displayExpandedItem(item, parent_id){ } } +function displayNextCosts(parent_id, build) { + let p_elem = document.getElementById(parent_id); + let stats = build.statMap; + let int = build.total_skillpoints[2]; + let spells = spell_table[build.weapon.get("type")]; + + p_elem.textContent = ""; + + let title = document.createElement("p"); + title.classList.add("smalltitle"); + title.textContent = "Next Spell Costs"; + + let int_title = document.createElement("p"); + int_title.classList.add("itemp"); + int_title.textContent = int + " Intelligence points."; + + p_elem.append(title); + p_elem.append(int_title); + + for (const spell of spells) { //warp + let spellp = document.createElement("p"); + let spelltitle = document.createElement("p"); + spelltitle.classList.add("itemp"); + spelltitle.textContent = spell.title; + spellp.appendChild(spelltitle); + let row = document.createElement("p"); + row.classList.add("itemp"); + let init_cost = document.createElement("b"); + init_cost.textContent = build.getSpellCost(spells.indexOf(spell) + 1, spell.cost); + init_cost.classList.add("Mana"); + let arrow = document.createElement("b"); + arrow.textContent = "\u279C"; + let next_cost = document.createElement("b"); + next_cost.textContent = (build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) == 1 ? 1 : build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) - 1); + next_cost.classList.add("Mana"); + let int_needed = document.createElement("b"); + int_needed.textContent = ": " + (0) + " int"; //DO MATH + + row.appendChild(init_cost); + row.appendChild(arrow); + row.appendChild(next_cost); + row.appendChild(int_needed); + spellp.appendChild(row); + + p_elem.append(spellp); + } +} + function displayFixedID(active, id, value, elemental_format, style) { if (style) { /*if(reversedIDs.filter(e => e !== "atkTier").includes(id)){ @@ -1132,17 +1180,13 @@ function displaySpellDamage(parent_elem, overallparent_elem, build, spell, spell if (spellIdx != 0) { title_elem.textContent = spell.title + " (" + build.getSpellCost(spellIdx, spell.cost) + ")"; - let first = document.createElement("b"); - first.classList.add("space"); + let first = document.createElement("b"); first.textContent = spell.title + " ("; title_elemavg.appendChild(first); let second = document.createElement("b"); second.textContent = build.getSpellCost(spellIdx, spell.cost); - second.classList.add("Legendary"); + second.classList.add("Mana"); title_elemavg.appendChild(second); - let third = document.createElement("b"); - third.classList.add("Water"); - title_elemavg.appendChild(third); let fourth = document.createElement("b"); fourth.textContent = ")"; title_elemavg.appendChild(fourth); @@ -1270,8 +1314,16 @@ function displaySpellDamage(parent_elem, overallparent_elem, build, spell, spell part_div.append(averageLabel); let overallaverageLabel = document.createElement("p"); - overallaverageLabel.textContent = "Average: "+total_damage.toFixed(2); overallaverageLabel.classList.add("damageSubtitle"); + let overallaverageLabelFirst = document.createElement("b"); + let overallaverageLabelSecond = document.createElement("b"); + overallaverageLabelFirst.textContent = "Average: "; + overallaverageLabelSecond.textContent = total_damage.toFixed(2); + overallaverageLabelSecond.classList.add("Damage"); + + + overallaverageLabel.appendChild(overallaverageLabelFirst); + overallaverageLabel.appendChild(overallaverageLabelSecond); part_divavg.append(overallaverageLabel); } } diff --git a/index.html b/index.html index 136f36d..9cfba0e 100644 --- a/index.html +++ b/index.html @@ -551,9 +551,12 @@
-

Made by hppeng and ferricles with Atlas Inc (JavaScript required to function, nothing works without js)

diff --git a/styles.css b/styles.css index 630b179..0ae4224 100644 --- a/styles.css +++ b/styles.css @@ -78,7 +78,7 @@ a.link{ text-align: left; } -.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order, .build-overall, .build-melee-stats, .build-defense-stats, .spell-info, .set-info, .powder-special, .powder-special-stats { +.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order, .build-overall, .build-melee-stats, .build-defense-stats, .spell-info, .set-info, .powder-special, .powder-special-stats, .int-info { color: #aaa; background: #121516; border: 3px solid #BCBCBC; @@ -161,6 +161,9 @@ a.link{ .Neutral:before { content: "\2724" ' '; } .Damage { color: rgb(255, 198, 85)} +.Mana { color: #5ff;} +.Mana:after { content: "\2749"} + .Health { color: #a00; /*text-shadow: 2px 2px 0 #2a0000;*/ From e4068912b1880b84bad193adcaf8e7d420e81af9 Mon Sep 17 00:00:00 2001 From: ferricles Date: Fri, 15 Jan 2021 10:49:24 -0800 Subject: [PATCH 2/4] implemented next cost intel needed feature --- build.js | 2 +- builder.js | 2 +- display.js | 20 ++++++++++++++++---- index.html | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/build.js b/build.js index 5fdfa33..af00975 100644 --- a/build.js +++ b/build.js @@ -160,7 +160,7 @@ class Build{ getSpellCost(spellIdx, cost) { cost = Math.ceil(cost * (1 - skillPointsToPercentage(this.total_skillpoints[2]))); cost += this.statMap.get("spRaw"+spellIdx); - return Math.max(1, Math.floor(cost * (1 + this.statMap.get("spPct"+spellIdx) / 100))) + return Math.max(1, Math.floor(cost * (1 + this.statMap.get("spPct"+spellIdx) / 100))); } diff --git a/builder.js b/builder.js index ddc406f..95dd4bb 100644 --- a/builder.js +++ b/builder.js @@ -11,7 +11,7 @@ console.log(url_tag); * END testing section */ -const BUILD_VERSION = "6.9.1"; +const BUILD_VERSION = "6.9.2"; function setTitle() { document.getElementById("header").textContent = "WynnBuilder version "+BUILD_VERSION+" (db version "+DB_VERSION+")"; diff --git a/display.js b/display.js index e68eea1..6e257aa 100644 --- a/display.js +++ b/display.js @@ -558,7 +558,6 @@ function displayExpandedItem(item, parent_id){ function displayNextCosts(parent_id, build) { let p_elem = document.getElementById(parent_id); - let stats = build.statMap; let int = build.total_skillpoints[2]; let spells = spell_table[build.weapon.get("type")]; @@ -589,11 +588,24 @@ function displayNextCosts(parent_id, build) { let arrow = document.createElement("b"); arrow.textContent = "\u279C"; let next_cost = document.createElement("b"); - next_cost.textContent = (build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) == 1 ? 1 : build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) - 1); + next_cost.textContent = (init_cost.textContent === "1" ? 1 : build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) - 1); next_cost.classList.add("Mana"); let int_needed = document.createElement("b"); - int_needed.textContent = ": " + (0) + " int"; //DO MATH - + if (init_cost.textContent === "1") { + int_needed.textContent = ": n/a (+0)"; + }else { //do math + let target = build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) - 1; + let needed = int; + //forgive me... I couldn't inverse ceil, floor, and max. + while (build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) != target) { + needed++; + build.total_skillpoints[2] = needed; + } + let missing = needed - int; + build.total_skillpoints[2] = int;//forgive me pt 2 + int_needed.textContent = ": " + needed + " int (+" + missing + ")"; + } + row.appendChild(init_cost); row.appendChild(arrow); row.appendChild(next_cost); diff --git a/index.html b/index.html index 9cfba0e..99b2a8c 100644 --- a/index.html +++ b/index.html @@ -551,10 +551,10 @@
-
+ - From 351b6fc2d4e98fb20028398e1f7ac46b1a428569 Mon Sep 17 00:00:00 2001 From: ferricles Date: Fri, 15 Jan 2021 11:52:11 -0800 Subject: [PATCH 3/4] fixed next spell cost infinite loop + bugs --- damage_calc.js | 1 - display.js | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/damage_calc.js b/damage_calc.js index 2a426ae..b2ef542 100644 --- a/damage_calc.js +++ b/damage_calc.js @@ -99,7 +99,6 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, totalDamCrit[0] += damages_results[i][2]; totalDamCrit[1] += damages_results[i][3]; } - console.log(damages_results); if (melee) { totalDamNorm[0] += Math.max(rawModifier, -damages_results[0][0]); totalDamNorm[1] += Math.max(rawModifier, -damages_results[0][1]); diff --git a/display.js b/display.js index 6e257aa..48c1678 100644 --- a/display.js +++ b/display.js @@ -564,7 +564,8 @@ function displayNextCosts(parent_id, build) { p_elem.textContent = ""; let title = document.createElement("p"); - title.classList.add("smalltitle"); + title.classList.add("title"); + title.classList.add("Normal"); title.textContent = "Next Spell Costs"; let int_title = document.createElement("p"); @@ -597,13 +598,19 @@ function displayNextCosts(parent_id, build) { let target = build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) - 1; let needed = int; //forgive me... I couldn't inverse ceil, floor, and max. - while (build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) != target) { + while (build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) > target) { + if(needed > 150) { + break; + } needed++; build.total_skillpoints[2] = needed; } let missing = needed - int; + //in rare circumstances, the next spell cost can jump. + next_cost.textContent = (init_cost.textContent === "1" ? 1 : build.getSpellCost(spells.indexOf(spell) + 1, spell.cost)); + build.total_skillpoints[2] = int;//forgive me pt 2 - int_needed.textContent = ": " + needed + " int (+" + missing + ")"; + int_needed.textContent = ": " + (needed > 150 ? ">150" : needed) + " int (+" + (needed > 150 ? "n/a" : missing) + ")"; } row.appendChild(init_cost); From a6f8a48e18ddc08ffb625d30a6518993557339ce Mon Sep 17 00:00:00 2001 From: ferricles Date: Fri, 15 Jan 2021 12:36:12 -0800 Subject: [PATCH 4/4] minor spell cost display fix --- display.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/display.js b/display.js index 48c1678..cf73715 100644 --- a/display.js +++ b/display.js @@ -597,9 +597,11 @@ function displayNextCosts(parent_id, build) { }else { //do math let target = build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) - 1; let needed = int; + let noUpdate = false; //forgive me... I couldn't inverse ceil, floor, and max. while (build.getSpellCost(spells.indexOf(spell) + 1, spell.cost) > target) { if(needed > 150) { + noUpdate = true; break; } needed++; @@ -607,7 +609,12 @@ function displayNextCosts(parent_id, build) { } let missing = needed - int; //in rare circumstances, the next spell cost can jump. - next_cost.textContent = (init_cost.textContent === "1" ? 1 : build.getSpellCost(spells.indexOf(spell) + 1, spell.cost)); + if (noUpdate) { + next_cost.textContent = (init_cost.textContent === "1" ? 1 : build.getSpellCost(spells.indexOf(spell) + 1, spell.cost)-1); + }else { + next_cost.textContent = (init_cost.textContent === "1" ? 1 : build.getSpellCost(spells.indexOf(spell) + 1, spell.cost)); + } + build.total_skillpoints[2] = int;//forgive me pt 2 int_needed.textContent = ": " + (needed > 150 ? ">150" : needed) + " int (+" + (needed > 150 ? "n/a" : missing) + ")";