From e4068912b1880b84bad193adcaf8e7d420e81af9 Mon Sep 17 00:00:00 2001 From: ferricles Date: Fri, 15 Jan 2021 10:49:24 -0800 Subject: [PATCH] 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 @@
-
+ -