From 85e255ee5915be3b2b9973faa24c8df17d6769d0 Mon Sep 17 00:00:00 2001 From: ferricles Date: Fri, 8 Jan 2021 12:14:23 -0800 Subject: [PATCH] fixed skill points with all fixed + weapon reqs, added skillpoint related warnings, refactored code --- build.js | 5 +---- index.html | 4 ++-- skillpoints.js | 31 +++++++++++++++++++++++++--- test.js | 56 +++++++++++++++++++++++++------------------------- 4 files changed, 59 insertions(+), 37 deletions(-) diff --git a/build.js b/build.js index 21cb383..0d13cfd 100644 --- a/build.js +++ b/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. diff --git a/index.html b/index.html index bfe97be..88de7b9 100644 --- a/index.html +++ b/index.html @@ -233,9 +233,9 @@
-
+
-
+
diff --git a/skillpoints.js b/skillpoints.js index f02e6cc..7ede982 100644 --- a/skillpoints.js +++ b/skillpoints.js @@ -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]; } } diff --git a/test.js b/test.js index 8016f7d..3e5be17 100644 --- a/test.js +++ b/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] + "
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.
" + "WARNING: Too many skillpoints need to be assigned!
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("

Melee Stats

"); - meleeSummary = meleeSummary.concat("

Average DPS: ",Math.round(meleeStats[10]),"



"); + meleeSummary = meleeSummary.concat("

Average DPS: ",Math.round(meleeStats[10]),"


"); + let attackSpeeds = ["SUPER SLOW", "VERY SLOW", "SLOW", "NORMAL", "FAST", "VERY FAST", "SUPER FAST"]; + meleeSummary = meleeSummary.concat("Attack Speed: ",attackSpeeds[meleeStats[11]],"

"); meleeSummary = meleeSummary.concat("Non-Crit Stats:
"); 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],"
"); } @@ -321,14 +318,17 @@ function calculateBuild(){ meleeSummary = meleeSummary.concat("
Total Damage: ",meleeStats[6][0]," -> ",meleeStats[6][1],"
"); meleeSummary = meleeSummary.concat("Normal DPS: ",Math.round(meleeStats[8]),"

"); meleeSummary = meleeSummary.concat("Crit Stats:
"); - 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],"
"); } } meleeSummary = meleeSummary.concat("
Total Damage: ",meleeStats[7][0]," -> ",meleeStats[7][1],"
"); meleeSummary = meleeSummary.concat("Crit DPS: ",Math.round(meleeStats[9]),"

"); - 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(); }