2021-10-21 21:11:04 +07:00
function displaysq2BuildStats ( parent _id , build , command _group ) {
2021-10-17 22:53:48 +07:00
// Commands to "script" the creation of nice formatting.
// #commands create a new element.
// !elemental is some janky hack for elemental damage.
// normals just display a thing.
let display _commands = command _group ;
console . log ( display _commands ) ;
// Clear the parent div.
setHTML ( parent _id , "" ) ;
let parent _div = document . getElementById ( parent _id ) ;
let stats = build . statMap ;
console . log ( build . statMap ) ;
let active _elem ;
let elemental _format = false ;
//TODO this is put here for readability, consolidate with definition in build.js
let staticIDs = [ "hp" , "eDef" , "tDef" , "wDef" , "fDef" , "aDef" ] ;
for ( const command of display _commands ) {
// style instructions
2021-10-21 21:11:04 +07:00
2021-10-17 22:53:48 +07:00
if ( command . charAt ( 0 ) === "#" ) {
2021-10-21 21:11:04 +07:00
if ( command === "#defense-stats" ) {
displaysq2DefenseStats ( parent _div , build , true ) ;
2021-10-17 22:53:48 +07:00
}
}
2021-10-21 21:11:04 +07:00
if ( command . charAt ( 0 ) === "!" ) {
2021-10-17 22:53:48 +07:00
// TODO: This is sooo incredibly janky.....
if ( command === "!elemental" ) {
elemental _format = ! elemental _format ;
}
}
// id instruction
else {
let id = command ;
if ( stats . get ( id ) ) {
let style = null ;
// TODO: add pos and neg style
if ( ! staticIDs . includes ( id ) ) {
style = "positive" ;
if ( stats . get ( id ) < 0 ) {
style = "negative" ;
}
}
// ignore
let id _val = stats . get ( id ) ;
if ( reversedIDs . includes ( id ) ) {
style === "positive" ? style = "negative" : style = "positive" ;
}
if ( id === "poison" && id _val > 0 ) {
id _val = Math . ceil ( id _val * build . statMap . get ( "poisonPct" ) / 100 ) ;
}
2021-10-21 21:11:04 +07:00
displaysq2FixedID ( parent _div , id , id _val , elemental _format , style ) ;
2021-10-17 22:53:48 +07:00
if ( id === "poison" && id _val > 0 ) {
2021-10-21 21:11:04 +07:00
let row = document . createElement ( 'div' ) ;
row . classList . add ( "row" )
let value _elem = document . createElement ( 'div' ) ;
value _elem . classList . add ( 'col' ) ;
value _elem . classList . add ( 'text-end' ) ;
2021-10-17 22:53:48 +07:00
let prefix _elem = document . createElement ( 'b' ) ;
prefix _elem . textContent = "\u279C With Strength: " ;
let number _elem = document . createElement ( 'b' ) ;
number _elem . classList . add ( style ) ;
number _elem . textContent = ( id _val * ( 1 + skillPointsToPercentage ( build . total _skillpoints [ 0 ] ) ) ) . toFixed ( 0 ) + idSuffixes [ id ] ;
value _elem . append ( prefix _elem ) ;
value _elem . append ( number _elem ) ;
row . appendChild ( value _elem ) ;
2021-10-21 21:11:04 +07:00
parent _div . appendChild ( row ) ;
2021-10-17 22:53:48 +07:00
}
// sp thingy
} else if ( skp _order . includes ( id ) ) {
let total _assigned = build . total _skillpoints [ skp _order . indexOf ( id ) ] ;
let base _assigned = build . base _skillpoints [ skp _order . indexOf ( id ) ] ;
let diff = total _assigned - base _assigned ;
let style ;
if ( diff > 0 ) {
style = "positive" ;
} else if ( diff < 0 ) {
style = "negative" ;
}
if ( diff != 0 ) {
2021-10-21 21:11:04 +07:00
displaysq2FixedID ( parent _div , id , diff , false , style ) ;
2021-10-17 22:53:48 +07:00
}
}
}
}
}
2021-10-18 07:25:02 +07:00
function displaysq2ExpandedItem ( item , parent _id , mini = false ) {
2021-10-17 22:53:48 +07:00
// Commands to "script" the creation of nice formatting.
// #commands create a new element.
// !elemental is some janky hack for elemental damage.
// normals just display a thing.
if ( item . get ( "category" ) === "weapon" ) {
let stats = new Map ( ) ;
stats . set ( "atkSpd" , item . get ( "atkSpd" ) ) ;
stats . set ( "damageBonus" , [ 0 , 0 , 0 , 0 , 0 ] ) ;
//SUPER JANK @HPP PLS FIX
let damage _keys = [ "nDam_" , "eDam_" , "tDam_" , "wDam_" , "fDam_" , "aDam_" ] ;
if ( item . get ( "tier" ) !== "Crafted" ) {
stats . set ( "damageRaw" , [ item . get ( "nDam" ) , item . get ( "eDam" ) , item . get ( "tDam" ) , item . get ( "wDam" ) , item . get ( "fDam" ) , item . get ( "aDam" ) ] ) ;
let results = calculateSpellDamage ( stats , [ 100 , 0 , 0 , 0 , 0 , 0 ] , 0 , 0 , 0 , item , [ 0 , 0 , 0 , 0 , 0 ] , 1 , undefined ) ;
let damages = results [ 2 ] ;
let total _damage = 0 ;
for ( const i in damage _keys ) {
total _damage += damages [ i ] [ 0 ] + damages [ i ] [ 1 ] ;
item . set ( damage _keys [ i ] , damages [ i ] [ 0 ] + "-" + damages [ i ] [ 1 ] ) ;
}
total _damage = total _damage / 2 ;
item . set ( "basedps" , total _damage ) ;
} else {
stats . set ( "damageRaw" , [ item . get ( "nDamLow" ) , item . get ( "eDamLow" ) , item . get ( "tDamLow" ) , item . get ( "wDamLow" ) , item . get ( "fDamLow" ) , item . get ( "aDamLow" ) ] ) ;
stats . set ( "damageBases" , [ item . get ( "nDamBaseLow" ) , item . get ( "eDamBaseLow" ) , item . get ( "tDamBaseLow" ) , item . get ( "wDamBaseLow" ) , item . get ( "fDamBaseLow" ) , item . get ( "aDamBaseLow" ) ] ) ;
let resultsLow = calculateSpellDamage ( stats , [ 100 , 0 , 0 , 0 , 0 , 0 ] , 0 , 0 , 0 , item , [ 0 , 0 , 0 , 0 , 0 ] , 1 , undefined ) ;
let damagesLow = resultsLow [ 2 ] ;
stats . set ( "damageRaw" , [ item . get ( "nDam" ) , item . get ( "eDam" ) , item . get ( "tDam" ) , item . get ( "wDam" ) , item . get ( "fDam" ) , item . get ( "aDam" ) ] ) ;
stats . set ( "damageBases" , [ item . get ( "nDamBaseHigh" ) , item . get ( "eDamBaseHigh" ) , item . get ( "tDamBaseHigh" ) , item . get ( "wDamBaseHigh" ) , item . get ( "fDamBaseHigh" ) , item . get ( "aDamBaseHigh" ) ] ) ;
let results = calculateSpellDamage ( stats , [ 100 , 0 , 0 , 0 , 0 , 0 ] , 0 , 0 , 0 , item , [ 0 , 0 , 0 , 0 , 0 ] , 1 , undefined ) ;
let damages = results [ 2 ] ;
console . log ( damages ) ;
let total _damage _min = 0 ;
let total _damage _max = 0 ;
for ( const i in damage _keys ) {
total _damage _min += damagesLow [ i ] [ 0 ] + damagesLow [ i ] [ 1 ] ;
total _damage _max += damages [ i ] [ 0 ] + damages [ i ] [ 1 ] ;
item . set ( damage _keys [ i ] , damagesLow [ i ] [ 0 ] + "-" + damagesLow [ i ] [ 1 ] + "\u279c" + damages [ i ] [ 0 ] + "-" + damages [ i ] [ 1 ] ) ;
}
total _damage _min = total _damage _min / 2 ;
total _damage _max = total _damage _max / 2 ;
item . set ( "basedps" , [ total _damage _min , total _damage _max ] ) ;
}
} else if ( item . get ( "category" ) === "armor" ) {
}
let display _commands = item _display _commands ;
// Clear the parent div.
setHTML ( parent _id , "" ) ;
let parent _div = document . getElementById ( parent _id ) ;
let active _elem ;
let fix _id = item . has ( "fixID" ) && item . get ( "fixID" ) ;
let elemental _format = false ;
for ( let i = 0 ; i < display _commands . length ; i ++ ) {
const command = display _commands [ i ] ;
if ( command . charAt ( 0 ) === "#" ) {
if ( command === "#cdiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'center' ) ;
}
else if ( command === "#ldiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'left' ) ;
}
else if ( command === "#table" ) {
active _elem = document . createElement ( 'table' ) ;
2021-10-18 16:39:43 +07:00
active _elem . style . width = "100%" ;
2021-10-17 22:53:48 +07:00
}
active _elem . classList . add ( 'item-margin' ) ;
parent _div . appendChild ( active _elem ) ;
}
else if ( command . charAt ( 0 ) === "!" ) {
// TODO: This is sooo incredibly janky.....
if ( command === "!elemental" ) {
elemental _format = ! elemental _format ;
}
}
else {
let id = command ;
if ( nonRolledIDs . includes ( id ) ) { //nonRolledID & non-0/non-null/non-und ID
if ( ! item . get ( id ) ) {
if ( ! ( item . get ( "crafted" ) && skp _order . includes ( id ) &&
( item . get ( "maxRolls" ) . get ( id ) || item . get ( "minRolls" ) . get ( id ) ) ) ) {
continue ;
}
}
if ( id === "slots" ) {
let p _elem = document . createElement ( "p" ) ;
2021-10-18 18:54:47 +07:00
p _elem . classList . add ( 'itemp' )
2021-10-17 22:53:48 +07:00
// PROPER POWDER DISPLAYING
let numerals = new Map ( [ [ 1 , "I" ] , [ 2 , "II" ] , [ 3 , "III" ] , [ 4 , "IV" ] , [ 5 , "V" ] , [ 6 , "VI" ] ] ) ;
let powderPrefix = document . createElement ( "b" ) ;
powderPrefix . classList . add ( "powderLeft" ) ; powderPrefix . classList . add ( "left" ) ;
powderPrefix . textContent = "Powder Slots: " + item . get ( id ) + " [" ;
p _elem . appendChild ( powderPrefix ) ;
let powders = item . get ( "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 ( "b" ) ;
powderSuffix . classList . add ( "powderRight" ) ; powderSuffix . classList . add ( "left" ) ;
powderSuffix . textContent = "]" ;
p _elem . appendChild ( powderSuffix ) ;
active _elem . appendChild ( p _elem ) ;
} else if ( id === "set" ) {
if ( item . get ( "hideSet" ) ) { continue ; }
let p _elem = document . createElement ( "p" ) ;
p _elem . classList . add ( "itemp" ) ;
p _elem . textContent = "Set: " + item . get ( id ) . toString ( ) ;
active _elem . appendChild ( p _elem ) ;
} else if ( id === "majorIds" ) {
console . log ( item . get ( id ) ) ;
for ( let majorID of item . get ( id ) ) {
let p _elem = document . createElement ( "p" ) ;
p _elem . classList . add ( "itemp" ) ;
let title _elem = document . createElement ( "b" ) ;
let b _elem = document . createElement ( "b" ) ;
if ( majorID . includes ( ":" ) ) {
let name = majorID . substring ( 0 , majorID . indexOf ( ":" ) + 1 ) ;
let mid = majorID . substring ( majorID . indexOf ( ":" ) + 1 ) ;
if ( name . charAt ( 0 ) !== "+" ) { name = "+" + name }
title _elem . classList . add ( "Legendary" ) ;
title _elem . textContent = name ;
b _elem . classList . add ( "Crafted" ) ;
b _elem . textContent = mid ;
p _elem . appendChild ( title _elem ) ;
p _elem . appendChild ( b _elem ) ;
} else {
let name = item . get ( id ) . toString ( )
if ( name . charAt ( 0 ) !== "+" ) { name = "+" + name }
b _elem . classList . add ( "Legendary" ) ;
b _elem . textContent = name ;
p _elem . appendChild ( b _elem ) ;
}
active _elem . appendChild ( p _elem ) ;
}
} else if ( id === "lvl" && item . get ( "tier" ) === "Crafted" ) {
let p _elem = document . createElement ( "p" ) ;
p _elem . classList . add ( "itemp" ) ;
p _elem . textContent = "Combat Level Min: " + item . get ( "lvlLow" ) + "-" + item . get ( id ) ;
active _elem . appendChild ( p _elem ) ;
} else if ( id === "displayName" ) {
let p _elem = document . createElement ( "a" ) ;
p _elem . classList . add ( 'itemp' ) ;
p _elem . classList . add ( "smalltitle" ) ;
p _elem . classList . add ( item . has ( "tier" ) ? item . get ( "tier" ) . replace ( " " , "" ) : "none" ) ;
if ( item . get ( "custom" ) ) {
// p_elem.href = url_base.replace(/\w+.html/, "") + "customizer.html#" + item.get("hash");
p _elem . textContent = item . get ( "displayName" ) ;
} else if ( item . get ( "crafted" ) ) {
// p_elem.href = url_base.replace(/\w+.html/, "") + "crafter.html#" + item.get("hash");
p _elem . textContent = item . get ( id ) ;
} else {
// p_elem.href = url_base.replace(/\w+.html/, "") + "item.html#" + item.get("displayName");
p _elem . textContent = item . get ( "displayName" ) ;
}
p _elem . target = "_blank" ;
active _elem . appendChild ( p _elem ) ;
let img = document . createElement ( "img" ) ;
if ( item && item . has ( "type" ) ) {
img . src = "./media/items/" + ( newIcons ? "new/" : "old/" ) + "generic-" + item . get ( "type" ) + ".png" ;
img . alt = item . get ( "type" ) ;
if ( mini ) {
img . style = " z=index: 1;max-width: 32px; max-height: 32px; position: relative; top: 50%; transform: translateY(-50%);" ;
} else {
img . style = " z=index: 1;max-width: 48px; max-height: 48px; position: relative; top: 50%; transform: translateY(-50%);" ;
}
let bckgrd = document . createElement ( "p" ) ;
if ( mini ) {
bckgrd . style = "width: 48px; height: 48px; border-radius: 50%;background-image: radial-gradient(closest-side, " + colorMap . get ( item . get ( "tier" ) ) + " 20%," + "#121516 80%); margin-left: auto; margin-right: auto;"
} else {
bckgrd . style = "width: 64px; height: 64px; border-radius: 50%;background-image: radial-gradient(closest-side, " + colorMap . get ( item . get ( "tier" ) ) + " 20%," + "#121516 80%); margin-left: auto; margin-right: auto;"
}
bckgrd . classList . add ( "center" ) ;
bckgrd . classList . add ( "itemp" ) ;
active _elem . appendChild ( bckgrd ) ;
bckgrd . appendChild ( img ) ;
}
} else {
let p _elem ;
if ( ! ( item . get ( "tier" ) === "Crafted" && item . get ( "category" ) === "armor" && id === "hp" ) && ( ! skp _order . includes ( id ) ) || ( skp _order . includes ( id ) && item . get ( "tier" ) !== "Crafted" && active _elem . nodeName === "DIV" ) ) { //skp warp
2021-10-18 07:25:02 +07:00
p _elem = displaysq2FixedID ( active _elem , id , item . get ( id ) , elemental _format ) ;
2021-10-17 22:53:48 +07:00
} else if ( item . get ( "tier" ) === "Crafted" && item . get ( "category" ) === "armor" && id === "hp" ) {
2021-10-18 07:25:02 +07:00
p _elem = displaysq2FixedID ( active _elem , id , item . get ( id + "Low" ) + "-" + item . get ( id ) , elemental _format ) ;
2021-10-17 22:53:48 +07:00
}
if ( id === "lore" ) {
p _elem . style = "font-style: italic" ;
p _elem . classList . add ( "lore" ) ;
} else if ( skp _order . includes ( id ) ) { //id = str, dex, int, def, or agi
if ( item . get ( "tier" ) !== "Crafted" && active _elem . nodeName === "DIV" ) {
p _elem . textContent = "" ;
p _elem . classList . add ( "itemp" ) ;
row = document . createElement ( "p" ) ;
row . classList . add ( "left" ) ;
let title = document . createElement ( "b" ) ;
title . textContent = idPrefixes [ id ] + " " ;
let boost = document . createElement ( "b" ) ;
if ( item . get ( id ) < 0 ) {
boost . classList . add ( "negative" ) ;
} else { //boost = 0 SHOULD not come up
boost . classList . add ( "positive" ) ;
}
boost . textContent = item . get ( id ) ;
row . appendChild ( title ) ;
row . appendChild ( boost ) ;
p _elem . appendChild ( row ) ;
} else if ( item . get ( "tier" ) === "Crafted" && active _elem . nodeName === "TABLE" ) {
2021-10-18 07:25:02 +07:00
let row = displaysq2RolledID ( item , id , elemental _format ) ;
2021-10-17 22:53:48 +07:00
active _elem . appendChild ( row ) ;
}
} else if ( id === "restrict" ) {
p _elem . classList . add ( "restrict" ) ;
}
}
}
else if ( rolledIDs . includes ( id ) &&
( ( item . get ( "maxRolls" ) && item . get ( "maxRolls" ) . get ( id ) )
|| ( item . get ( "minRolls" ) && item . get ( "minRolls" ) . get ( id ) ) ) ) {
let style = "positive" ;
if ( item . get ( "minRolls" ) . get ( id ) < 0 ) {
style = "negative" ;
}
if ( reversedIDs . includes ( id ) ) {
style === "positive" ? style = "negative" : style = "positive" ;
}
if ( fix _id ) {
2021-10-18 07:25:02 +07:00
displaysq2FixedID ( active _elem , id , item . get ( "minRolls" ) . get ( id ) , elemental _format , style ) ;
2021-10-17 22:53:48 +07:00
}
else {
2021-10-18 07:25:02 +07:00
let row = displaysq2RolledID ( item , id , elemental _format ) ;
2021-10-17 22:53:48 +07:00
active _elem . appendChild ( row ) ;
}
} else {
// :/
}
}
}
//Show powder specials ;-;
let nonConsumables = [ "relik" , "wand" , "bow" , "spear" , "dagger" , "chestplate" , "helmet" , "leggings" , "boots" , "ring" , "bracelet" , "necklace" ] ;
if ( nonConsumables . includes ( item . get ( "type" ) ) ) {
let powder _special = document . createElement ( "p" ) ;
powder _special . classList . add ( "left" ) ;
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]"
let powderSpecial = powderSpecialStats [ skp _elements . indexOf ( element ) ] ;
let specialSuffixes = new Map ( [ [ "Duration" , " sec" ] , [ "Radius" , " blocks" ] , [ "Chains" , "" ] , [ "Damage" , "%" ] , [ "Damage Boost" , "%" ] , [ "Knockback" , " blocks" ] ] ) ;
let specialTitle = document . createElement ( "p" ) ;
let specialEffects = document . createElement ( "p" ) ;
addClasses ( specialTitle , [ "left" , "itemp" , damageClasses [ skp _elements . indexOf ( element ) + 1 ] ] ) ;
addClasses ( specialEffects , [ "left" , "itemp" , "nocolor" ] ) ;
let effects ;
if ( item . get ( "category" ) === "weapon" ) { //weapon
effects = powderSpecial [ "weaponSpecialEffects" ] ;
specialTitle . textContent = powderSpecial [ "weaponSpecialName" ] ;
} else if ( item . get ( "category" ) === "armor" ) { //armor
effects = powderSpecial [ "armorSpecialEffects" ] ;
specialTitle . textContent += powderSpecial [ "armorSpecialName" ] + ": " ;
}
for ( const [ key , value ] of effects . entries ( ) ) {
if ( key !== "Description" ) {
let effect = document . createElement ( "p" ) ;
effect . classList . add ( "itemp" ) ;
effect . textContent = key + ": " + value [ power ] + specialSuffixes . get ( key ) ;
if ( key === "Damage" ) {
effect . textContent += elementIcons [ skp _elements . indexOf ( element ) ] ;
}
if ( element === "w" && item . get ( "category" ) === "armor" ) {
effect . textContent += " / Mana Used" ;
}
specialEffects . appendChild ( effect ) ;
} else {
specialTitle . textContent += "[ " + effects . get ( "Description" ) + " ]" ;
}
}
powder _special . appendChild ( specialTitle ) ;
powder _special . appendChild ( specialEffects ) ;
parent _div . appendChild ( powder _special ) ;
}
}
if ( item . get ( "tier" ) && item . get ( "tier" ) === "Crafted" ) {
let dura _elem = document . createElement ( "p" ) ;
dura _elem . classList . add ( "itemp" ) ;
let dura = [ ] ;
let suffix = "" ;
if ( nonConsumables . includes ( item . get ( "type" ) ) ) {
dura = item . get ( "durability" ) ;
dura _elem . textContent = "Durability: "
} else {
dura = item . get ( "duration" ) ;
dura _elem . textContent = "Duration: "
suffix = " sec."
let charges = document . createElement ( "b" ) ;
charges . textContent = "Charges: " + item . get ( "charges" ) ;
charges . classList . add ( "spaceleft" ) ;
active _elem . appendChild ( charges ) ;
}
if ( typeof ( dura ) === "string" ) {
dura _elem . textContent += dura + suffix ;
} else {
dura _elem . textContent += dura [ 0 ] + "-" + dura [ 1 ] + suffix ;
}
active _elem . append ( dura _elem ) ;
}
//Show item tier
if ( item . get ( "tier" ) && item . get ( "tier" ) !== " " ) {
let item _desc _elem = document . createElement ( "p" ) ;
item _desc _elem . classList . add ( 'itemp' ) ;
item _desc _elem . classList . add ( item . get ( "tier" ) ) ;
item _desc _elem . textContent = item . get ( "tier" ) + " " + item . get ( "type" ) ;
active _elem . append ( item _desc _elem ) ;
}
//Show item hash if applicable
if ( item . get ( "crafted" ) || item . get ( "custom" ) ) {
let item _desc _elem = document . createElement ( "p" ) ;
item _desc _elem . classList . add ( 'itemp' ) ;
item _desc _elem . style . maxWidth = "100%" ;
item _desc _elem . style . wordWrap = "break-word" ;
item _desc _elem . style . wordBreak = "break-word" ;
item _desc _elem . textContent = item . get ( "hash" ) ;
active _elem . append ( item _desc _elem ) ;
}
if ( item . get ( "category" ) === "weapon" ) {
let damage _mult = baseDamageMultiplier [ attackSpeeds . indexOf ( item . get ( "atkSpd" ) ) ] ;
let total _damages = item . get ( "basedps" ) ;
let base _dps _elem = document . createElement ( "p" ) ;
base _dps _elem . classList . add ( "left" ) ;
base _dps _elem . classList . add ( "itemp" ) ;
if ( item . get ( "tier" ) === "Crafted" ) {
let base _dps _min = total _damages [ 0 ] * damage _mult ;
let base _dps _max = total _damages [ 1 ] * damage _mult ;
base _dps _elem . textContent = "Base DPS: " + base _dps _min . toFixed ( 3 ) + "\u279c" + base _dps _max . toFixed ( 3 ) ;
}
else {
base _dps _elem . textContent = "Base DPS: " + ( total _damages * damage _mult ) ;
}
parent _div . appendChild ( document . createElement ( "p" ) ) ;
parent _div . appendChild ( base _dps _elem ) ;
}
}
2021-10-18 07:25:02 +07:00
function displaysq2RolledID ( item , id , elemental _format ) {
2021-10-17 22:53:48 +07:00
let row = document . createElement ( 'tr' ) ;
let min _elem = document . createElement ( 'td' ) ;
min _elem . classList . add ( 'shaded-table' ) ;
min _elem . classList . add ( 'left' ) ;
let id _min = item . get ( "minRolls" ) . get ( id )
let style = id _min < 0 ? "negative" : "positive" ;
if ( reversedIDs . includes ( id ) ) {
style === "positive" ? style = "negative" : style = "positive" ;
}
min _elem . classList . add ( style ) ;
min _elem . textContent = id _min + idSuffixes [ id ] ;
row . appendChild ( min _elem ) ;
let desc _elem = document . createElement ( 'td' ) ;
desc _elem . classList . add ( 'center' ) ;
desc _elem . classList . add ( 'shaded-table' )
//TODO elemental format jank
if ( elemental _format ) {
apply _elemental _format ( desc _elem , id ) ;
}
else {
desc _elem . textContent = idPrefixes [ id ] ;
}
row . appendChild ( desc _elem ) ;
let max _elem = document . createElement ( 'td' ) ;
let id _max = item . get ( "maxRolls" ) . get ( id )
max _elem . classList . add ( 'right' ) ;
max _elem . classList . add ( 'shaded-table' )
style = id _max < 0 ? "negative" : "positive" ;
if ( reversedIDs . includes ( id ) ) {
style === "positive" ? style = "negative" : style = "positive" ;
}
max _elem . classList . add ( style ) ;
max _elem . textContent = id _max + idSuffixes [ id ] ;
row . appendChild ( max _elem ) ;
return row ;
}
2021-10-18 07:25:02 +07:00
function displaysq2WeaponBase ( build ) {
2021-10-17 22:53:48 +07:00
// let base_damage = build.get('damageRaw');
let damage _keys = [ "nDam" , "eDam" , "tDam" , "wDam" , "fDam" , "aDam" ] ;
// pP base calc (why do i still use pP)
let item = build . weapon ;
let stats = new Map ( ) ;
stats . set ( "atkSpd" , item . get ( "atkSpd" ) ) ;
stats . set ( "damageBonus" , [ 0 , 0 , 0 , 0 , 0 ] ) ;
stats . set ( "damageRaw" , [ item . get ( "nDam" ) , item . get ( "eDam" ) , item . get ( "tDam" ) , item . get ( "wDam" ) , item . get ( "fDam" ) , item . get ( "aDam" ) ] ) ;
let results = calculateSpellDamage ( stats , [ 100 , 0 , 0 , 0 , 0 , 0 ] , 0 , 0 , 0 , build . weapon , [ 0 , 0 , 0 , 0 , 0 ] , 1 , undefined ) ;
let powdered _base = results [ 2 ] ;
const powdered _map = new Map ( ) ;
powdered _map . set ( 'nDam' , powdered _base [ 0 ] [ 0 ] + '-' + powdered _base [ 0 ] [ 1 ] ) ;
powdered _map . set ( 'eDam' , powdered _base [ 1 ] [ 0 ] + '-' + powdered _base [ 1 ] [ 1 ] ) ;
powdered _map . set ( 'tDam' , powdered _base [ 2 ] [ 0 ] + '-' + powdered _base [ 2 ] [ 1 ] ) ;
powdered _map . set ( 'wDam' , powdered _base [ 3 ] [ 0 ] + '-' + powdered _base [ 3 ] [ 1 ] ) ;
powdered _map . set ( 'fDam' , powdered _base [ 4 ] [ 0 ] + '-' + powdered _base [ 4 ] [ 1 ] ) ;
powdered _map . set ( 'aDam' , powdered _base [ 5 ] [ 0 ] + '-' + powdered _base [ 5 ] [ 1 ] ) ;
// display
for ( const i in damage _keys ) {
document . getElementById ( damage _keys [ i ] + "-base" ) . textContent = powdered _map . get ( damage _keys [ i ] ) ;
}
}
2021-10-18 07:25:02 +07:00
function displaysq2FixedID ( active , id , value , elemental _format , style ) {
2021-10-17 22:53:48 +07:00
if ( style ) {
2021-10-21 21:11:04 +07:00
let row = document . createElement ( 'div' ) ;
row . classList . add ( "row" ) ;
let desc _elem = document . createElement ( 'div' ) ;
desc _elem . classList . add ( 'col' ) ;
desc _elem . classList . add ( 'text-start' ) ;
2021-10-17 22:53:48 +07:00
if ( elemental _format ) {
apply _elemental _format ( desc _elem , id ) ;
}
else {
desc _elem . textContent = idPrefixes [ id ] ;
}
row . appendChild ( desc _elem ) ;
2021-10-21 21:11:04 +07:00
let value _elem = document . createElement ( 'div' ) ;
value _elem . classList . add ( 'col' ) ;
value _elem . classList . add ( 'text-end' ) ;
2021-10-17 22:53:48 +07:00
value _elem . classList . add ( style ) ;
value _elem . textContent = value + idSuffixes [ id ] ;
row . appendChild ( value _elem ) ;
active . appendChild ( row ) ;
return row ;
}
else {
// HACK TO AVOID DISPLAYING ZERO DAMAGE! TODO
if ( value === "0-0" || value === "0-0\u279c0-0" ) {
return ;
}
let p _elem = document . createElement ( 'p' ) ;
p _elem . classList . add ( 'itemp' ) ;
if ( elemental _format ) {
apply _elemental _format ( p _elem , id , value ) ;
}
else {
p _elem . textContent = idPrefixes [ id ] . concat ( value , idSuffixes [ id ] ) ;
}
active . appendChild ( p _elem ) ;
return p _elem ;
}
}
2021-10-18 07:25:02 +07:00
function displaysq2PoisonDamage ( overallparent _elem , build ) {
2021-10-17 22:53:48 +07:00
overallparent _elem . textContent = "" ;
//Title
2021-10-21 21:11:04 +07:00
let title _elemavg = document . createElement ( "b" ) ;
2021-10-17 22:53:48 +07:00
title _elemavg . textContent = "Poison Stats" ;
overallparent _elem . append ( title _elemavg ) ;
let overallpoisonDamage = document . createElement ( "p" ) ;
2021-10-21 21:11:04 +07:00
let overallpoisonDamageFirst = document . createElement ( "span" ) ;
let overallpoisonDamageSecond = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
let poison _tick = Math . ceil ( build . statMap . get ( "poison" ) * ( 1 + skillPointsToPercentage ( build . total _skillpoints [ 0 ] ) ) * ( build . statMap . get ( "poisonPct" ) + build . externalStats . get ( "poisonPct" ) ) / 100 / 3 ) ;
overallpoisonDamageFirst . textContent = "Poison Tick: " ;
overallpoisonDamageSecond . textContent = Math . max ( poison _tick , 0 ) ;
overallpoisonDamageSecond . classList . add ( "Damage" ) ;
overallpoisonDamage . appendChild ( overallpoisonDamageFirst ) ;
overallpoisonDamage . appendChild ( overallpoisonDamageSecond ) ;
overallparent _elem . append ( overallpoisonDamage ) ;
}
2021-10-18 07:25:02 +07:00
function displaysq2MeleeDamage ( parent _elem , overallparent _elem , meleeStats ) {
2021-10-21 21:11:04 +07:00
// console.log("Melee Stats");
// console.log(meleeStats);
2021-10-17 22:53:48 +07:00
let tooltipinfo = meleeStats [ 13 ] ;
let attackSpeeds = [ "Super Slow" , "Very Slow" , "Slow" , "Normal" , "Fast" , "Very Fast" , "Super Fast" ] ;
//let damagePrefixes = ["Neutral Damage: ","Earth Damage: ","Thunder Damage: ","Water Damage: ","Fire Damage: ","Air Damage: "];
parent _elem . textContent = "" ;
overallparent _elem . textContent = "" ;
const stats = meleeStats . slice ( ) ;
for ( let i = 0 ; i < 6 ; ++ i ) {
for ( let j in stats [ i ] ) {
stats [ i ] [ j ] = stats [ i ] [ j ] . toFixed ( 2 ) ;
}
}
for ( let i = 6 ; i < 8 ; ++ i ) {
for ( let j = 0 ; j < 2 ; j ++ ) {
stats [ i ] [ j ] = stats [ i ] [ j ] . toFixed ( 2 ) ;
}
}
for ( let i = 8 ; i < 11 ; ++ i ) {
stats [ i ] = stats [ i ] . toFixed ( 2 ) ;
}
//tooltipelem, tooltiptext
let tooltip ; let tooltiptext ;
//title
let title _elem = document . createElement ( "p" ) ;
title _elem . classList . add ( "title" ) ;
title _elem . textContent = "Melee Stats" ;
parent _elem . append ( title _elem ) ;
parent _elem . append ( document . createElement ( "br" ) ) ;
//overall title
2021-10-21 21:11:04 +07:00
let title _elemavg = document . createElement ( "b" ) ;
2021-10-17 22:53:48 +07:00
title _elemavg . textContent = "Melee Stats" ;
overallparent _elem . append ( title _elemavg ) ;
//average DPS
let averageDamage = document . createElement ( "p" ) ;
averageDamage . classList . add ( "left" ) ;
averageDamage . textContent = "Average DPS: " + stats [ 10 ] ;
tooltiptext = ` = (( ${ stats [ 8 ] } * ${ ( stats [ 6 ] [ 2 ] ) . toFixed ( 2 ) } ) + ( ${ stats [ 9 ] } * ${ ( stats [ 7 ] [ 2 ] ) . toFixed ( 2 ) } )) `
tooltip = createTooltip ( tooltip , "p" , tooltiptext , averageDamage , [ "melee-tooltip" ] ) ;
averageDamage . appendChild ( tooltip ) ;
parent _elem . append ( averageDamage ) ;
//overall average DPS
let overallaverageDamage = document . createElement ( "p" ) ;
2021-10-21 21:11:04 +07:00
let overallaverageDamageFirst = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
overallaverageDamageFirst . textContent = "Average DPS: "
2021-10-21 21:11:04 +07:00
let overallaverageDamageSecond = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
overallaverageDamageSecond . classList . add ( "Damage" ) ;
overallaverageDamageSecond . textContent = stats [ 10 ] ;
overallaverageDamage . appendChild ( overallaverageDamageFirst ) ;
overallaverageDamage . appendChild ( overallaverageDamageSecond ) ;
overallparent _elem . append ( overallaverageDamage ) ;
//overallparent_elem.append(document.createElement("br"));
//attack speed
let atkSpd = document . createElement ( "p" ) ;
atkSpd . classList . add ( "left" ) ;
atkSpd . textContent = "Attack Speed: " + attackSpeeds [ stats [ 11 ] ] ;
parent _elem . append ( atkSpd ) ;
parent _elem . append ( document . createElement ( "br" ) ) ;
//overall attack speed
let overallatkSpd = document . createElement ( "p" ) ;
2021-10-21 21:11:04 +07:00
let overallatkSpdFirst = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
overallatkSpdFirst . textContent = "Attack Speed: " ;
2021-10-21 21:11:04 +07:00
let overallatkSpdSecond = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
overallatkSpdSecond . classList . add ( "Damage" ) ;
overallatkSpdSecond . textContent = attackSpeeds [ stats [ 11 ] ] ;
overallatkSpd . appendChild ( overallatkSpdFirst ) ;
overallatkSpd . appendChild ( overallatkSpdSecond ) ;
overallparent _elem . append ( overallatkSpd ) ;
//Non-Crit: n->elem, total dmg, DPS
let nonCritStats = document . createElement ( "p" ) ;
nonCritStats . classList . add ( "left" ) ;
nonCritStats . textContent = "Non-Crit Stats: " ;
nonCritStats . append ( document . createElement ( "br" ) ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( stats [ i ] [ 1 ] != 0 ) {
let dmg = document . createElement ( "p" ) ;
dmg . textContent = stats [ i ] [ 0 ] + " \u2013 " + stats [ i ] [ 1 ] ;
dmg . classList . add ( damageClasses [ i ] ) ;
dmg . classList . add ( "itemp" ) ;
tooltiptext = tooltipinfo . get ( "damageformulas" ) [ i ] . slice ( 0 , 2 ) . join ( "\n" ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , dmg , [ "melee-tooltip" ] ) ;
nonCritStats . append ( dmg ) ;
}
}
let normalDamage = document . createElement ( "p" ) ;
normalDamage . textContent = "Total: " + stats [ 6 ] [ 0 ] + " \u2013 " + stats [ 6 ] [ 1 ] ;
let tooltiparr = [ "Min: = " , "Max: = " ]
let arr = [ ] ; let arr2 = [ ] ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( stats [ i ] [ 0 ] != 0 ) {
arr . push ( stats [ i ] [ 0 ] ) ;
arr2 . push ( stats [ i ] [ 1 ] ) ;
}
}
tooltiptext = tooltiparr [ 0 ] + arr . join ( " + " ) + "\n" + tooltiparr [ 1 ] + arr2 . join ( " + " ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , normalDamage , [ "melee-tooltip" ] ) ;
nonCritStats . append ( normalDamage ) ;
let normalDPS = document . createElement ( "p" ) ;
normalDPS . textContent = "Normal DPS: " + stats [ 8 ] ;
normalDPS . classList . add ( "tooltip" ) ;
tooltiptext = ` = (( ${ stats [ 6 ] [ 0 ] } + ${ stats [ 6 ] [ 1 ] } ) / 2) * ${ baseDamageMultiplier [ stats [ 11 ] ] } ` ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , normalDPS , [ "melee-tooltip" ] ) ;
nonCritStats . append ( normalDPS ) ;
//overall average DPS
let singleHitDamage = document . createElement ( "p" ) ;
2021-10-21 21:11:04 +07:00
let singleHitDamageFirst = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
singleHitDamageFirst . textContent = "Single Hit Average: " ;
2021-10-21 21:11:04 +07:00
let singleHitDamageSecond = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
singleHitDamageSecond . classList . add ( "Damage" ) ;
singleHitDamageSecond . textContent = stats [ 12 ] . toFixed ( 2 ) ;
tooltiptext = ` = (( ${ stats [ 6 ] [ 0 ] } + ${ stats [ 6 ] [ 1 ] } ) / 2) * ${ stats [ 6 ] [ 2 ] . toFixed ( 2 ) } + (( ${ stats [ 7 ] [ 0 ] } + ${ stats [ 7 ] [ 1 ] } ) / 2) * ${ stats [ 7 ] [ 2 ] . toFixed ( 2 ) } ` ;
// tooltip = createTooltip(tooltip, "p", tooltiptext, singleHitDamage, ["melee-tooltip", "summary-tooltip"]);
singleHitDamage . appendChild ( singleHitDamageFirst ) ;
singleHitDamage . appendChild ( singleHitDamageSecond ) ;
overallparent _elem . append ( singleHitDamage ) ;
let normalChance = document . createElement ( "p" ) ;
normalChance . textContent = "Non-Crit Chance: " + ( stats [ 6 ] [ 2 ] * 100 ) . toFixed ( 2 ) + "%" ;
normalChance . append ( document . createElement ( "br" ) ) ;
normalChance . append ( document . createElement ( "br" ) ) ;
nonCritStats . append ( normalChance ) ;
parent _elem . append ( nonCritStats ) ;
parent _elem . append ( document . createElement ( "br" ) ) ;
//Crit: n->elem, total dmg, DPS
let critStats = document . createElement ( "p" ) ;
critStats . classList . add ( "left" ) ;
critStats . textContent = "Crit Stats: " ;
critStats . append ( document . createElement ( "br" ) ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( stats [ i ] [ 3 ] != 0 ) {
dmg = document . createElement ( "p" ) ;
dmg . textContent = stats [ i ] [ 2 ] + " \u2013 " + stats [ i ] [ 3 ] ;
dmg . classList . add ( damageClasses [ i ] ) ;
dmg . classList . add ( "itemp" ) ;
tooltiptext = tooltipinfo . get ( "damageformulas" ) [ i ] . slice ( 2 , 4 ) . join ( "\n" ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , dmg , [ "melee-tooltip" ] ) ;
critStats . append ( dmg ) ;
}
}
let critDamage = document . createElement ( "p" ) ;
critDamage . textContent = "Total: " + stats [ 7 ] [ 0 ] + " \u2013 " + stats [ 7 ] [ 1 ] ;
tooltiparr = [ "Min: = " , "Max: = " ]
arr = [ ] ; arr2 = [ ] ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( stats [ i ] [ 0 ] != 0 ) {
arr . push ( stats [ i ] [ 2 ] ) ;
arr2 . push ( stats [ i ] [ 3 ] ) ;
}
}
tooltiptext = tooltiparr [ 0 ] + arr . join ( " + " ) + "\n" + tooltiparr [ 1 ] + arr2 . join ( " + " ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , critDamage , [ "melee-tooltip" ] ) ;
critStats . append ( critDamage ) ;
let critDPS = document . createElement ( "p" ) ;
critDPS . textContent = "Crit DPS: " + stats [ 9 ] ;
tooltiptext = ` = (( ${ stats [ 7 ] [ 0 ] } + ${ stats [ 7 ] [ 1 ] } ) / 2) * ${ baseDamageMultiplier [ stats [ 11 ] ] } ` ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , critDPS , [ "melee-tooltip" ] ) ;
critStats . append ( critDPS ) ;
let critChance = document . createElement ( "p" ) ;
critChance . textContent = "Crit Chance: " + ( stats [ 7 ] [ 2 ] * 100 ) . toFixed ( 2 ) + "%" ;
critChance . append ( document . createElement ( "br" ) ) ;
critChance . append ( document . createElement ( "br" ) ) ;
critStats . append ( critChance ) ;
parent _elem . append ( critStats ) ;
}
2021-10-18 07:25:02 +07:00
function displaysq2ArmorStats ( build ) {
2021-10-17 22:53:48 +07:00
let armor _keys = [ 'helmet' , 'chestplate' , 'leggings' , 'boots' , 'ring1' , 'ring2' , 'bracelet' , 'necklace' ] ;
for ( const i in armor _keys ) {
document . getElementById ( armor _keys [ i ] + '-health' ) . textContent = build [ armor _keys [ i ] ] . get ( 'hp' ) ;
document . getElementById ( armor _keys [ i ] + '-lv' ) . textContent = build [ armor _keys [ i ] ] . get ( 'lvl' ) ;
}
}
2021-10-18 07:25:02 +07:00
function displaysq2DefenseStats ( parent _elem , build , insertSummary ) {
2021-10-17 22:53:48 +07:00
let defenseStats = build . getDefenseStats ( ) ;
insertSummary = ( typeof insertSummary !== 'undefined' ) ? insertSummary : false ;
if ( ! insertSummary ) {
parent _elem . textContent = "" ;
}
const stats = defenseStats . slice ( ) ;
// parent_elem.append(document.createElement("br"));
2021-10-21 21:11:04 +07:00
let statsTable = document . createElement ( "div" ) ;
2021-10-17 22:53:48 +07:00
//[total hp, ehp, total hpr, ehpr, [def%, agi%], [edef,tdef,wdef,fdef,adef]]
for ( const i in stats ) {
if ( typeof stats [ i ] === "number" ) {
stats [ i ] = stats [ i ] . toFixed ( 2 ) ;
} else {
for ( const j in stats [ i ] ) {
stats [ i ] [ j ] = stats [ i ] [ j ] . toFixed ( 2 ) ;
}
}
}
//total HP
2021-10-21 21:11:04 +07:00
let hpRow = document . createElement ( "div" ) ;
hpRow . classList . add ( 'row' ) ;
let hp = document . createElement ( "div" ) ;
hp . classList . add ( 'col' ) ;
2021-10-17 22:53:48 +07:00
hp . classList . add ( "Health" ) ;
2021-10-21 21:11:04 +07:00
hp . classList . add ( "text-start" ) ;
2021-10-17 22:53:48 +07:00
hp . textContent = "Total HP:" ;
2021-10-21 21:11:04 +07:00
let boost = document . createElement ( "div" ) ;
boost . classList . add ( 'col' ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = stats [ 0 ] ;
2021-10-21 21:11:04 +07:00
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
hpRow . appendChild ( hp ) ;
hpRow . append ( boost ) ;
if ( insertSummary ) {
parent _elem . appendChild ( hpRow ) ;
} else {
statsTable . appendChild ( hpRow ) ;
}
let tooltip ; let tooltiptext ;
let defMult = build . statMap . get ( "defMult" ) ;
if ( ! defMult ) { defMult = 1 }
//EHP
2021-10-21 21:11:04 +07:00
let ehpRow = document . createElement ( "div" ) ;
ehpRow . classList . add ( "row" ) ;
let ehp = document . createElement ( "div" ) ;
ehp . classList . add ( "col" ) ;
ehp . classList . add ( "text-start" ) ;
2021-10-17 22:53:48 +07:00
ehp . textContent = "Effective HP:" ;
2021-10-21 21:11:04 +07:00
boost = document . createElement ( "div" ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = stats [ 1 ] [ 0 ] ;
2021-10-21 21:11:04 +07:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
tooltiptext = ` = ${ stats [ 0 ] } / ((1 - ${ skillPointsToPercentage ( build . total _skillpoints [ 3 ] ) . toFixed ( 3 ) } ) * (1 - ${ skillPointsToPercentage ( build . total _skillpoints [ 4 ] ) . toFixed ( 3 ) } ) * (2 - ${ defMult } ) * (2 - ${ build . defenseMultiplier } )) `
// tooltip = createTooltip(tooltip, "p", tooltiptext, boost, ["def-tooltip"]);
ehpRow . appendChild ( ehp ) ;
ehpRow . append ( boost ) ;
if ( insertSummary ) {
parent _elem . appendChild ( ehpRow )
} else {
statsTable . append ( ehpRow ) ;
}
2021-10-21 21:11:04 +07:00
ehpRow = document . createElement ( "div" ) ;
ehpRow . classList . add ( "row" ) ;
ehp = document . createElement ( "div" ) ;
ehp . classList . add ( "col" ) ;
ehp . classList . add ( "text-start" ) ;
2021-10-17 22:53:48 +07:00
ehp . textContent = "Effective HP (no agi):" ;
2021-10-21 21:11:04 +07:00
boost = document . createElement ( "div" ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = stats [ 1 ] [ 1 ] ;
2021-10-21 21:11:04 +07:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
tooltiptext = ` = ${ stats [ 0 ] } / ((1 - ${ skillPointsToPercentage ( build . total _skillpoints [ 3 ] ) . toFixed ( 3 ) } ) * (2 - ${ defMult } ) * (2 - ${ build . defenseMultiplier } )) `
// tooltip = createTooltip(tooltip, "p", tooltiptext, boost, ["def-tooltip"]);
ehpRow . appendChild ( ehp ) ;
ehpRow . append ( boost ) ;
statsTable . append ( ehpRow ) ;
//total HPR
2021-10-21 21:11:04 +07:00
let hprRow = document . createElement ( "div" ) ;
hprRow . classList . add ( "row" )
let hpr = document . createElement ( "div" ) ;
2021-10-17 22:53:48 +07:00
hpr . classList . add ( "Health" ) ;
2021-10-21 21:11:04 +07:00
hpr . classList . add ( "col" ) ;
hpr . classList . add ( "text-start" ) ;
2021-10-17 22:53:48 +07:00
hpr . textContent = "HP Regen (Total):" ;
2021-10-21 21:11:04 +07:00
boost = document . createElement ( "div" ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = stats [ 2 ] ;
2021-10-21 21:11:04 +07:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
hprRow . appendChild ( hpr ) ;
hprRow . appendChild ( boost ) ;
if ( insertSummary ) {
parent _elem . appendChild ( hprRow ) ;
} else {
statsTable . appendChild ( hprRow ) ;
}
//EHPR
2021-10-21 21:11:04 +07:00
let ehprRow = document . createElement ( "div" ) ;
ehprRow . classList . add ( "row" )
let ehpr = document . createElement ( "div" ) ;
ehpr . classList . add ( "col" ) ;
ehpr . classList . add ( "text-start" ) ;
2021-10-17 22:53:48 +07:00
ehpr . textContent = "Effective HP Regen:" ;
2021-10-21 21:11:04 +07:00
boost = document . createElement ( "div" ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = stats [ 3 ] [ 0 ] ;
2021-10-21 21:11:04 +07:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
tooltiptext = ` = ${ stats [ 2 ] } / ((1 - ${ skillPointsToPercentage ( build . total _skillpoints [ 3 ] ) . toFixed ( 3 ) } ) * (1 - ${ skillPointsToPercentage ( build . total _skillpoints [ 4 ] ) . toFixed ( 3 ) } ) * (2 - ${ defMult } ) * (2 - ${ build . defenseMultiplier } )) `
// tooltip = createTooltip(tooltip, "p", tooltiptext, boost, ["def-tooltip"]);
ehprRow . appendChild ( ehpr ) ;
ehprRow . append ( boost ) ;
statsTable . append ( ehprRow ) ;
/ *
ehprRow = document . createElement ( "tr" ) ;
ehpr = document . createElement ( "td" ) ;
ehpr . classList . add ( "left" ) ;
ehpr . textContent = "Effective HP Regen (no agi):" ;
boost = document . createElement ( "td" ) ;
boost . textContent = stats [ 3 ] [ 1 ] ;
boost . classList . add ( "right" ) ;
ehprRow . appendChild ( ehpr ) ;
ehprRow . append ( boost ) ;
statsTable . append ( ehprRow ) ; * /
//eledefs
let eledefs = stats [ 5 ] ;
for ( let i = 0 ; i < eledefs . length ; i ++ ) {
2021-10-21 21:11:04 +07:00
let eledefElemRow = document . createElement ( "div" ) ;
eledefElemRow . classList . add ( "row" )
2021-10-17 22:53:48 +07:00
2021-10-21 21:11:04 +07:00
let eledef = document . createElement ( "div" ) ;
eledef . classList . add ( "col" ) ;
eledef . classList . add ( "text-start" ) ;
let eledefTitle = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
eledefTitle . textContent = damageClasses [ i + 1 ] ;
eledefTitle . classList . add ( damageClasses [ i + 1 ] ) ;
2021-10-21 21:11:04 +07:00
let defense = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
defense . textContent = " Def (Total): " ;
eledef . appendChild ( eledefTitle ) ;
eledef . appendChild ( defense ) ;
eledefElemRow . appendChild ( eledef ) ;
2021-10-21 21:11:04 +07:00
let boost = document . createElement ( "div" ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = eledefs [ i ] ;
boost . classList . add ( eledefs [ i ] >= 0 ? "positive" : "negative" ) ;
2021-10-21 21:11:04 +07:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
let defRaw = build . statMap . get ( "defRaw" ) [ i ] ;
let defPct = build . statMap . get ( "defBonus" ) [ i ] / 100 ;
if ( defRaw < 0 ) {
defPct >= 0 ? defPct = "- " + defPct : defPct = "+ " + defPct ;
tooltiptext = ` = min(0, ${ defRaw } * (1 ${ defPct } )) `
} else {
defPct >= 0 ? defPct = "+ " + defPct : defPct = "- " + defPct ;
tooltiptext = ` = ${ defRaw } * (1 ${ defPct } ) `
}
// tooltip = createTooltip(tooltip, "p", tooltiptext, boost, ["def-tooltip"]);
eledefElemRow . appendChild ( boost ) ;
if ( insertSummary ) {
parent _elem . appendChild ( eledefElemRow ) ;
} else {
statsTable . appendChild ( eledefElemRow ) ;
}
}
if ( ! insertSummary ) {
//skp
2021-10-21 21:11:04 +07:00
let defRow = document . createElement ( "div" ) ;
defRow . classList . add ( "row" ) ;
let defElem = document . createElement ( "div" ) ;
defElem . classList . add ( "col" ) ;
defElem . classList . add ( "text-start" ) ;
2021-10-17 22:53:48 +07:00
defElem . textContent = "Damage Absorbed %:" ;
2021-10-21 21:11:04 +07:00
boost = document . createElement ( "div" ) ;
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = stats [ 4 ] [ 0 ] + "%" ;
defRow . appendChild ( defElem ) ;
defRow . appendChild ( boost ) ;
statsTable . append ( defRow ) ;
2021-10-21 21:11:04 +07:00
let agiRow = document . createElement ( "div" ) ;
agiRow . classList . add ( "row" ) ;
let agiElem = document . createElement ( "div" ) ;
agiElem . classList . add ( "col" ) ;
agiElem . classList . add ( "text-start" ) ;
2021-10-17 22:53:48 +07:00
agiElem . textContent = "Dodge Chance %:" ;
2021-10-21 21:11:04 +07:00
boost = document . createElement ( "div" ) ;
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-10-17 22:53:48 +07:00
boost . textContent = stats [ 4 ] [ 1 ] + "%" ;
agiRow . appendChild ( agiElem ) ;
agiRow . appendChild ( boost ) ;
statsTable . append ( agiRow ) ;
}
if ( ! insertSummary ) {
parent _elem . append ( statsTable ) ;
}
}
2021-10-18 07:25:02 +07:00
function displaysq2PowderSpecials ( parent _elem , powderSpecials , build ) {
2021-10-17 22:53:48 +07:00
parent _elem . textContent = "Powder Specials" ;
let specials = powderSpecials . slice ( ) ;
let stats = build . statMap ;
let expandedStats = new Map ( ) ;
//each entry of powderSpecials is [ps, power]
for ( special of specials ) {
//iterate through the special and display its effects.
let powder _special = document . createElement ( "p" ) ;
powder _special . classList . add ( "left" ) ;
let specialSuffixes = new Map ( [ [ "Duration" , " sec" ] , [ "Radius" , " blocks" ] , [ "Chains" , "" ] , [ "Damage" , "%" ] , [ "Damage Boost" , "%" ] , [ "Knockback" , " blocks" ] ] ) ;
let specialTitle = document . createElement ( "p" ) ;
let specialEffects = document . createElement ( "p" ) ;
specialTitle . classList . add ( "left" ) ;
specialTitle . classList . add ( damageClasses [ powderSpecialStats . indexOf ( special [ 0 ] ) + 1 ] ) ;
specialEffects . classList . add ( "left" ) ;
let effects = special [ 0 ] [ "weaponSpecialEffects" ] ;
let power = special [ 1 ] ;
specialTitle . textContent = special [ 0 ] [ "weaponSpecialName" ] + " " + Math . floor ( ( power - 1 ) * 0.5 + 4 ) + ( power % 2 == 0 ? ".5" : "" ) ;
for ( const [ key , value ] of effects ) {
let effect = document . createElement ( "p" ) ;
effect . classList . add ( "item-margin" ) ;
effect . textContent += key + ": " + value [ power - 1 ] + specialSuffixes . get ( key ) ;
if ( key === "Damage" ) {
effect . textContent += elementIcons [ powderSpecialStats . indexOf ( special [ 0 ] ) ] ;
}
if ( special [ 0 ] [ "weaponSpecialName" ] === "Wind Prison" && key === "Damage Boost" ) {
effect . textContent += " (only 1st hit)" ;
}
specialEffects . appendChild ( effect ) ;
}
powder _special . appendChild ( specialTitle ) ;
powder _special . appendChild ( specialEffects ) ;
//if this special is an instant-damage special (Quake, Chain Lightning, Courage Burst), display the damage.
let specialDamage = document . createElement ( "p" ) ;
// specialDamage.classList.add("item-margin");
let spells = spell _table [ "powder" ] ;
if ( powderSpecialStats . indexOf ( special [ 0 ] ) == 0 || powderSpecialStats . indexOf ( special [ 0 ] ) == 1 || powderSpecialStats . indexOf ( special [ 0 ] ) == 3 ) { //Quake, Chain Lightning, or Courage
let spell = ( powderSpecialStats . indexOf ( special [ 0 ] ) == 3 ? spells [ 2 ] : spells [ powderSpecialStats . indexOf ( special [ 0 ] ) ] ) ;
let part = spell [ "parts" ] [ 0 ] ;
let _results = calculateSpellDamage ( stats , part . conversion ,
stats . get ( "mdRaw" ) , stats . get ( "mdPct" ) + build . externalStats . get ( "mdPct" ) ,
0 , build . weapon , build . total _skillpoints , build . damageMultiplier * ( ( part . multiplier [ power - 1 ] / 100 ) ) , build . externalStats ) ; //part.multiplier[power] / 100
let critChance = skillPointsToPercentage ( build . total _skillpoints [ 1 ] ) ;
let save _damages = [ ] ;
let totalDamNormal = _results [ 0 ] ;
let totalDamCrit = _results [ 1 ] ;
let results = _results [ 2 ] ;
for ( let i = 0 ; i < 6 ; ++ i ) {
for ( let j in results [ i ] ) {
results [ i ] [ j ] = results [ i ] [ j ] . toFixed ( 2 ) ;
}
}
let nonCritAverage = ( totalDamNormal [ 0 ] + totalDamNormal [ 1 ] ) / 2 || 0 ;
let critAverage = ( totalDamCrit [ 0 ] + totalDamCrit [ 1 ] ) / 2 || 0 ;
let averageDamage = ( 1 - critChance ) * nonCritAverage + critChance * critAverage || 0 ;
let averageLabel = document . createElement ( "p" ) ;
averageLabel . textContent = "Average: " + averageDamage . toFixed ( 2 ) ;
averageLabel . classList . add ( "damageSubtitle" ) ;
averageLabel . classList . add ( "item-margin" ) ;
specialDamage . append ( averageLabel ) ;
let nonCritLabel = document . createElement ( "p" ) ;
nonCritLabel . textContent = "Non-Crit Average: " + nonCritAverage . toFixed ( 2 ) ;
nonCritLabel . classList . add ( "damageSubtitle" ) ;
nonCritLabel . classList . add ( "item-margin" ) ;
specialDamage . append ( nonCritLabel ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( results [ i ] [ 1 ] > 0 ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "damagep" ) ;
p . classList . add ( damageClasses [ i ] ) ;
p . textContent = results [ i ] [ 0 ] + "-" + results [ i ] [ 1 ] ;
specialDamage . append ( p ) ;
}
}
let normalDamage = document . createElement ( "p" ) ;
normalDamage . textContent = "Total: " + totalDamNormal [ 0 ] . toFixed ( 2 ) + "-" + totalDamNormal [ 1 ] . toFixed ( 2 ) ;
normalDamage . classList . add ( "itemp" ) ;
specialDamage . append ( normalDamage ) ;
let nonCritChanceLabel = document . createElement ( "p" ) ;
nonCritChanceLabel . textContent = "Non-Crit Chance: " + ( ( 1 - critChance ) * 100 ) . toFixed ( 2 ) + "%" ;
specialDamage . append ( nonCritChanceLabel ) ;
let critLabel = document . createElement ( "p" ) ;
critLabel . textContent = "Crit Average: " + critAverage . toFixed ( 2 ) ;
critLabel . classList . add ( "damageSubtitle" ) ;
critLabel . classList . add ( "item-margin" ) ;
specialDamage . append ( critLabel ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( results [ i ] [ 1 ] > 0 ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "damagep" ) ;
p . classList . add ( damageClasses [ i ] ) ;
p . textContent = results [ i ] [ 2 ] + "-" + results [ i ] [ 3 ] ;
specialDamage . append ( p ) ;
}
}
let critDamage = document . createElement ( "p" ) ;
critDamage . textContent = "Total: " + totalDamCrit [ 0 ] . toFixed ( 2 ) + "-" + totalDamCrit [ 1 ] . toFixed ( 2 ) ;
critDamage . classList . add ( "itemp" ) ;
specialDamage . append ( critDamage ) ;
let critChanceLabel = document . createElement ( "p" ) ;
critChanceLabel . textContent = "Crit Chance: " + ( critChance * 100 ) . toFixed ( 2 ) + "%" ;
specialDamage . append ( critChanceLabel ) ;
save _damages . push ( averageDamage ) ;
powder _special . append ( specialDamage ) ;
}
parent _elem . appendChild ( powder _special ) ;
}
}
2021-10-18 07:25:02 +07:00
function displaysq2SpellDamage ( parent _elem , overallparent _elem , build , spell , spellIdx ) {
2021-10-17 22:53:48 +07:00
parent _elem . textContent = "" ;
let tooltip ; let tooltiptext ;
const stats = build . statMap ;
let title _elem = document . createElement ( "p" ) ;
overallparent _elem . textContent = "" ;
2021-10-21 21:11:04 +07:00
let title _elemavg = document . createElement ( "b" ) ;
2021-10-17 22:53:48 +07:00
if ( spellIdx != 0 ) {
2021-10-21 21:11:04 +07:00
let first = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
first . textContent = spell . title + " (" ;
title _elem . appendChild ( first . cloneNode ( true ) ) ; //cloneNode is needed here.
title _elemavg . appendChild ( first ) ;
2021-10-21 21:11:04 +07:00
let second = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
second . textContent = build . getSpellCost ( spellIdx , spell . cost ) ;
second . classList . add ( "Mana" ) ;
let int _redux = skillPointsToPercentage ( build . total _skillpoints [ 2 ] ) . toFixed ( 2 ) ;
let spPct _redux = ( build . statMap . get ( "spPct" + spellIdx ) / 100 ) . toFixed ( 2 ) ;
let spRaw _redux = ( build . statMap . get ( "spRaw" + spellIdx ) ) . toFixed ( 2 ) ;
spPct _redux >= 0 ? spPct _redux = "+ " + spPct _redux : spPct _redux = "- " + Math . abs ( spPct _redux ) ;
spRaw _redux >= 0 ? spRaw _redux = "+ " + spRaw _redux : spRaw _redux = "- " + Math . abs ( spRaw _redux ) ;
// tooltiptext = `= max(1, floor((ceil(${spell.cost} * (1 - ${int_redux})) ${spRaw_redux}) * (1 ${spPct_redux})))`;
// tooltip = createTooltip(tooltip, "p", tooltiptext, second, ["spellcostcalc"]);
// second.appendChild(tooltip);
title _elem . appendChild ( second . cloneNode ( true ) ) ;
title _elemavg . appendChild ( second ) ;
let third = document . createElement ( "p" ) ;
third . classList . add ( 'no-newline' ) ;
third . textContent = ") [Base: " + build . getBaseSpellCost ( spellIdx , spell . cost ) + " ]" ;
title _elem . appendChild ( third ) ;
2021-10-21 21:11:04 +07:00
let third _summary = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
third _summary . textContent = ")" ;
title _elemavg . appendChild ( third _summary ) ;
}
else {
title _elem . textContent = spell . title ;
title _elemavg . textContent = spell . title ;
}
parent _elem . append ( title _elem ) ;
overallparent _elem . append ( title _elemavg ) ;
let critChance = skillPointsToPercentage ( build . total _skillpoints [ 1 ] ) ;
let save _damages = [ ] ;
let part _divavg = document . createElement ( "p" ) ;
overallparent _elem . append ( part _divavg ) ;
let spell _parts ;
if ( spell . parts ) {
spell _parts = spell . parts ;
}
else {
spell _parts = spell . variants . DEFAULT ;
for ( const majorID of stats . get ( "activeMajorIDs" ) ) {
if ( majorID in spell . variants ) {
spell _parts = spell . variants [ majorID ] ;
break ;
}
}
}
//console.log(spell_parts);
for ( const part of spell _parts ) {
2021-10-21 21:11:04 +07:00
// parent_elem.append(document.createElement("br"));
2021-10-17 22:53:48 +07:00
let part _div = document . createElement ( "p" ) ;
parent _elem . append ( part _div ) ;
let subtitle _elem = document . createElement ( "p" ) ;
subtitle _elem . textContent = part . subtitle ;
part _div . append ( subtitle _elem ) ;
if ( part . type === "damage" ) {
//console.log(build.expandedStats);
let _results = calculateSpellDamage ( stats , part . conversion ,
stats . get ( "sdRaw" ) + stats . get ( "rainbowRaw" ) , stats . get ( "sdPct" ) + build . externalStats . get ( "sdPct" ) ,
part . multiplier / 100 , build . weapon , build . total _skillpoints , build . damageMultiplier , build . externalStats ) ;
let totalDamNormal = _results [ 0 ] ;
let totalDamCrit = _results [ 1 ] ;
let results = _results [ 2 ] ;
let tooltipinfo = _results [ 3 ] ;
for ( let i = 0 ; i < 6 ; ++ i ) {
for ( let j in results [ i ] ) {
results [ i ] [ j ] = results [ i ] [ j ] . toFixed ( 2 ) ;
}
}
let nonCritAverage = ( totalDamNormal [ 0 ] + totalDamNormal [ 1 ] ) / 2 || 0 ;
let critAverage = ( totalDamCrit [ 0 ] + totalDamCrit [ 1 ] ) / 2 || 0 ;
let averageDamage = ( 1 - critChance ) * nonCritAverage + critChance * critAverage || 0 ;
let averageLabel = document . createElement ( "p" ) ;
averageLabel . textContent = "Average: " + averageDamage . toFixed ( 2 ) ;
tooltiptext = ` = ((1 - ${ critChance } ) * ${ nonCritAverage . toFixed ( 2 ) } ) + ( ${ critChance } * ${ critAverage . toFixed ( 2 ) } ) `
// averageLabel.classList.add("damageSubtitle");
// tooltip = createTooltip(tooltip, "p", tooltiptext, averageLabel, ["spell-tooltip"]);
part _div . append ( averageLabel ) ;
if ( part . summary == true ) {
let overallaverageLabel = document . createElement ( "p" ) ;
2021-10-21 21:11:04 +07:00
let first = document . createElement ( "span" ) ;
let second = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
first . textContent = part . subtitle + " Average: " ;
second . textContent = averageDamage . toFixed ( 2 ) ;
overallaverageLabel . appendChild ( first ) ;
overallaverageLabel . appendChild ( second ) ;
// tooltip = createTooltip(tooltip, "p", tooltiptext, overallaverageLabel, ["spell-tooltip", "summary-tooltip"]);
second . classList . add ( "Damage" ) ;
overallaverageLabel . classList . add ( "itemp" ) ;
part _divavg . append ( overallaverageLabel ) ;
}
function _damage _display ( label _text , average , result _idx ) {
let label = document . createElement ( "p" ) ;
label . textContent = label _text + average . toFixed ( 2 ) ;
label . classList . add ( "damageSubtitle" ) ;
part _div . append ( label ) ;
let arrmin = [ ] ;
let arrmax = [ ] ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( results [ i ] [ 1 ] != 0 ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "damagep" ) ;
p . classList . add ( damageClasses [ i ] ) ;
p . textContent = results [ i ] [ result _idx ] + " \u2013 " + results [ i ] [ result _idx + 1 ] ;
tooltiptext = tooltipinfo . get ( "damageformulas" ) [ i ] . slice ( 0 , 2 ) . join ( "\n" ) ;
// tooltip = createTooltip(tooltip, "p", tooltiptext, p, ["spell-tooltip"]);
arrmin . push ( results [ i ] [ result _idx ] ) ;
arrmax . push ( results [ i ] [ result _idx + 1 ] ) ;
part _div . append ( p ) ;
}
}
tooltiptext = ` = (( ${ arrmin . join ( " + " ) } ) + ( ${ arrmax . join ( " + " ) } )) / 2 ` ;
// tooltip = createTooltip(tooltip, "p", tooltiptext, label, ["spell-tooltip"]);
}
_damage _display ( "Non-Crit Average: " , nonCritAverage , 0 ) ;
_damage _display ( "Crit Average: " , critAverage , 2 ) ;
save _damages . push ( averageDamage ) ;
} else if ( part . type === "heal" ) {
let heal _amount = ( part . strength * build . getDefenseStats ( ) [ 0 ] * Math . max ( 0.5 , Math . min ( 1.75 , 1 + 0.5 * stats . get ( "wDamPct" ) / 100 ) ) ) . toFixed ( 2 ) ;
tooltiptext = ` = ${ part . strength } * ${ build . getDefenseStats ( ) [ 0 ] } * max(0.5, min(1.75, 1 + 0.5 * ${ stats . get ( "wDamPct" ) / 100 } )) ` ;
let healLabel = document . createElement ( "p" ) ;
healLabel . textContent = heal _amount ;
// healLabel.classList.add("damagep");
// tooltip = createTooltip(tooltip, "p", tooltiptext, healLabel, ["spell-tooltip"]);
part _div . append ( healLabel ) ;
if ( part . summary == true ) {
let overallhealLabel = document . createElement ( "p" ) ;
2021-10-21 21:11:04 +07:00
let first = document . createElement ( "span" ) ;
let second = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
first . textContent = part . subtitle + ": " ;
second . textContent = heal _amount ;
overallhealLabel . appendChild ( first ) ;
second . classList . add ( "Set" ) ;
overallhealLabel . appendChild ( second ) ;
part _divavg . append ( overallhealLabel ) ;
}
} else if ( part . type === "total" ) {
let total _damage = 0 ;
tooltiptext = "" ;
for ( let i in part . factors ) {
total _damage += save _damages [ i ] * part . factors [ i ] ;
}
let dmgarr = part . factors . slice ( ) ;
dmgarr = dmgarr . map ( x => "(" + x + " * " + save _damages [ dmgarr . indexOf ( x ) ] . toFixed ( 2 ) + ")" ) ;
tooltiptext = " = " + dmgarr . join ( " + " ) ;
let averageLabel = document . createElement ( "p" ) ;
averageLabel . textContent = "Average: " + total _damage . toFixed ( 2 ) ;
averageLabel . classList . add ( "damageSubtitle" ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , averageLabel , [ "spell-tooltip" ] ) ;
part _div . append ( averageLabel ) ;
let overallaverageLabel = document . createElement ( "p" ) ;
2021-10-21 21:11:04 +07:00
let overallaverageLabelFirst = document . createElement ( "span" ) ;
let overallaverageLabelSecond = document . createElement ( "span" ) ;
2021-10-17 22:53:48 +07:00
overallaverageLabelFirst . textContent = "Average: " ;
overallaverageLabelSecond . textContent = total _damage . toFixed ( 2 ) ;
overallaverageLabelSecond . classList . add ( "Damage" ) ;
overallaverageLabel . appendChild ( overallaverageLabelFirst ) ;
overallaverageLabel . appendChild ( overallaverageLabelSecond ) ;
part _divavg . append ( overallaverageLabel ) ;
}
}
}