Merging
This commit is contained in:
commit
4d66a5b3c5
6 changed files with 84 additions and 80 deletions
7
build.js
7
build.js
|
@ -151,9 +151,8 @@ class Build{
|
|||
Returns an array in the order:
|
||||
*/
|
||||
getMeleeStats(){
|
||||
|
||||
const stats = this.statMap;
|
||||
// Array of neutral + ewtf damages. Each entry is a pair (min, max).
|
||||
// Array of neutral + ewtfa damages. Each entry is a pair (min, max).
|
||||
let damages = [];
|
||||
for (const damage_string of stats.get("damageRaw")) {
|
||||
const damage_vals = damage_string.split("-").map(Number);
|
||||
|
@ -204,7 +203,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.
|
||||
|
@ -222,7 +221,7 @@ class Build{
|
|||
for (const staticID of staticIDs) {
|
||||
statMap.set(staticID, 0);
|
||||
}
|
||||
statMap.set("hp", this.getHealth());
|
||||
statMap.set("hp", levelToHPBase(this.level)); //TODO: Add player base health
|
||||
|
||||
for (const _item of this.items){
|
||||
let item = expandItem(_item);
|
||||
|
|
12
display.js
12
display.js
|
@ -38,7 +38,17 @@ function expandItem(item){
|
|||
expandedItem.set("maxRolls",maxRolls);
|
||||
return expandedItem;
|
||||
}
|
||||
|
||||
/*An independent helper function that rounds a rolled ID to the nearest integer OR brings the roll away from 0.
|
||||
* @param id
|
||||
*/
|
||||
function idRound(id){
|
||||
rounded = Math.round(id);
|
||||
if(rounded == 0){
|
||||
return 1;
|
||||
}else{
|
||||
return rounded;
|
||||
}
|
||||
}
|
||||
function displayExpandedItem(item, parent_id){
|
||||
// Commands to "script" the creation of nice formatting.
|
||||
// #commands create a new element.
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,3 +135,8 @@
|
|||
.Health:before {
|
||||
content: "\2764" ' ';
|
||||
}
|
||||
|
||||
.skpInput, .skplabel {
|
||||
display: block;
|
||||
margin: auto;
|
||||
}
|
||||
|
|
99
test.js
99
test.js
|
@ -368,31 +368,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]);
|
||||
|
||||
setHTML("str-skp-pct", skillPointsToPercentage(skillpoints[0])*100 );
|
||||
setHTML("dex-skp-pct", skillPointsToPercentage(skillpoints[1])*100 );
|
||||
setHTML("int-skp-pct", skillPointsToPercentage(skillpoints[2])*100 );
|
||||
setHTML("def-skp-pct", skillPointsToPercentage(skillpoints[3])*100 );
|
||||
setHTML("agi-skp-pct", skillPointsToPercentage(skillpoints[4])*100 );
|
||||
|
||||
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.");
|
||||
}
|
||||
setText(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");
|
||||
|
@ -422,64 +417,34 @@ function calculateBuildStats() {
|
|||
}
|
||||
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>");
|
||||
if(meleeStats[0][0] > 0){
|
||||
meleeSummary = meleeSummary.concat("Neutral Damage: ",meleeStats[0][0]," -> ",meleeStats[0][1],"<br>");
|
||||
let damagePrefixes = ["Neutral Damage: ","Earth Damage: ","Thunder Damage: ","Water Damage: ","Fire Damage: ","Air Damage: "];
|
||||
for (let i = 0; i < 6; i++){
|
||||
if(meleeStats[i][0] > 0){
|
||||
meleeSummary = meleeSummary.concat(damagePrefixes[i],meleeStats[i][0]," -> ",meleeStats[i][1],"<br>");
|
||||
}
|
||||
if(meleeStats[1][0] > 0){
|
||||
meleeSummary = meleeSummary.concat("Earth Damage: ",meleeStats[1][0]," -> ",meleeStats[1][1],"<br>");
|
||||
}
|
||||
if(meleeStats[2][0] > 0){
|
||||
meleeSummary = meleeSummary.concat("Thunder Damage: ",meleeStats[2][0]," -> ",meleeStats[2][1],"<br>");
|
||||
}
|
||||
if(meleeStats[3][0] > 0){
|
||||
meleeSummary = meleeSummary.concat("Water Damage: ",meleeStats[3][0]," -> ",meleeStats[3][1],"<br>");
|
||||
}
|
||||
if(meleeStats[4][0] > 0){
|
||||
meleeSummary = meleeSummary.concat("Fire Damage: ",meleeStats[4][0]," -> ",meleeStats[4][1],"<br>");
|
||||
}
|
||||
if(meleeStats[5][0] > 0){
|
||||
meleeSummary = meleeSummary.concat("Air Damage: ",meleeStats[5][0]," -> ",meleeStats[5][1],"<br>");
|
||||
}
|
||||
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>");
|
||||
if(meleeStats[0][2] > 0){
|
||||
meleeSummary = meleeSummary.concat("Neutral Damage: ",meleeStats[0][2]," -> ",meleeStats[0][3],"<br>");
|
||||
for (let i = 0; i < 6; i++){
|
||||
if(meleeStats[i][2] > 0){
|
||||
meleeSummary = meleeSummary.concat(damagePrefixes[i],meleeStats[i][2]," -> ",meleeStats[i][3],"<br>");
|
||||
}
|
||||
if(meleeStats[1][2] > 0){
|
||||
meleeSummary = meleeSummary.concat("Earth Damage: ",meleeStats[1][2]," -> ",meleeStats[1][3],"<br>");
|
||||
}
|
||||
if(meleeStats[2][2] > 0){
|
||||
meleeSummary = meleeSummary.concat("Thunder Damage: ",meleeStats[2][2]," -> ",meleeStats[2][3],"<br>");
|
||||
}
|
||||
if(meleeStats[3][2] > 0){
|
||||
meleeSummary = meleeSummary.concat("Water Damage: ",meleeStats[3][2]," -> ",meleeStats[3][3],"<br>");
|
||||
}
|
||||
if(meleeStats[4][2] > 0){
|
||||
meleeSummary = meleeSummary.concat("Fire Damage: ",meleeStats[4][2]," -> ",meleeStats[4][3],"<br>");
|
||||
}
|
||||
if(meleeStats[5][2] > 0){
|
||||
meleeSummary = meleeSummary.concat("Air Damage: ",meleeStats[5][2]," -> ",meleeStats[5][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();
|
||||
}
|
||||
|
||||
/*An independent helper function that rounds a rolled ID to the nearest integer OR brings the roll away from 0.
|
||||
* @param id
|
||||
*/
|
||||
function idRound(id){
|
||||
rounded = Math.round(id);
|
||||
if(rounded == 0){
|
||||
return 1;
|
||||
}else{
|
||||
return rounded;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue