Add poison damage, merge changes, improve powder display

This commit is contained in:
b 2021-01-11 01:22:06 -06:00
commit 615ec62570
5 changed files with 164 additions and 85 deletions

View file

@ -1,7 +1,7 @@
const baseDamageMultiplier = [ 0.51, 0.83, 1.5, 2.05, 2.5, 3.1, 4.3 ];
const attackSpeeds = ["SUPER_SLOW", "VERY_SLOW", "SLOW", "NORMAL", "FAST", "VERY_FAST", "SUPER_FAST"];
const classDefenseMultipliers = new Map([ ["relik",0.60], ["bow",0.60], ["wand", 0.80], ["assassin", 1.0], ["spear",1.20] ]);
const classDefenseMultipliers = new Map([ ["relik",0.60], ["bow",0.60], ["wand", 0.80], ["dagger", 1.0], ["spear",1.20] ]);
/*Turns the input amount of skill points into a float precision percentage.
* @param skp - the integer skillpoint count to be converted
@ -174,20 +174,22 @@ class Build{
// 0 for melee damage.
let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], stats.get("mdRaw"), stats.get("mdPct"), 0, this.weapon, this.total_skillpoints);
//TODO: Account for strength (this.damageMultiplier).
let dex = this.total_skillpoints[1];
let totalDamNorm = results[0];
let totalDamCrit = results[1];
totalDamNorm.push(1-skillPointsToPercentage(dex));
totalDamCrit.push(skillPointsToPercentage(dex));
let damages_results = results[2];
let dex = this.total_skillpoints[1];
//Now do math
let normDPS = (totalDamNorm[0]+totalDamNorm[1])/2 * baseDamageMultiplier[adjAtkSpd];
let critDPS = (totalDamCrit[0]+totalDamCrit[1])/2 * baseDamageMultiplier[adjAtkSpd];
let avgDPS = (normDPS * (1 - skillPointsToPercentage(dex))) + (critDPS * (skillPointsToPercentage(dex)));
//console.log([nDamAdj,eDamAdj,tDamAdj,wDamAdj,fDamAdj,aDamAdj,totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS]);
//[[n n n n] [e e e e] [t t t t] [w w w w] [f f f f] [a a a a] [lowtotal hightotal normalChance] [critlowtotal crithightotal critChance] normalDPS critCPS averageDPS adjAttackSpeed]
//console.log(damages_results.concat([totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS,adjAtkSpd]));
return damages_results.concat([totalDamNorm,totalDamCrit,normDPS,critDPS,avgDPS,adjAtkSpd]);
}

View file

@ -40,9 +40,11 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier,
}
let damageMult = 1;
let melee = false;
// If we are doing melee calculations:
if (spellMultiplier == 0) {
spellMultiplier = 1;
melee = true;
}
else {
damageMult *= spellMultiplier * baseDamageMultiplier[attackSpeeds.indexOf(stats.get("atkSpd"))];
@ -51,9 +53,12 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier,
//console.log(damageMult);
rawModifier *= spellMultiplier;
let totalDamNorm = [rawModifier, rawModifier];
let totalDamCrit = [rawModifier, rawModifier];
let totalDamNorm = [0, 0];
let totalDamCrit = [0, 0];
if(!melee){
totalDamNorm = [rawModifier, rawModifier];
totalDamCrit = [rawModifier, rawModifier];
}
let damages_results = [];
// 0th skillpoint is strength, 1st is dex.
let str = total_skillpoints[0];

View file

@ -44,6 +44,17 @@ function expandItem(item, powders){
expandedItem.set("minRolls",minRolls);
expandedItem.set("maxRolls",maxRolls);
expandedItem.set("powders", powders);
if(expandedItem.has("eDef")){ //item is armor
for(const id of powders){
//console.log(powderStats[id]);
let powder = powderStats[id];
let name = powderNames.get(id);
expandedItem.set(name.charAt(0) + "Def", expandedItem.get(name.charAt(0)+"Def") + powder["defPlus"]);
expandedItem.set(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 6 )% 5] + "Def", expandedItem.get(skp_elements[(skp_elements.indexOf(name.charAt(0)) + 6 )% 5]+"Def") - powder["defMinus"]);
}
}
return expandedItem;
}
@ -340,43 +351,33 @@ function displayExpandedItem(item, parent_id){
let id = command;
if(nonRolledIDs.includes(id) && item.get(id)){//nonRolledID & non-0/non-null/non-und ID
if (id === "slots") {
continue;
let p_elem = document.createElement("p");
// PROPER POWDER DISPLAYING EZ CLAP
p_elem.textContent = "";
let numerals = new Map([["1", "I"], ["2", "II"], ["3", "III"], ["4", "IV"], ["5", "V"], ["6", "VI"]]);
let numerals = new Map([[1, "I"], [2, "II"], [3, "III"], [4, "IV"], [5, "V"], [6, "VI"]]);
/*p_elem.textContent = idPrefixes[id].concat(item.get(id), idSuffixes[id]) +
" [ " + item.get("powders").map(x => powderNames.get(x)) + " ]";*/
let wrapper = document.createElement("p");
let powderPrefix = document.createElement("b");
powderPrefix.classList.add("itemp");
powderPrefix.classList.add("left");
powderPrefix.textContent = "[";
row.appendChild(powderPrefix);
powderPrefix.textContent = "Powder Slots: " + item.get(id) + " [";
p_elem.appendChild(powderPrefix);
let spaceElem = document.createElement("td");
//spaceElem.textContent = " ";
spaceElem.classList.add("itemp");
spaceElem.classList.add("left");
let powderList = item.get("powders").map(x => powderNames.get(x))
for (let i = 0; i < powderList.length; i++) {
let powder = document.createElement("td");
let powderStr = powderList[i];
console.log(powderStr);
powder.textContent = numerals.get(powderStr.charAt(1), 10);
powder.classList.add(powderMap.get(powderStr.charAt(0)));
row.appendChild(powder);
let powders = item.get("powders");
console.log(powders);
for (let i = 0; i < powders.length; i++) {
let powder = document.createElement("b");
powder.textContent = numerals.get((powders[i]%6)+1)+" ";
powder.classList.add(damageClasses[Math.floor(powders[i]/6)+1]+"_powder");
p_elem.appendChild(powder);
}
let powderSuffix = document.createElement("td");
let powderSuffix = document.createElement("b");
powderSuffix.classList.add("itemp");
powderSuffix.classList.add("left");
powderSuffix.textContent = " ]";
row.appendChild(powderSuffix);
wrapper.appendChild(row);
p_elem.appendChild(wrapper);
powderSuffix.textContent = "]";
p_elem.appendChild(powderSuffix);
active_elem.appendChild(p_elem);
}
else {
let p_elem = displayFixedID(active_elem, id, item.get(id), elemental_format);
@ -449,6 +450,39 @@ function displayExpandedItem(item, parent_id){
}//Just don't do anything if else
}
}
//Show powder specials ;-;
let powder_special = document.createElement("p");
powder_special.classList.add("left");
powder_special.classList.add("itemp");
let powders = item.get("powders");
let element = "";
let power = 0;
for (let i = 0; i < powders.length; i++) {
let firstPowderType = skp_elements[Math.floor(powders[i]/6)];
if (element !== "") break;
else if (powders[i]%6 > 2) { //t4+
for (let j = i+1; j < powders.length; j++) {
let currentPowderType = skp_elements[Math.floor(powders[j]/6)]
if (powders[j] % 6 > 2 && firstPowderType === currentPowderType) {
element = currentPowderType;
power = Math.round(((powders[i] % 6 + powders[j] % 6 + 2) / 2 - 4) * 2);
break;
}
}
}
}
if (element !== "") {//powder special is "[e,t,w,f,a]+[0,1,2,3,4]"
console.log(skp_elements.indexOf(element));
let powderSpecial = powderSpecialStats[ skp_elements.indexOf(element)];
let attackSpecialTitle = document.createElement("p");
attackSpecialTitle.classList.add("left");
attackSpecialTitle.textContent = powderSpecial["weaponSpecialName"];
powder_special.appendChild(attackSpecialTitle);
parent_div.append(powder_special);
}
//Show item tier
if (item.get("tier") & item.get("tier") !== " ") {
let item_desc_elem = document.createElement('p');
item_desc_elem.classList.add('itemp');
@ -550,7 +584,7 @@ function displayMeleeDamage(parent_elem, overallparent_elem, meleeStats){
}
}
for (let i = 6; i < 8; ++i) {
for (let j in stats[i]) {
for (let j = 0; j < 2; j++) {
stats[i][j] = stats[i][j].toFixed(2);
}
}
@ -626,10 +660,15 @@ function displayMeleeDamage(parent_elem, overallparent_elem, meleeStats){
let normalDPS = document.createElement("p");
normalDPS.textContent = "Normal DPS: " + stats[8];
normalDPS.append(document.createElement("br"));
normalDPS.append(document.createElement("br"));
normalDPS.classList.add("itemp");
nonCritStats.append(normalDPS);
let normalChance = document.createElement("p");
normalChance.textContent = "Non-Crit Chance: " + (stats[6][2]*100).toFixed(2) + "%";
normalChance.classList.add("itemp");
normalChance.append(document.createElement("br"));
normalChance.append(document.createElement("br"));
nonCritStats.append(normalChance);
parent_elem.append(nonCritStats);
parent_elem.append(document.createElement("br"));
@ -657,10 +696,15 @@ function displayMeleeDamage(parent_elem, overallparent_elem, meleeStats){
let critDPS = document.createElement("p");
critDPS.textContent = "Crit DPS: " + stats[9];
critDPS.classList.add("itemp");
critDPS.append(document.createElement("br"));
critDPS.append(document.createElement("br"));
critStats.append(critDPS);
let critChance = document.createElement("p");
critChance.textContent = "Crit Chance: " + (stats[7][2]*100).toFixed(2) + "%";
critChance.classList.add("itemp");
critChance.append(document.createElement("br"));
critChance.append(document.createElement("br"));
critStats.append(critChance);
parent_elem.append(critStats);
}
function displayDefenseStats(parent_elem,defenseStats){

View file

@ -138,53 +138,33 @@ a.link{
/*text-shadow: 2px 2px 0 #1f1515;*/
}
.Earth {
color: #0a0;
/*text-shadow: 2px 2px 0 #002a00;*/
}
.Earth:before {
content: "\2724" ' ';
}
.Earth { color: #0a0; }
.Earth:before { content: "\2724" ' '; }
.Earth_powder { color: #0a0; }
.Earth_powder:before { content: "\2724"; }
.Thunder {
color: #ff5;
/*text-shadow: 2px 2px 0 #3f3f15;*/
}
.Thunder:before {
content: "\2726" ' ';
}
.Thunder { color: #ff5; }
.Thunder:before { content: "\2726" ' '; }
.Thunder_powder { color: #ff5; }
.Thunder_powder:before { content: "\2726"; }
.Water {
color: #5ff;
/*text-shadow: 2px 2px 0 #153f3f;*/
}
.Water:before {
content: "\2749" ' ';
}
.Water { color: #5ff; }
.Water:before { content: "\2749" ' '; }
.Water_powder { color: #5ff; }
.Water_powder:before { content: "\2749"; }
.Fire {
color: #f55;
/*text-shadow: 2px 2px 0 #1f1515;*/
}
.Fire:before {
content: "\2739" ' ';
}
.Fire { color: #f55; }
.Fire:before { content: "\2739" ' '; }
.Fire_powder { color: #f55; }
.Fire_powder:before { content: "\2739"; }
.Air {
color: #fff;
/*text-shadow: 2px 2px 0 #3f3f3f;*/
}
.Air:before {
content: "\274b" ' ';
}
.Air { color: #fff; }
.Air:before { content: "\274b" ' '; }
.Air_powder { color: #fff; }
.Air_powder:before { content: "\274b"; }
.Neutral {
color: #fa0;
/*text-shadow: 2px 2px 0 #2a2a00;*/
}
.Neutral:before {
content: "\2724" ' ';
}
.Neutral { color: #fa0; }
.Neutral:before { content: "\2724" ' '; }
.Health {
color: #a00;
@ -270,6 +250,6 @@ input {
.Set{
color:#5f5;
}
.restrict{
.restrict {
color: #ff006a;
}

54
test.js
View file

@ -91,6 +91,26 @@ let powderStats = [
_p(2,6,11,3,1), _p(4,9,14,6,2), _p(7,10,17,10,3), _p(9,13,22,16,5), _p(13,18,28,24,9), _p(16,18,35,34,13)
];
//Ordering: [weapon special name, weapon special effects, armor special name, armor special effects]
class PowderSpecial{
constructor(wSpName, wSpEff, aSpName, aSpEff, cap){
this.weaponSpecialName = wSpName;
this.weaponSpecialEffects = wSpEff;
this.armorSpecialName = aSpName;
this.armorSpecialEffects = aSpEff;
this.cap = cap;
}
}
function _ps(a,b,c,d,e) { return new PowderSpecial(a,b,c,d,e); } //bruh moment
let powderSpecialStats = [
_ps("Quake",new Map([["Radius",[5,5.5,6,6.5,7]], ["Damage",[155,220,285,350,415]] ]),"Rage",new Map([ ["Damage", [0.3,0.4,0.5,0.7,1.0]],["Description", "% \2764 Missing"] ]),400), //e
_ps("Chain Lightning",new Map([ ["Chains", [5,6,7,8,9]], ["Damage", [80,120,160,200,240]] ]),"Kill Streak",new Map([ ["Damage", [3,4.5,6,7.5,9]],["Duration", [5,5,5,5,5]],["Description", "Mob Killed"] ]),200), //t
_ps("Curse",new Map([ ["Duration", [7,7.5,8,8.5,9]],["Damage", [90,120,150,180,210]] ]),"Concentration",new Map([ ["Damage", [1,2,3,4,5]],["Duration",[1,1,1,1,1]],["Description", "Mana Used"] ]),150), //w
_ps("Courage",new Map([ ["Duration", [6,6.5,7,7.5,8]],["Damage", [75,87.5,100,112.5,125]],["Damage Boost", [70,90,110,130,150]] ]),"Endurance",new Map([ ["Damage", [2,3,4,5,6]],["Duration", [8,8,8,8,8]],["Description", "Hit Taken"] ]),200), //f
_ps("Air Prison",new Map([ ["Duration", [3,3.5,4,4.5,5]],["Damage Boost", [400,450,500,550,600]],["Knockback", [8,12,16,20,24]] ]),"Dodge",new Map([ ["Damage",[2,3,4,5,6]],["Duration",[2,3,4,5,6]],["Description","Near Mobs"] ]),150) //a
];
let itemTypes = armorTypes.concat(accessoryTypes).concat(weaponTypes);
let itemLists = new Map();
for (const it of itemTypes) {
@ -454,10 +474,38 @@ function calculateBuildStats() {
let summarybox = document.getElementById("summary-box");
summarybox.textContent = "";
let skpSummary = document.createElement("p");
skpSummary.textContent = "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints. Total: ( " + player_build.total_skillpoints.join(" | ") + " )";
let skpRow = document.createElement("tr");
//let skpSummary = document.createElement("p");
//skpSummary.textContent = "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints. Total: ( " + player_build.total_skillpoints.join(" | ") + " )";
let skpSummary = document.createElement("td");
skpSummary.textContent = "Summary: Assigned "+player_build.assigned_skillpoints+" skillpoints. Total: (";
skpSummary.classList.add("itemp");
summarybox.append(skpSummary);
skpRow.appendChild(skpSummary);
for (let i = 0; i < skp_order.length; i++){
let skp = document.createElement("td");
let boost = document.createElement("td");
let separator = document.createElement("td");
skp.classList.add("itemp");
skp.classList.add("nopadding");
skp.classList.add(damageClasses[i+1]);
boost.classList.add("itemp");
boost.classList.add("nopadding");
boost.textContent = player_build.total_skillpoints[i];
skpRow.appendChild(skp);
skpRow.appendChild(document.createElement("br"));
skpRow.appendChild(boost);
if(i < 4){
skpRow.appendChild(separator);
}
}
//summarybox.append(skpSummary);
let skpEnd = document.createElement("td");
skpEnd.textContent = ")";
skpEnd.classList.add("itemp");
skpRow.append(skpEnd);
summarybox.append(skpRow);
if(player_build.assigned_skillpoints > levelToSkillPoints(player_build.level)){
let skpWarning = document.createElement("p");
skpWarning.classList.add("itemp");