fixed skill points with all fixed + weapon reqs, added skillpoint related warnings, refactored code
This commit is contained in:
parent
24de737a4b
commit
85e255ee59
4 changed files with 59 additions and 37 deletions
5
build.js
5
build.js
|
@ -137,7 +137,6 @@ class Build{
|
|||
Returns an array in the order:
|
||||
*/
|
||||
getMeleeStats(){
|
||||
|
||||
const stats = this.statMap;
|
||||
// Array of neutral + ewtfa damages. Each entry is a pair (min, max).
|
||||
let damages = [];
|
||||
|
@ -168,10 +167,8 @@ class Build{
|
|||
for (let i in this.total_skillpoints) {
|
||||
skillBoost.push(skillPointsToPercentage(this.total_skillpoints[i]) + stats.get("damageBonus")[i] / 100.);
|
||||
}
|
||||
console.log(skillBoost);
|
||||
for (let i in damages) {
|
||||
let damageBoost = 1 + skillBoost[i] + staticBoost;
|
||||
console.log(damageBoost);
|
||||
damages_results.push([
|
||||
Math.round(damages[i][0] * damageBoost), // Normal min
|
||||
Math.round(damages[i][1] * damageBoost), // Normal max
|
||||
|
@ -192,7 +189,7 @@ class Build{
|
|||
let critDPS = (totalDamCrit[0]+totalDamCrit[1])/2 * baseDamageMultiplier[adjAtkSpd];
|
||||
let avgDPS = (normDPS * (1 - skillPointsToPercentage(dex))) + (critDPS * (skillPointsToPercentage(dex))) + (poison / 3.0 * (1 + skillPointsToPercentage(str)));
|
||||
//console.log([nDamAdj,eDamAdj,tDamAdj,wDamAdj,fDamAdj,aDamAdj,totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS]);
|
||||
return damages_results.concat([totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS]);
|
||||
return damages_results.concat([totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS,adjAtkSpd]);
|
||||
}
|
||||
|
||||
/* Get all stats for this build. Stores in this.statMap.
|
||||
|
|
|
@ -233,9 +233,9 @@
|
|||
</div>
|
||||
<div class = "center build-order" id = "build-order" style = "grid-column:2;grid-row:3">
|
||||
</div>
|
||||
<div class = "center" id = "build-cumulative-stats" style = "grid-column:3;grid-row:3">
|
||||
<div class = "center" id = "build-melee-stats" style = "grid-column:3;grid-row:3">
|
||||
</div>
|
||||
<div class = "center" id = "defense-damage-stats" style = "grid-column:4;grid-row:3">
|
||||
<div class = "center" id = "build-defense-stats" style = "grid-column:4;grid-row:3">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
let fixed = [];
|
||||
let consider = [];
|
||||
let noboost = [];
|
||||
|
||||
console.log(equipment);
|
||||
for (const item of equipment) {
|
||||
if (item.reqs.every(x => x === 0)) {
|
||||
fixed.push(item);
|
||||
|
@ -69,7 +69,6 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
let has_skillpoint = [false, false, false, false, false];
|
||||
|
||||
permutation = permutation.concat(noboost);
|
||||
console.log(permutation);
|
||||
|
||||
let skillpoints_applied = [0, 0, 0, 0, 0];
|
||||
// Complete slice is a shallow copy.
|
||||
|
@ -144,6 +143,32 @@ function calculate_skillpoints(equipment, weapon) {
|
|||
return [equip_order, best_skillpoints, final_skillpoints, best_total];
|
||||
}
|
||||
else {
|
||||
return [fixed.concat(noboost), best_skillpoints, static_skillpoints_base, 0];
|
||||
//Temporary fix: please verify
|
||||
let has_skillpoint = [false,false,false,false,false]
|
||||
let skillpoints_applied = [0, 0, 0, 0, 0];
|
||||
let skillpoints = static_skillpoints_base.slice();
|
||||
let total_applied = 0;
|
||||
let result;
|
||||
let needed_skillpoints;
|
||||
let total_diff;
|
||||
result = apply_to_fit(skillpoints, weapon, has_skillpoint);
|
||||
needed_skillpoints = result[0];
|
||||
total_diff = result[1];
|
||||
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
skillpoints_applied[i] += needed_skillpoints[i];
|
||||
skillpoints[i] += needed_skillpoints[i];
|
||||
}
|
||||
|
||||
apply_skillpoints(skillpoints, weapon);
|
||||
total_applied += total_diff;
|
||||
|
||||
if (total_applied < best_total) {
|
||||
best = [weapon];
|
||||
final_skillpoints = skillpoints;
|
||||
best_skillpoints = skillpoints_applied;
|
||||
best_total = total_applied;
|
||||
}
|
||||
return [ best ? best : fixed.concat(noboost) , best_skillpoints, final_skillpoints ? final_skillpoints : static_skillpoints_base, best_total ? best_total : 0];
|
||||
}
|
||||
}
|
||||
|
|
56
test.js
56
test.js
|
@ -271,31 +271,26 @@ function calculateBuild(){
|
|||
setHTML("build-order", equip_order_text);
|
||||
|
||||
const assigned = player_build.base_skillpoints;
|
||||
setText("str-skp-assign", "Before Boosts: " + assigned[0]);
|
||||
setText("dex-skp-assign", "Before Boosts: " + assigned[1]);
|
||||
setText("int-skp-assign", "Before Boosts: " + assigned[2]);
|
||||
setText("def-skp-assign", "Before Boosts: " + assigned[3]);
|
||||
setText("agi-skp-assign", "Before Boosts: " + assigned[4]);
|
||||
|
||||
const skillpoints = player_build.total_skillpoints;
|
||||
setValue("str-skp", skillpoints[0]);
|
||||
setValue("dex-skp", skillpoints[1]);
|
||||
setValue("int-skp", skillpoints[2]);
|
||||
setValue("def-skp", skillpoints[3]);
|
||||
setValue("agi-skp", skillpoints[4]);
|
||||
setText("str-skp-base", "Original Value: " + skillpoints[0]);
|
||||
setText("dex-skp-base", "Original Value: " + skillpoints[1]);
|
||||
setText("int-skp-base", "Original Value: " + skillpoints[2]);
|
||||
setText("def-skp-base", "Original Value: " + skillpoints[3]);
|
||||
setText("agi-skp-base", "Original Value: " + skillpoints[4]);
|
||||
console.log("????");
|
||||
setHTML("str-skp-pct", (skillPointsToPercentage(skillpoints[0])*100).toFixed(1).concat("% more damage dealt."));
|
||||
setHTML("dex-skp-pct", (skillPointsToPercentage(skillpoints[1])*100).toFixed(1).concat("% chance to crit."));
|
||||
setHTML("int-skp-pct", (skillPointsToPercentage(skillpoints[2])*100).toFixed(1).concat("% spell cost reduction."));
|
||||
setHTML("def-skp-pct", (skillPointsToPercentage(skillpoints[3])*100).toFixed(1).concat("% less damage taken."));
|
||||
setHTML("agi-skp-pct", (skillPointsToPercentage(skillpoints[4])*100).toFixed(1).concat("% chance to dodge."));
|
||||
|
||||
setText("summary-box", "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints.");
|
||||
let skp_order = ["str","dex","int","def","agi"];
|
||||
let skp_effects = ["% more damage dealt.","% chance to crit.","% spell cost reduction.","% less damage taken.","% chance to dodge."];
|
||||
for (let i in skp_order){ //big bren
|
||||
setText(skp_order[i] + "-skp-assign", "Before Boosts: " + assigned[i]);
|
||||
setValue(skp_order[i] + "-skp", skillpoints[i]);
|
||||
if(assigned[i] <= 100){
|
||||
setText(skp_order[i] + "-skp-base", "Original Value: " + skillpoints[i]);
|
||||
}else{
|
||||
setHTML(skp_order[i] + "-skp-base", "Original Value: " + skillpoints[i] + "<br>WARNING: cannot assign " + assigned[i] + " skillpoints naturally.");
|
||||
}
|
||||
setHTML(skp_order[i] + "-skp-pct", (skillPointsToPercentage(skillpoints[i])*100).toFixed(1).concat(skp_effects[i]));
|
||||
}
|
||||
console.log(skillpoints);
|
||||
if(player_build.assigned_skillpoints > levelToSkillPoints(player_build.level)){
|
||||
setHTML("summary-box", "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints.<br>" + "WARNING: Too many skillpoints need to be assigned!<br> For level " + player_build.level + ", there are only " + levelToSkillPoints(player_build.level) + " skill points available.");
|
||||
}else{
|
||||
setText("summary-box", "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints.");
|
||||
}
|
||||
|
||||
|
||||
displayExpandedItem(expandItem(player_build.helmet), "build-helmet");
|
||||
displayExpandedItem(expandItem(player_build.chestplate), "build-chestplate");
|
||||
|
@ -310,10 +305,12 @@ function calculateBuild(){
|
|||
//nDamAdj,eDamAdj,tDamAdj,wDamAdj,fDamAdj,aDamAdj,totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS
|
||||
let meleeSummary = "";
|
||||
meleeSummary = meleeSummary.concat("<h1><u>Melee Stats</u></h1>");
|
||||
meleeSummary = meleeSummary.concat("<h2>Average DPS: ",Math.round(meleeStats[10]),"</h2> <br><br>");
|
||||
meleeSummary = meleeSummary.concat("<h2>Average DPS: ",Math.round(meleeStats[10]),"</h2> <br>");
|
||||
let attackSpeeds = ["SUPER SLOW", "VERY SLOW", "SLOW", "NORMAL", "FAST", "VERY FAST", "SUPER FAST"];
|
||||
meleeSummary = meleeSummary.concat("<b>Attack Speed: ",attackSpeeds[meleeStats[11]],"</b><br><br>");
|
||||
meleeSummary = meleeSummary.concat("<b>Non-Crit Stats: </b><br>");
|
||||
let damagePrefixes = ["Neutral Damage: ","Earth Damage: ","Thunder Damage: ","Water Damage: ","Fire Damage: ","Air Damage: "];
|
||||
for (const i in meleeStats){
|
||||
for (let i = 0; i < 6; i++){
|
||||
if(meleeStats[i][0] > 0){
|
||||
meleeSummary = meleeSummary.concat(damagePrefixes[i],meleeStats[i][0]," -> ",meleeStats[i][1],"<br>");
|
||||
}
|
||||
|
@ -321,14 +318,17 @@ function calculateBuild(){
|
|||
meleeSummary = meleeSummary.concat("<br>Total Damage: ",meleeStats[6][0]," -> ",meleeStats[6][1],"<br>");
|
||||
meleeSummary = meleeSummary.concat("Normal DPS: ",Math.round(meleeStats[8]),"<br><br>");
|
||||
meleeSummary = meleeSummary.concat("<b>Crit Stats: </b><br>");
|
||||
for (const i in meleeStats){
|
||||
for (let i = 0; i < 6; i++){
|
||||
if(meleeStats[i][2] > 0){
|
||||
meleeSummary = meleeSummary.concat(damagePrefixes[i],meleeStats[i][2]," -> ",meleeStats[i][3],"<br>");
|
||||
}
|
||||
}
|
||||
meleeSummary = meleeSummary.concat("<br>Total Damage: ",meleeStats[7][0]," -> ",meleeStats[7][1],"<br>");
|
||||
meleeSummary = meleeSummary.concat("Crit DPS: ",Math.round(meleeStats[9]),"<br><br>");
|
||||
setHTML("build-cumulative-stats", "".concat(meleeSummary)); //Incomplete function
|
||||
setHTML("build-melee-stats", "".concat(meleeSummary)); //basically complete function
|
||||
let defenseStats = "";
|
||||
|
||||
setHTML("build-defense-stats", "".concat(defenseStats));
|
||||
location.hash = encodeBuild();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue