Merge pull request #163 from hppeng-wynn/spellcost_float

Make spellcost floating point
This commit is contained in:
hppeng-wynn 2022-07-22 19:37:44 -07:00 committed by GitHub
commit d655598a1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -866,7 +866,7 @@ function displayNextCosts(_stats, spell, spellIdx) {
let int_needed = document.createElement("b"); let int_needed = document.createElement("b");
if (init_cost.textContent === "1") { if (init_cost.textContent === "1") {
int_needed.textContent = ": n/a (+0)"; int_needed.textContent = ": n/a (+0)";
}else { //do math } else { //do math
let target = getSpellCost(stats, spellIdx, spell.cost) - 1; let target = getSpellCost(stats, spellIdx, spell.cost) - 1;
let needed = intel; let needed = intel;
let noUpdate = false; let noUpdate = false;
@ -1386,10 +1386,9 @@ function getSpellCost(stats, spell) {
} }
function getBaseSpellCost(stats, spell) { function getBaseSpellCost(stats, spell) {
// old intelligence: let cost = spell.cost * (1 - skillPointsToPercentage(stats.get('int')) * skillpoint_final_mult[2]);
let cost = Math.ceil(spell.cost * (1 - skillPointsToPercentage(stats.get('int')) * skillpoint_final_mult[2]));
cost += stats.get("spRaw"+spell.base_spell); cost += stats.get("spRaw"+spell.base_spell);
return Math.floor(cost * (1 + stats.get("spPct"+spell.base_spell) / 100)); return cost * (1 + stats.get("spPct"+spell.base_spell) / 100);
} }
@ -1408,7 +1407,7 @@ function displaySpellDamage(parent_elem, overallparent_elem, stats, spell, spell
title_elem.appendChild(first.cloneNode(true)); //cloneNode is needed here. title_elem.appendChild(first.cloneNode(true)); //cloneNode is needed here.
title_elemavg.appendChild(first); title_elemavg.appendChild(first);
let second = make_elem("span", ["Mana"], { textContent: getSpellCost(stats, spell) }); let second = make_elem("span", ["Mana"], { textContent: getSpellCost(stats, spell).toFixed(2) });
title_elem.appendChild(second.cloneNode(true)); title_elem.appendChild(second.cloneNode(true));
title_elemavg.appendChild(second); title_elemavg.appendChild(second);
@ -1425,7 +1424,6 @@ function displaySpellDamage(parent_elem, overallparent_elem, stats, spell, spell
overallparent_elem.append(title_elemavg); overallparent_elem.append(title_elemavg);
// if ('cost' in spell) { // if ('cost' in spell) {
// :( ...... ?
// overallparent_elem.append(displayNextCosts(stats, spell, spellIdx)); // overallparent_elem.append(displayNextCosts(stats, spell, spellIdx));
// } // }