Fix skillpoint weapon bug for real, formatting changes

This commit is contained in:
b 2021-01-09 17:31:14 -06:00
parent b1f01b83a2
commit 231b045960
4 changed files with 28 additions and 21 deletions

View file

@ -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];
}

View file

@ -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');

View file

@ -25,7 +25,7 @@
<div class="center" style="grid-column:1;grid-row:1">
<div>
<label for="helmet-choice">Helmet:</label>
<input list="helmet-items" id="helmet-choice" name="helmet-choice" value="No Helmet"/>
<input list="helmet-items" id="helmet-choice" name="helmet-choice" placeholder="No Helmet"/>
<datalist id="helmet-items">
</datalist>
</div>
@ -40,7 +40,7 @@
<div class="center" style="grid-column:2;grid-row:1">
<div>
<label for="chestplate-choice">Chestplate:</label>
<input list="chestplate-items" id="chestplate-choice" name="chestplate-choice" value="No Chestplate"/>
<input list="chestplate-items" id="chestplate-choice" name="chestplate-choice" placeholder="No Chestplate"/>
<datalist id="chestplate-items">
</datalist>
</div>
@ -55,7 +55,7 @@
<div class="center" style="grid-column:3;grid-row:1">
<div>
<label for="leggings-choice">Leggings:</label>
<input list="leggings-items" id="leggings-choice" name="leggings-choice" value="No Leggings"/>
<input list="leggings-items" id="leggings-choice" name="leggings-choice" placeholder="No Leggings"/>
<datalist id="leggings-items">
</datalist>
</div>
@ -70,7 +70,7 @@
<div class="center" style="grid-column:4;grid-row:1">
<div id="boots">
<label for="boots-choice">Boots:</label>
<input list="boots-items" id="boots-choice" name="boots-choice" value="No Boots"/>
<input list="boots-items" id="boots-choice" name="boots-choice" placeholder="No Boots"/>
<datalist id="boots-items">
</datalist>
</div>
@ -84,31 +84,31 @@
</div>
<div class="center" style="grid-column:1;grid-row:2">
<label for="ring1-choice">Ring 1:</label>
<input list="ring1-items" id="ring1-choice" name="ring1-choice" value="No Ring 1"/>
<input list="ring1-items" id="ring1-choice" name="ring1-choice" placeholder="No Ring 1"/>
<datalist id="ring1-items">
</datalist>
</div>
<div class="center" style="grid-column:2;grid-row:2">
<label for="ring2-choice">Ring 2:</label>
<input list="ring2-items" id="ring2-choice" name="ring2-choice" value="No Ring 2"/>
<input list="ring2-items" id="ring2-choice" name="ring2-choice" placeholder="No Ring 2"/>
<datalist id="ring2-items">
</datalist>
</div>
<div class="center" style="grid-column:3;grid-row:2">
<label for="bracelet-choice">Bracelet:</label>
<input list="bracelet-items" id="bracelet-choice" name="bracelet-choice" value="No Bracelet"/>
<input list="bracelet-items" id="bracelet-choice" name="bracelet-choice" placeholder="No Bracelet"/>
<datalist id="bracelet-items">
</datalist>
</div>
<div class="center" style="grid-column:4;grid-row:2">
<label for="necklace-choice">Necklace:</label>
<input list="necklace-items" id="necklace-choice" name="necklace-choice" value="No Necklace"/>
<input list="necklace-items" id="necklace-choice" name="necklace-choice" placeholder="No Necklace"/>
<datalist id="necklace-items">
</datalist>
</div>
<div class="center" style="grid-column:1;grid-row:3">
<label for="weapon-choice">Weapon:</label><br>
<input list="weapon-items" id="weapon-choice" name="weapon-choice" value=""/>
<input list="weapon-items" id="weapon-choice" name="weapon-choice" placeholder="No Weapon"/>
<datalist id="weapon-items">
</datalist>
</div>

View file

@ -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) {