2021-03-05 16:28:00 +00:00
let nonRolledIDs = [ "name" , "lore" , "displayName" , "tier" , "set" , "slots" , "type" , "material" , "drop" , "quest" , "restrict" , "nDam" , "fDam" , "wDam" , "aDam" , "tDam" , "eDam" , "atkSpd" , "hp" , "fDef" , "wDef" , "aDef" , "tDef" , "eDef" , "lvl" , "classReq" , "strReq" , "dexReq" , "intReq" , "defReq" , "agiReq" , "str" , "dex" , "int" , "agi" , "def" , "fixID" , "category" , "id" , "skillpoints" , "reqs" , "nDam_" , "fDam_" , "wDam_" , "aDam_" , "tDam_" , "eDam_" , "majorIds" ] ;
2021-01-09 11:15:28 +00:00
let rolledIDs = [ "hprPct" , "mr" , "sdPct" , "mdPct" , "ls" , "ms" , "xpb" , "lb" , "ref" , "thorns" , "expd" , "spd" , "atkTier" , "poison" , "hpBonus" , "spRegen" , "eSteal" , "hprRaw" , "sdRaw" , "mdRaw" , "fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" , "fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" , "spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" , "rainbowRaw" , "sprint" , "sprintReg" , "jh" , "lq" , "gXp" , "gSpd" ] ;
2021-01-11 22:31:25 +00:00
let reversedIDs = [ "spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" ] ;
2021-01-24 20:33:00 +00:00
let colorMap = new Map (
[
[ "Normal" , "#fff" ] ,
[ "Unique" , "#ff5" ] ,
[ "Rare" , "#f5f" ] ,
[ "Legendary" , "#5ff" ] ,
[ "Fabled" , "#f55" ] ,
[ "Mythic" , "#a0a" ] ,
[ "Crafted" , "#0aa" ] ,
[ "Custom" , "#0aa" ] ,
[ "Set" , "#5f5" ]
]
) ;
2021-01-10 21:31:29 +00:00
2021-01-09 00:56:07 +00:00
function expandItem ( item , powders ) {
2021-01-07 22:44:52 +00:00
let minRolls = new Map ( ) ;
let maxRolls = new Map ( ) ;
let expandedItem = new Map ( ) ;
if ( item . fixID ) { //The item has fixed IDs.
expandedItem . set ( "fixID" , true ) ;
for ( const id of rolledIDs ) { //all rolled IDs are numerical
2021-01-10 21:01:59 +00:00
let val = ( item [ id ] || 0 ) ;
2021-01-08 05:36:57 +00:00
//if(item[id]) {
2021-01-10 21:01:59 +00:00
minRolls . set ( id , val ) ;
maxRolls . set ( id , val ) ;
2021-01-08 05:36:57 +00:00
//}
2021-01-07 22:44:52 +00:00
}
} else { //The item does not have fixed IDs.
for ( const id of rolledIDs ) {
2021-01-10 21:01:59 +00:00
let val = ( item [ id ] || 0 ) ;
if ( val > 0 ) { // positive rolled IDs
2021-01-11 22:31:25 +00:00
if ( reversedIDs . includes ( id ) ) {
2021-01-12 04:22:38 +00:00
maxRolls . set ( id , idRound ( val * 0.3 ) ) ;
minRolls . set ( id , idRound ( val * 1.3 ) ) ;
2021-01-11 22:39:20 +00:00
} else {
2021-01-11 22:31:25 +00:00
maxRolls . set ( id , idRound ( val * 1.3 ) ) ;
2021-01-12 04:22:38 +00:00
minRolls . set ( id , idRound ( val * 0.3 ) ) ;
2021-01-11 22:31:25 +00:00
}
2021-01-10 21:01:59 +00:00
} else if ( val < 0 ) { //negative rolled IDs
2021-01-09 13:25:19 +00:00
if ( reversedIDs . includes ( id ) ) {
2021-01-10 21:01:59 +00:00
maxRolls . set ( id , idRound ( val * 1.3 ) ) ;
minRolls . set ( id , idRound ( val * 0.7 ) ) ;
2021-01-07 22:44:52 +00:00
}
2021-01-09 13:25:19 +00:00
else {
2021-01-10 21:01:59 +00:00
minRolls . set ( id , idRound ( val * 1.3 ) ) ;
maxRolls . set ( id , idRound ( val * 0.7 ) ) ;
2021-01-09 13:25:19 +00:00
}
} else { //Id = 0
minRolls . set ( id , 0 ) ;
maxRolls . set ( id , 0 ) ;
2021-01-07 22:44:52 +00:00
}
}
}
for ( const id of nonRolledIDs ) {
2021-01-09 13:15:30 +00:00
expandedItem . set ( id , item [ id ] ) ;
2021-01-07 22:44:52 +00:00
}
expandedItem . set ( "minRolls" , minRolls ) ;
expandedItem . set ( "maxRolls" , maxRolls ) ;
2021-01-09 00:56:07 +00:00
expandedItem . set ( "powders" , powders ) ;
2021-01-30 08:50:25 +00:00
if ( item . category === "armor" ) {
2021-01-11 06:49:52 +00:00
for ( const id of powders ) {
let powder = powderStats [ id ] ;
let name = powderNames . get ( id ) ;
2021-01-15 10:24:52 +00:00
expandedItem . set ( name . charAt ( 0 ) + "Def" , ( expandedItem . get ( name . charAt ( 0 ) + "Def" ) || 0 ) + powder [ "defPlus" ] ) ;
expandedItem . set ( skp _elements [ ( skp _elements . indexOf ( name . charAt ( 0 ) ) + 4 ) % 5 ] + "Def" , ( expandedItem . get ( skp _elements [ ( skp _elements . indexOf ( name . charAt ( 0 ) ) + 4 ) % 5 ] + "Def" ) || 0 ) - powder [ "defMinus" ] ) ;
2021-01-11 06:49:52 +00:00
}
}
2021-01-07 22:44:52 +00:00
return expandedItem ;
}
2021-01-09 23:30:05 +00:00
2021-01-18 01:26:39 +00:00
/ * T a k e s i n a n i n g r e d i e n t o b j e c t a n d r e t u r n s a n e q u i v a l e n t M a p ( ) .
* /
function expandIngredient ( ing ) {
let expandedIng = new Map ( ) ;
let mapIds = [ 'consumableIDs' , 'itemIDs' , 'posMods' ] ;
for ( const id of mapIds ) {
let idMap = new Map ( ) ;
for ( const key of Object . keys ( ing [ id ] ) ) {
idMap . set ( key , ing [ id ] [ key ] ) ;
}
expandedIng . set ( id , idMap ) ;
}
2021-03-04 13:58:29 +00:00
let normIds = [ 'lvl' , 'name' , 'displayName' , 'tier' , 'skills' , 'id' ] ;
2021-01-18 01:26:39 +00:00
for ( const id of normIds ) {
expandedIng . set ( id , ing [ id ] ) ;
}
2021-01-28 00:52:34 +00:00
if ( ing [ 'isPowder' ] ) {
expandedIng . set ( "isPowder" , ing [ 'isPowder' ] ) ;
expandedIng . set ( "pid" , ing [ 'pid' ] ) ;
}
2021-01-18 01:26:39 +00:00
//now the actually hard one
let idMap = new Map ( ) ;
idMap . set ( "minRolls" , new Map ( ) ) ;
idMap . set ( "maxRolls" , new Map ( ) ) ;
for ( const field of ingFields ) {
let val = ( ing [ 'ids' ] [ field ] || 0 ) ;
2021-01-18 20:23:37 +00:00
idMap . get ( "minRolls" ) . set ( field , val [ 'minimum' ] ) ;
idMap . get ( "maxRolls" ) . set ( field , val [ 'maximum' ] ) ;
2021-01-18 01:26:39 +00:00
}
expandedIng . set ( "ids" , idMap ) ;
//console.log(expandedIng);
return expandedIng ;
}
/ * T a k e s i n a r e c i p e o b j e c t a n d r e t u r n s a n e q u i v a l e n t M a p ( ) .
* /
function expandRecipe ( recipe ) {
let expandedRecipe = new Map ( ) ;
2021-01-29 02:31:31 +00:00
let normIDs = [ "name" , "skill" , "type" , "id" ] ;
2021-01-18 01:26:39 +00:00
for ( const id of normIDs ) {
expandedRecipe . set ( id , recipe [ id ] ) ;
}
2021-03-14 07:55:08 +00:00
let rangeIDs = [ "durability" , "lvl" , "healthOrDamage" , "duration" , "basicDuration" ] ;
2021-01-18 01:26:39 +00:00
for ( const id of rangeIDs ) {
if ( recipe [ id ] ) {
expandedRecipe . set ( id , [ recipe [ id ] [ 'minimum' ] , recipe [ id ] [ 'maximum' ] ] ) ;
2021-01-18 20:23:37 +00:00
} else {
expandedRecipe . set ( id , [ 0 , 0 ] ) ;
}
2021-01-18 01:26:39 +00:00
}
2021-01-28 00:52:34 +00:00
expandedRecipe . set ( "materials" , [ new Map ( [ [ "item" , recipe [ 'materials' ] [ 0 ] [ 'item' ] ] , [ "amount" , recipe [ 'materials' ] [ 0 ] [ 'amount' ] ] ] ) , new Map ( [ [ "item" , recipe [ 'materials' ] [ 1 ] [ 'item' ] ] , [ "amount" , recipe [ 'materials' ] [ 1 ] [ 'amount' ] ] ] ) ] ) ;
2021-01-18 01:26:39 +00:00
//console.log(expandedRecipe);
return expandedRecipe ;
}
2021-01-09 23:30:05 +00:00
2021-01-08 17:30:36 +00:00
/ * A n i n d e p e n d e n t h e l p e r f u n c t i o n t h a t r o u n d s a r o l l e d I D t o t h e n e a r e s t i n t e g e r O R b r i n g s t h e r o l l a w a y f r o m 0 .
* @ param id
* /
function idRound ( id ) {
rounded = Math . round ( id ) ;
if ( rounded == 0 ) {
2021-01-09 23:30:05 +00:00
return 1 ; //this is a hack, will need changing along w/ rest of ID system if anything changes
2021-01-08 17:30:36 +00:00
} else {
return rounded ;
}
}
2021-01-09 11:56:10 +00:00
2021-01-18 20:23:37 +00:00
//Used for item IDs and ingredient id field IDs
2021-03-05 16:28:00 +00:00
let idPrefixes = { "displayName" : "" , "lvl" : "Combat Level Min: " , "classReq" : "Class Req: " , "strReq" : "Strength Min: " , "dexReq" : "Dexterity Min: " , "intReq" : "Intelligence Min: " , "defReq" : "Defense Min: " , "agiReq" : "Agility Min: " , "nDam_" : "Neutral Damage: " , "eDam_" : "Earth Damage: " , "tDam_" : "Thunder Damage: " , "wDam_" : "Water Damage: " , "fDam_" : "Fire Damage: " , "aDam_" : "Air Damage: " , "atkSpd" : "Attack Speed: " , "hp" : "Health : " , "eDef" : "Earth Defense: " , "tDef" : "Thunder Defense: " , "wDef" : "Water Defense: " , "fDef" : "Fire Defense: " , "aDef" : "Air Defense: " , "str" : "Strength: " , "dex" : "Dexterity: " , "int" : "Intelligence: " , "def" : "Defense: " , "agi" : "Agility: " , "hpBonus" : "Health Bonus: " , "hprRaw" : "Health Regen Raw: " , "hprPct" : "Health Regen %: " , "sdRaw" : "Raw Spell Damage: " , "sdPct" : "Spell Damage %: " , "mdRaw" : "Raw Melee Damage: " , "mdPct" : "Melee Damage %: " , "mr" : "Mana Regen: " , "ms" : "Mana Steal: " , "ref" : "Reflection: " , "ls" : "Life Steal: " , "poison" : "Poison: " , "thorns" : "Thorns: " , "expd" : "Exploding: " , "spd" : "Walk Speed Bonus: " , "atkTier" : "Attack Speed Bonus: " , "eDamPct" : "Earth Damage %: " , "tDamPct" : "Thunder Damage %: " , "wDamPct" : "Water Damage %: " , "fDamPct" : "Fire Damage %: " , "aDamPct" : "Air Damage %: " , "eDefPct" : "Earth Defense %: " , "tDefPct" : "Thunder Defense %: " , "wDefPct" : "Water Defense %: " , "fDefPct" : "Fire Defense %: " , "aDefPct" : "Air Defense %: " , "spPct1" : "1st Spell Cost %: " , "spRaw1" : "1st Spell Cost Raw: " , "spPct2" : "2nd Spell Cost %: " , "spRaw2" : "2nd Spell Cost Raw: " , "spPct3" : "3rd Spell Cost %: " , "spRaw3" : "3rd Spell Cost Raw: " , "spPct4" : "4th Spell Cost %: " , "spRaw4" : "4th Spell Cost Raw: " , "rainbowRaw" : "Rainbow Spell Damage Raw: " , "sprint" : "Sprint Bonus: " , "sprintReg" : "Sprint Regen Bonus: " , "jh" : "Jump Height: " , "xpb" : "Combat XP Bonus: " , "lb" : "Loot Bonus: " , "lq" : "Loot Quality: " , "spRegen" : "Soul Point Regen: " , "eSteal" : "Stealing: " , "gXp" : "Gathering XP Bonus: " , "gSpd" : "Gathering Speed Bonus: " , "slots" : "Powder Slots: " , "set" : "Set: " , "quest" : "Quest Req: " , "restrict" : "" , "lore" : "" } ;
2021-03-24 22:49:17 +00:00
let idSuffixes = { "displayName" : "" , "lvl" : "" , "classReq" : "" , "strReq" : "" , "dexReq" : "" , "intReq" : "" , "defReq" : "" , "agiReq" : "" , "nDam_" : "" , "eDam_" : "" , "tDam_" : "" , "wDam_" : "" , "fDam_" : "" , "aDam_" : "" , "atkSpd" : "" , "hp" : "" , "eDef" : "" , "tDef" : "" , "wDef" : "" , "fDef" : "" , "aDef" : "" , "str" : "" , "dex" : "" , "int" : "" , "def" : "" , "agi" : "" , "hpBonus" : "" , "hprRaw" : "" , "hprPct" : "%" , "sdRaw" : "" , "sdPct" : "%" , "mdRaw" : "" , "mdPct" : "%" , "mr" : "/5s" , "ms" : "/3s" , "ref" : "%" , "ls" : "/3s" , "poison" : "/3s" , "thorns" : "%" , "expd" : "%" , "spd" : "%" , "atkTier" : " tier" , "eDamPct" : "%" , "tDamPct" : "%" , "wDamPct" : "%" , "fDamPct" : "%" , "aDamPct" : "%" , "eDefPct" : "%" , "tDefPct" : "%" , "wDefPct" : "%" , "fDefPct" : "%" , "aDefPct" : "%" , "spPct1" : "%" , "spRaw1" : "" , "spPct2" : "%" , "spRaw2" : "" , "spPct3" : "%" , "spRaw3" : "" , "spPct4" : "%" , "spRaw4" : "" , "rainbowRaw" : "" , "sprint" : "%" , "sprintReg" : "%" , "jh" : "" , "xpb" : "%" , "lb" : "%" , "lq" : "%" , "spRegen" : "%" , "eSteal" : "%" , "gXp" : "%" , "gSpd" : "%" , "slots" : "" , "set" : " set." , "quest" : "" , "restrict" : "" , "lore" : "" } ;
2021-01-18 20:23:37 +00:00
//Used for ingredient IDs - name, lvl, tier. As of now, not used.
/ * l e t i n g P r e f i x e s = { " n a m e " : " " , " l v l " : " " , " t i e r " : " " } ;
let ingSuffixes = { "name" : "" , "lvl" : "" , "tier" : "" } * /
//Used for ingredient consumableIDs
let consumableIDPrefixes = {
"charges" : "Charges: " ,
"dura" : "Duration: "
}
let consumableIDSuffixes = {
"charges" : "" ,
2021-01-19 17:32:27 +00:00
"dura" : " sec."
2021-01-18 20:23:37 +00:00
}
//Used for ingredient itemIDs
let itemIDPrefixes = {
"dura" : "Durability: " ,
"strReq" : "Strength Min: " ,
"dexReq" : "Dexterity Min: " ,
"intReq" : "Intelligence Min: " ,
"defReq" : "Defense Min: " ,
"agiReq" : "Agility Min: "
}
/ * l e t i t e m I D S u f f i x e s = {
"dura" : "" ,
"strReq" : "" ,
"dexReq" : "" ,
"intReq" : "" ,
"defReq" : "" ,
"agiReq" : ""
} * /
//Used for ingredient posMods IDs
let posModPrefixes = {
"left" : "Effectiveness Left: " ,
"right" : "EFfectiveness Right: " ,
"above" : "Effectiveness Above: " ,
2021-01-19 17:32:27 +00:00
"under" : "Effectiveness Under: " ,
2021-01-18 20:23:37 +00:00
"touching" : "EFfectiveness Touching: " ,
"notTouching" : "Effectiveness Not Touching: "
}
let posModSuffixes = {
"left" : "%" ,
"right" : "%" ,
"above" : "%" ,
2021-01-19 17:32:27 +00:00
"under" : "%" ,
2021-01-18 20:23:37 +00:00
"touching" : "%" ,
"notTouching" : "%"
}
2021-01-09 12:47:25 +00:00
function apply _elemental _format ( p _elem , id , suffix ) {
suffix = ( typeof suffix !== 'undefined' ) ? suffix : "" ;
// THIS IS SO JANK BUT IM TOO LAZY TO FIX IT TODO
let parts = idPrefixes [ id ] . split ( / (.*)/ ) ;
let element _prefix = parts [ 0 ] ;
let desc = parts [ 1 ] ;
let i _elem = document . createElement ( 'b' ) ;
i _elem . classList . add ( element _prefix ) ;
i _elem . textContent = element _prefix ;
p _elem . appendChild ( i _elem ) ;
let i _elem2 = document . createElement ( 'b' ) ;
i _elem2 . textContent = " " + desc + suffix ;
p _elem . appendChild ( i _elem2 ) ;
}
2021-01-15 18:20:17 +00:00
function displaySetBonuses ( parent _id , build ) {
2021-01-10 21:01:59 +00:00
setHTML ( parent _id , "" ) ;
let parent _div = document . getElementById ( parent _id ) ;
let set _summary _elem = document . createElement ( 'p' ) ;
set _summary _elem . classList . add ( 'itemcenter' ) ;
set _summary _elem . textContent = "Set Bonuses:" ;
parent _div . append ( set _summary _elem ) ;
2021-01-13 02:48:00 +00:00
if ( build . activeSetCounts . size ) {
2021-01-14 02:13:41 +00:00
parent _div . parentElement . style . display = "block" ;
2021-01-13 02:48:00 +00:00
} else {
2021-01-14 02:13:41 +00:00
parent _div . parentElement . style . display = "none" ;
2021-01-13 02:48:00 +00:00
}
2021-01-10 21:01:59 +00:00
for ( const [ setName , count ] of build . activeSetCounts ) {
2021-02-04 10:55:15 +00:00
const active _set = sets [ setName ] ;
if ( active _set [ "hidden" ] ) { continue ; }
2021-01-10 21:01:59 +00:00
let set _elem = document . createElement ( 'p' ) ;
set _elem . id = "set-" + setName ;
set _summary _elem . append ( set _elem ) ;
2021-02-04 10:55:15 +00:00
const bonus = active _set . bonuses [ count - 1 ] ;
2021-01-10 21:01:59 +00:00
let mock _item = new Map ( ) ;
mock _item . set ( "fixID" , true ) ;
mock _item . set ( "displayName" , setName + " Set: " + count + "/" + sets [ setName ] . items . length ) ;
let mock _minRolls = new Map ( ) ;
2021-03-16 22:43:44 +00:00
let mock _maxRolls = new Map ( ) ;
2021-01-10 21:01:59 +00:00
mock _item . set ( "minRolls" , mock _minRolls ) ;
2021-03-16 22:43:44 +00:00
mock _item . set ( "maxRolls" , mock _maxRolls ) ;
2021-01-10 21:01:59 +00:00
for ( const id in bonus ) {
if ( rolledIDs . includes ( id ) ) {
mock _minRolls . set ( id , bonus [ id ] ) ;
2021-03-16 22:43:44 +00:00
mock _maxRolls . set ( id , bonus [ id ] ) ;
2021-01-10 21:01:59 +00:00
}
else {
mock _item . set ( id , bonus [ id ] ) ;
}
}
2021-01-11 12:19:15 +00:00
mock _item . set ( "powders" , [ ] ) ;
2021-01-10 21:01:59 +00:00
displayExpandedItem ( mock _item , set _elem . id ) ;
2021-03-16 22:43:44 +00:00
console . log ( mock _item ) ;
2021-01-10 21:01:59 +00:00
}
}
2021-03-24 22:49:17 +00:00
2021-01-15 18:20:17 +00:00
function displayBuildStats ( parent _id , build ) {
2021-01-09 12:47:25 +00: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 = [
2021-01-11 22:25:55 +00:00
// "#ldiv",
// "!elemental",
// "hp",
// "fDef", "wDef", "aDef", "tDef", "eDef",
// "!elemental",
2021-01-20 05:59:17 +00:00
// "#table",
2021-01-11 22:25:55 +00:00
// "hprRaw", "hprPct",
2021-01-11 22:26:35 +00:00
"#table" ,
2021-01-20 05:59:17 +00:00
"str" , "dex" , "int" , "def" , "agi" ,
"mr" , "ms" ,
2021-01-21 21:15:05 +00:00
"hprRaw" , "hprPct" ,
2021-01-09 12:47:25 +00:00
"sdRaw" , "sdPct" ,
"mdRaw" , "mdPct" ,
"ref" , "thorns" ,
"ls" ,
"poison" ,
"expd" ,
"spd" ,
"atkTier" ,
"!elemental" ,
"fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" ,
2021-01-11 22:25:55 +00:00
// "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct",
2021-01-09 12:47:25 +00:00
"!elemental" ,
"spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" ,
"rainbowRaw" ,
"sprint" , "sprintReg" ,
"jh" ,
"xpb" , "lb" , "lq" ,
"spRegen" ,
"eSteal" ,
"gXp" , "gSpd" ,
] ;
// Clear the parent div.
setHTML ( parent _id , "" ) ;
let parent _div = document . getElementById ( parent _id ) ;
2021-01-10 21:31:29 +00:00
let title = document . createElement ( "p" ) ;
title . classList . add ( "itemcenter" ) ;
title . classList . add ( "itemp" ) ;
title . classList . add ( "title" ) ;
title . classList . add ( "Normal" ) ;
title . textContent = "Overall Build Stats" ;
parent _div . append ( title ) ;
parent _div . append ( document . createElement ( "br" ) ) ;
2021-01-09 12:47:25 +00:00
2021-01-11 21:33:03 +00:00
if ( build . activeSetCounts . size > 0 ) {
let set _summary _elem = document . createElement ( 'p' ) ;
set _summary _elem . classList . add ( 'itemp' ) ;
set _summary _elem . classList . add ( 'left' ) ;
set _summary _elem . textContent = "Set Summary:" ;
parent _div . append ( set _summary _elem ) ;
for ( const [ setName , count ] of build . activeSetCounts ) {
2021-02-04 10:55:15 +00:00
const active _set = sets [ setName ] ;
if ( active _set [ "hidden" ] ) { continue ; }
2021-01-11 21:33:03 +00:00
let set _elem = document . createElement ( 'p' ) ;
set _elem . classList . add ( 'itemp' ) ;
set _elem . classList . add ( 'left' ) ;
set _elem . textContent = " " + setName + " Set: " + count + "/" + sets [ setName ] . items . length ;
set _summary _elem . append ( set _elem ) ;
}
2021-01-10 21:01:59 +00:00
}
2021-01-11 22:25:55 +00:00
displayDefenseStats ( parent _div , build , true ) ;
2021-01-09 12:47:25 +00:00
let stats = build . statMap ;
2021-01-11 22:25:55 +00:00
//console.log(build.statMap);
2021-01-09 12:47:25 +00:00
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 ) {
if ( command . charAt ( 0 ) === "#" ) {
if ( command === "#cdiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'itemcenter' ) ;
}
else if ( command === "#ldiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'itemleft' ) ;
}
else if ( command === "#table" ) {
active _elem = document . createElement ( 'table' ) ;
active _elem . classList . add ( 'itemtable' ) ;
}
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 ( stats . get ( id ) ) {
let style = null ;
if ( ! staticIDs . includes ( id ) ) {
style = "positive" ;
if ( stats . get ( id ) < 0 ) {
style = "negative" ;
}
}
2021-01-11 07:05:23 +00:00
let id _val = stats . get ( id ) ;
2021-03-16 06:11:59 +00:00
if ( reversedIDs . includes ( id ) ) {
2021-01-11 17:52:21 +00:00
style === "positive" ? style = "negative" : style = "positive" ;
}
2021-01-14 06:58:32 +00:00
if ( id === "poison" && id _val > 0 ) {
id _val = Math . round ( id _val * ( build . statMap . get ( "poisonPct" ) + build . externalStats . get ( "poisonPct" ) ) / 100 ) ;
}
2021-01-11 07:05:23 +00:00
displayFixedID ( active _elem , id , id _val , elemental _format , style ) ;
if ( id === "poison" && id _val > 0 ) {
let style = "positive" ;
let row = document . createElement ( 'tr' ) ;
let value _elem = document . createElement ( 'td' ) ;
value _elem . classList . add ( 'right' ) ;
value _elem . setAttribute ( "colspan" , "2" ) ;
let prefix _elem = document . createElement ( 'b' ) ;
2021-01-28 00:52:34 +00:00
prefix _elem . textContent = "\u279C With Strength: " ;
2021-01-11 07:05:23 +00:00
let number _elem = document . createElement ( 'b' ) ;
number _elem . classList . add ( style ) ;
2021-01-14 06:58:32 +00:00
number _elem . textContent = ( id _val * ( 1 + skillPointsToPercentage ( build . total _skillpoints [ 0 ] ) ) ) . toFixed ( 0 ) + idSuffixes [ id ] ;
2021-01-11 07:05:23 +00:00
value _elem . append ( prefix _elem ) ;
value _elem . append ( number _elem ) ;
row . appendChild ( value _elem ) ;
2021-01-20 05:59:17 +00:00
active _elem . appendChild ( row ) ;
} else if ( id === "ls" && id _val != 0 ) {
let style ;
if ( id _val > 0 ) {
style = "positive" ;
} else {
style = "negative" ;
}
let row = document . createElement ( "tr" ) ;
let title = document . createElement ( "td" ) ;
title . classList . add ( "left" ) ;
title . textContent = "Effective Life Steal:"
let value = document . createElement ( "td" ) ;
let defStats = build . getDefenseStats ( ) ;
2021-03-25 08:38:52 +00:00
value . textContent = Math . round ( defStats [ 1 ] [ 0 ] * id _val / defStats [ 0 ] ) + "/3s" ;
2021-01-20 05:59:17 +00:00
value . classList . add ( "right" ) ;
value . classList . add ( style ) ;
row . appendChild ( title ) ;
row . appendChild ( value ) ;
2021-01-11 07:05:23 +00:00
active _elem . appendChild ( row ) ;
}
2021-01-20 05:59:17 +00:00
} 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 ) {
displayFixedID ( active _elem , id , diff , false , style ) ;
}
2021-01-09 12:47:25 +00:00
}
}
}
}
2021-01-18 01:26:39 +00:00
2021-01-07 22:44:52 +00:00
function displayExpandedItem ( item , parent _id ) {
// Commands to "script" the creation of nice formatting.
// #commands create a new element.
2021-01-08 01:02:12 +00:00
// !elemental is some janky hack for elemental damage.
2021-01-07 22:44:52 +00:00
// normals just display a thing.
2021-01-09 00:56:07 +00:00
if ( item . get ( "category" ) === "weapon" ) {
let stats = new Map ( ) ;
stats . set ( "atkSpd" , item . get ( "atkSpd" ) ) ;
stats . set ( "damageBonus" , [ 0 , 0 , 0 , 0 , 0 ] ) ;
2021-01-28 00:52:34 +00:00
//SUPER JANK @HPP PLS FIX
2021-01-09 00:56:07 +00:00
let damage _keys = [ "nDam_" , "eDam_" , "tDam_" , "wDam_" , "fDam_" , "aDam_" ] ;
2021-01-28 00:52:34 +00:00
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 ] ;
for ( const i in damage _keys ) {
item . set ( damage _keys [ i ] , damages [ i ] [ 0 ] + "-" + damages [ i ] [ 1 ] ) ;
}
} else {
stats . set ( "damageRaw" , [ item . get ( "nDamLow" ) , item . get ( "eDamLow" ) , item . get ( "tDamLow" ) , item . get ( "wDamLow" ) , item . get ( "fDamLow" ) , item . get ( "aDamLow" ) ] ) ;
2021-03-14 07:55:08 +00:00
stats . set ( "damageBases" , [ item . get ( "nDamBaseLow" ) , item . get ( "eDamBaseLow" ) , item . get ( "tDamBaseLow" ) , item . get ( "wDamBaseLow" ) , item . get ( "fDamBaseLow" ) , item . get ( "aDamBaseLow" ) ] ) ;
2021-01-28 00:52:34 +00:00
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" ) ] ) ;
2021-03-14 07:55:08 +00:00
stats . set ( "damageBases" , [ item . get ( "nDamBaseHigh" ) , item . get ( "eDamBaseHigh" ) , item . get ( "tDamBaseHigh" ) , item . get ( "wDamBaseHigh" ) , item . get ( "fDamBaseHigh" ) , item . get ( "aDamBaseHigh" ) ] ) ;
2021-01-28 00:52:34 +00:00
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 ] ;
for ( const i in damage _keys ) {
item . set ( damage _keys [ i ] , damagesLow [ i ] [ 0 ] + "-" + damagesLow [ i ] [ 1 ] + "\u279c" + damages [ i ] [ 0 ] + "-" + damages [ i ] [ 1 ] ) ;
}
2021-01-09 00:56:07 +00:00
}
2021-01-30 08:50:25 +00:00
} else if ( item . get ( "category" ) === "armor" ) {
2021-01-09 00:56:07 +00:00
}
2021-01-07 22:44:52 +00:00
let display _commands = [
"#cdiv" ,
"displayName" ,
2021-01-15 04:48:48 +00:00
//"type", //REPLACE THIS WITH SKIN
2021-01-07 22:44:52 +00:00
"#ldiv" ,
"atkSpd" ,
"#ldiv" ,
2021-01-08 01:02:12 +00:00
"!elemental" ,
2021-01-08 01:14:56 +00:00
"hp" ,
2021-01-09 03:53:57 +00:00
"nDam_" , "fDam_" , "wDam_" , "aDam_" , "tDam_" , "eDam_" ,
"fDef" , "wDef" , "aDef" , "tDef" , "eDef" ,
2021-01-08 01:02:12 +00:00
"!elemental" ,
"#ldiv" ,
"classReq" ,
"lvl" ,
"strReq" , "dexReq" , "intReq" , "defReq" , "agiReq" ,
"#ldiv" ,
2021-01-08 02:51:32 +00:00
"str" , "dex" , "int" , "def" , "agi" ,
2021-01-08 01:02:12 +00:00
"#table" ,
2021-01-19 17:32:27 +00:00
"str" , "dex" , "int" , "def" , "agi" , //jank lmao
2021-01-07 22:44:52 +00:00
"hpBonus" ,
"hprRaw" , "hprPct" ,
"sdRaw" , "sdPct" ,
"mdRaw" , "mdPct" ,
"mr" , "ms" ,
"ref" , "thorns" ,
"ls" ,
"poison" ,
2021-01-09 11:15:28 +00:00
"expd" ,
2021-01-07 22:44:52 +00:00
"spd" ,
"atkTier" ,
2021-01-08 01:02:12 +00:00
"!elemental" ,
2021-01-09 03:53:57 +00:00
"fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" ,
"fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" ,
2021-01-08 01:02:12 +00:00
"!elemental" ,
2021-01-07 22:44:52 +00:00
"spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" ,
"rainbowRaw" ,
"sprint" , "sprintReg" ,
"jh" ,
"xpb" , "lb" , "lq" ,
"spRegen" ,
"eSteal" ,
"gXp" , "gSpd" ,
2021-01-08 01:02:12 +00:00
"#ldiv" ,
2021-01-30 12:09:32 +00:00
"majorIds" ,
2021-01-07 22:44:52 +00:00
"slots" ,
"set" ,
2021-03-05 16:28:00 +00:00
"lore" ,
2021-01-07 22:44:52 +00:00
"quest" ,
2021-01-30 12:09:32 +00:00
"restrict"
] ;
2021-01-07 22:44:52 +00:00
// Clear the parent div.
setHTML ( parent _id , "" ) ;
let parent _div = document . getElementById ( parent _id ) ;
let active _elem ;
2021-01-08 01:02:12 +00:00
let fix _id = item . has ( "fixID" ) && item . get ( "fixID" ) ;
let elemental _format = false ;
2021-01-25 22:06:41 +00:00
for ( let i = 0 ; i < display _commands . length ; i ++ ) {
const command = display _commands [ i ] ;
2021-01-07 22:44:52 +00:00
if ( command . charAt ( 0 ) === "#" ) {
if ( command === "#cdiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'itemcenter' ) ;
}
else if ( command === "#ldiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'itemleft' ) ;
}
2021-01-08 01:02:12 +00:00
else if ( command === "#table" ) {
active _elem = document . createElement ( 'table' ) ;
active _elem . classList . add ( 'itemtable' ) ;
}
2021-03-14 07:55:08 +00:00
active _elem . style . maxWidth = "100%" ;
2021-01-07 22:44:52 +00:00
parent _div . appendChild ( active _elem ) ;
}
2021-01-08 01:02:12 +00:00
else if ( command . charAt ( 0 ) === "!" ) {
// TODO: This is sooo incredibly janky.....
if ( command === "!elemental" ) {
elemental _format = ! elemental _format ;
2021-03-05 16:28:00 +00:00
}
2021-01-08 01:02:12 +00:00
}
2021-01-07 22:44:52 +00:00
else {
2021-03-14 07:55:08 +00:00
let id = command ;
2021-01-19 17:32:27 +00:00
if ( ( nonRolledIDs . includes ( id ) && item . get ( id ) ) ) { //nonRolledID & non-0/non-null/non-und ID
2021-01-09 23:31:14 +00:00
if ( id === "slots" ) {
2021-01-11 07:22:06 +00:00
let p _elem = document . createElement ( "p" ) ;
2021-01-28 00:52:34 +00:00
// PROPER POWDER DISPLAYING
2021-01-11 07:22:06 +00:00
let numerals = new Map ( [ [ 1 , "I" ] , [ 2 , "II" ] , [ 3 , "III" ] , [ 4 , "IV" ] , [ 5 , "V" ] , [ 6 , "VI" ] ] ) ;
2021-01-10 21:31:29 +00:00
2021-01-11 07:05:23 +00:00
let powderPrefix = document . createElement ( "b" ) ;
2021-01-19 10:12:36 +00:00
powderPrefix . classList . add ( "powderLeft" ) ;
2021-01-10 21:31:29 +00:00
powderPrefix . classList . add ( "left" ) ;
2021-01-11 07:22:06 +00:00
powderPrefix . textContent = "Powder Slots: " + item . get ( id ) + " [" ;
p _elem . appendChild ( powderPrefix ) ;
2021-01-11 01:47:13 +00:00
2021-01-11 07:22:06 +00:00
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 ) ;
2021-01-10 21:31:29 +00:00
}
2021-01-11 07:22:06 +00:00
let powderSuffix = document . createElement ( "b" ) ;
2021-01-19 10:12:36 +00:00
powderSuffix . classList . add ( "powderRight" ) ;
2021-01-10 21:31:29 +00:00
powderSuffix . classList . add ( "left" ) ;
2021-01-11 02:58:39 +00:00
powderSuffix . textContent = "]" ;
2021-01-11 07:22:06 +00:00
p _elem . appendChild ( powderSuffix ) ;
active _elem . appendChild ( p _elem ) ;
2021-02-04 10:55:15 +00:00
} 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 ) ;
2021-01-30 12:09:32 +00:00
} else if ( id === "majorIds" ) {
let p _elem = document . createElement ( "p" ) ;
p _elem . classList . add ( "itemp" ) ;
2021-03-27 18:17:58 +00:00
let majorID = item . get ( id ) . toString ( ) ;
2021-03-14 07:55:08 +00:00
let title _elem = document . createElement ( "b" ) ;
let b _elem = document . createElement ( "b" ) ;
2021-03-27 18:17:58 +00:00
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 ) ;
}
2021-03-14 07:55:08 +00:00
2021-03-27 18:17:58 +00:00
2021-03-14 07:55:08 +00:00
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 ) ;
2021-01-30 12:09:32 +00:00
active _elem . appendChild ( p _elem ) ;
2021-01-19 17:32:27 +00:00
} else {
let p _elem ;
2021-01-30 08:50:25 +00:00
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-01-19 17:32:27 +00:00
p _elem = displayFixedID ( active _elem , id , item . get ( id ) , elemental _format ) ;
2021-01-30 08:50:25 +00:00
} else if ( item . get ( "tier" ) === "Crafted" && item . get ( "category" ) === "armor" && id === "hp" ) {
p _elem = displayFixedID ( active _elem , id , item . get ( id + "Low" ) + "-" + item . get ( id ) , elemental _format ) ;
}
2021-01-11 07:05:23 +00:00
if ( id === "displayName" ) {
p _elem . classList . add ( "title" ) ;
if ( item . get ( "tier" ) !== " " ) {
p _elem . classList . add ( item . get ( "tier" ) ) ;
}
2021-03-14 07:55:08 +00:00
p _elem . remove ( ) ;
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" ) ;
2021-02-05 18:09:36 +00:00
p _elem . textContent = item . get ( id ) ;
2021-03-14 07:55:08 +00:00
} else {
p _elem . href = url _base . replace ( /\w+.html/ , "" ) + "item.html#" + item . get ( "displayName" ) ;
2021-03-08 22:50:47 +00:00
p _elem . textContent = item . get ( "displayName" ) ;
}
2021-03-14 07:55:08 +00:00
p _elem . target = "_blank" ;
active _elem . appendChild ( p _elem ) ;
2021-01-24 20:33:00 +00:00
let img = document . createElement ( "img" ) ;
2021-03-14 07:55:08 +00:00
if ( item && item . has ( "type" ) ) {
2021-03-17 04:19:19 +00:00
img . src = "./media/items/" + ( newIcons ? "new/" : "old/" ) + "generic-" + item . get ( "type" ) + ".png" ;
2021-03-16 22:43:44 +00:00
img . alt = item . get ( "type" ) ;
img . style = " z=index: 1;max-width: 64px; max-height: 64px; position: relative; top: 50%; transform: translateY(-50%);" ;
let bckgrd = document . createElement ( "p" ) ;
bckgrd . style = "width: 96px; height: 96px; 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 ) ;
2021-03-14 07:55:08 +00:00
}
2021-03-05 16:28:00 +00:00
} else if ( id === "lore" ) {
p _elem . style = "font-style: italic" ;
2021-03-14 07:55:08 +00:00
p _elem . classList . add ( "lore" ) ;
2021-01-11 07:05:23 +00:00
} else if ( skp _order . includes ( id ) ) { //id = str, dex, int, def, or agi
2021-01-19 17:32:27 +00:00
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" ) {
let row = document . createElement ( 'tr' ) ;
let min _elem = document . createElement ( 'td' ) ;
min _elem . classList . add ( 'left' ) ;
min _elem . classList . add ( item . get ( "minRolls" ) . get ( id ) < 0 ? "negative" : "positive" ) ;
min _elem . textContent = item . get ( "minRolls" ) . get ( id ) + idSuffixes [ id ] ;
row . appendChild ( min _elem ) ;
let desc _elem = document . createElement ( 'td' ) ;
desc _elem . classList . add ( 'center' ) ;
//TODO elemental format jank
desc _elem . textContent = idPrefixes [ id ] ;
row . appendChild ( desc _elem ) ;
let max _elem = document . createElement ( 'td' ) ;
max _elem . classList . add ( 'right' ) ;
max _elem . classList . add ( item . get ( "maxRolls" ) . get ( id ) < 0 ? "negative" : "positive" ) ;
max _elem . textContent = item . get ( "maxRolls" ) . get ( id ) + idSuffixes [ id ] ;
row . appendChild ( max _elem ) ;
active _elem . appendChild ( row ) ;
2021-01-11 07:05:23 +00:00
}
2021-03-14 07:55:08 +00:00
} else if ( id === "restrict" ) {
2021-01-11 07:05:23 +00:00
p _elem . classList . add ( "restrict" ) ;
2021-03-14 07:55:08 +00:00
}
2021-01-09 23:31:14 +00:00
}
2021-01-07 22:44:52 +00:00
}
2021-02-25 06:34:43 +00:00
else if ( rolledIDs . includes ( id ) && item . get ( "maxRolls" ) && item . get ( "maxRolls" ) . get ( id ) ) { // && item.get("maxRolls").get(id) ){//rolled ID & non-0/non-null/non-und ID
2021-01-08 01:02:12 +00:00
let style = "positive" ;
if ( item . get ( "minRolls" ) . get ( id ) < 0 ) {
style = "negative" ;
}
2021-03-16 06:09:28 +00:00
if ( reversedIDs . includes ( id ) ) {
2021-01-10 21:31:29 +00:00
style === "positive" ? style = "negative" : style = "positive" ;
}
2021-01-08 01:02:12 +00:00
if ( fix _id ) {
2021-01-09 23:31:14 +00:00
displayFixedID ( active _elem , id , item . get ( "minRolls" ) . get ( id ) , elemental _format , style ) ;
2021-01-08 01:02:12 +00:00
}
else {
2021-01-09 12:47:25 +00:00
let row = document . createElement ( 'tr' ) ;
2021-01-08 01:02:12 +00:00
let min _elem = document . createElement ( 'td' ) ;
2021-01-10 21:31:29 +00:00
2021-01-08 01:02:12 +00:00
min _elem . classList . add ( 'left' ) ;
min _elem . classList . add ( style ) ;
min _elem . textContent = item . get ( "minRolls" ) . get ( id ) + idSuffixes [ id ] ;
row . appendChild ( min _elem ) ;
let desc _elem = document . createElement ( 'td' ) ;
desc _elem . classList . add ( 'center' ) ;
2021-01-09 03:53:57 +00:00
//TODO elemental format jank
2021-01-08 01:02:12 +00:00
if ( elemental _format ) {
apply _elemental _format ( desc _elem , id ) ;
}
else {
desc _elem . textContent = idPrefixes [ id ] ;
}
row . appendChild ( desc _elem ) ;
2021-03-14 07:55:08 +00:00
if ( item . get ( "maxRolls" ) . get ( id ) > 0 ) {
2021-03-16 06:09:28 +00:00
style = reversedIDs . includes ( id ) ? "negative" : "positive" ;
2021-03-14 07:55:08 +00:00
} else if ( item . get ( "maxRolls" ) . get ( id ) < 0 ) {
2021-03-16 06:09:28 +00:00
style = reversedIDs . includes ( id ) ? "positive" : "negative" ;
2021-03-14 07:55:08 +00:00
}
2021-01-08 01:02:12 +00:00
let max _elem = document . createElement ( 'td' ) ;
max _elem . classList . add ( 'right' ) ;
max _elem . classList . add ( style ) ;
max _elem . textContent = item . get ( "maxRolls" ) . get ( id ) + idSuffixes [ id ] ;
row . appendChild ( max _elem ) ;
2021-01-09 12:47:25 +00:00
active _elem . appendChild ( row ) ;
2021-01-08 01:02:12 +00:00
}
2021-01-19 17:32:27 +00:00
} else {
// :/
}
2021-01-07 22:44:52 +00:00
}
}
2021-01-11 06:49:52 +00:00
//Show powder specials ;-;
2021-01-19 17:32:27 +00:00
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 ;
}
2021-01-11 06:49:52 +00:00
}
}
}
2021-01-19 17:32:27 +00:00
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" ) ;
specialTitle . classList . add ( "left" ) ;
specialTitle . classList . add ( "itemp" ) ;
specialTitle . classList . add ( damageClasses [ skp _elements . indexOf ( element ) + 1 ] ) ;
specialEffects . classList . add ( "left" ) ;
specialEffects . classList . add ( "itemp" ) ;
specialEffects . classList . add ( "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" ] + ": " ;
}
2021-02-27 21:07:28 +00:00
// console.log(effects);
2021-02-03 17:47:48 +00:00
for ( const [ key , value ] of effects . entries ( ) ) {
if ( key !== "Description" ) {
2021-01-19 17:32:27 +00:00
let effect = document . createElement ( "p" ) ;
effect . classList . add ( "itemp" ) ;
2021-02-03 17:47:48 +00:00
effect . textContent = key + ": " + value [ power ] + specialSuffixes . get ( key ) ;
if ( key === "Damage" ) {
2021-01-19 17:32:27 +00:00
effect . textContent += elementIcons [ skp _elements . indexOf ( element ) ] ;
}
2021-02-05 18:09:36 +00:00
if ( element === "w" && item . get ( "category" ) === "armor" ) {
2021-01-19 17:32:27 +00:00
effect . textContent += " / Mana Used" ;
}
specialEffects . appendChild ( effect ) ;
} else {
specialTitle . textContent += "[ " + effects . get ( "Description" ) + " ]" ;
2021-01-11 07:40:49 +00:00
}
}
2021-02-03 17:47:48 +00:00
//specialTitle.append(specialEffects);
2021-01-19 17:32:27 +00:00
powder _special . appendChild ( specialTitle ) ;
2021-02-03 17:47:48 +00:00
powder _special . appendChild ( specialEffects ) ;
2021-01-19 17:32:27 +00:00
2021-02-03 17:47:48 +00:00
parent _div . appendChild ( powder _special ) ;
2021-01-11 07:40:49 +00:00
}
2021-01-11 06:49:52 +00:00
}
2021-01-19 17:32:27 +00:00
if ( item . get ( "tier" ) && item . get ( "tier" ) === "Crafted" ) {
let dura _elem = document . createElement ( "p" ) ;
2021-01-19 20:46:04 +00:00
dura _elem . classList . add ( "itemp" ) ;
2021-01-19 17:32:27 +00:00
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."
2021-01-29 02:48:26 +00:00
let charges = document . createElement ( "b" ) ;
charges . textContent = "Charges: " + item . get ( "charges" ) ;
charges . classList . add ( "spaceleft" ) ;
active _elem . appendChild ( charges ) ;
2021-01-19 17:32:27 +00:00
}
2021-03-14 07:55:08 +00:00
if ( typeof ( dura ) === "string" ) {
dura _elem . textContent += dura + suffix ;
} else {
dura _elem . textContent += dura [ 0 ] + "-" + dura [ 1 ] + suffix ;
}
2021-01-19 20:46:04 +00:00
active _elem . append ( dura _elem ) ;
2021-01-28 00:52:34 +00:00
2021-01-19 17:32:27 +00:00
}
2021-01-11 06:49:52 +00:00
//Show item tier
2021-01-11 17:52:21 +00:00
if ( item . get ( "tier" ) && item . get ( "tier" ) !== " " ) {
2021-01-19 17:32:27 +00:00
let item _desc _elem = document . createElement ( "p" ) ;
2021-01-19 20:46:04 +00:00
item _desc _elem . classList . add ( 'itemp' ) ;
2021-01-10 21:01:59 +00:00
item _desc _elem . classList . add ( item . get ( "tier" ) ) ;
item _desc _elem . textContent = item . get ( "tier" ) + " " + item . get ( "type" ) ;
2021-01-19 20:46:04 +00:00
active _elem . append ( item _desc _elem ) ;
2021-01-10 21:01:59 +00:00
}
2021-03-14 07:55:08 +00:00
//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 ) ;
}
2021-01-07 22:44:52 +00:00
}
2021-01-20 05:59:17 +00:00
/ * D i s p l a y s s t a t s a b o u t a r e c i p e t h a t a r e N O T d i s p l a y e d i n t h e c r a f t s t a t s .
* Includes : mat name and amounts
* ingred names in an "array" with ingred effectiveness
* /
function displayRecipeStats ( craft , parent _id ) {
let elem = document . getElementById ( parent _id ) ;
elem . textContent = "" ;
recipe = craft [ "recipe" ] ;
2021-03-14 07:55:08 +00:00
mat _tiers = craft [ "mat_tiers" ] ;
2021-01-20 05:59:17 +00:00
ingreds = [ ] ;
for ( const n of craft [ "ingreds" ] ) {
ingreds . push ( n . get ( "name" ) ) ;
}
let effectiveness = craft [ "statMap" ] . get ( "ingredEffectiveness" ) ;
let ldiv = document . createElement ( "div" ) ;
ldiv . classList . add ( "itemleft" ) ;
let title = document . createElement ( "p" ) ;
title . classList . add ( "smalltitle" ) ;
title . textContent = "Recipe Stats" ;
ldiv . appendChild ( title ) ;
let mats = document . createElement ( "p" ) ;
mats . classList . add ( "itemp" ) ;
mats . textContent = "Crafting Materials: " ;
for ( let i = 0 ; i < 2 ; i ++ ) {
2021-03-14 07:55:08 +00:00
let tier = mat _tiers [ i ] ;
2021-01-20 05:59:17 +00:00
let row = document . createElement ( "p" ) ;
row . classList . add ( "left" ) ;
let b = document . createElement ( "b" ) ;
let mat = recipe . get ( "materials" ) [ i ] ;
b . textContent = "- " + mat . get ( "amount" ) + "x " + mat . get ( "item" ) . split ( " " ) . slice ( 1 ) . join ( " " ) ;
b . classList . add ( "space" ) ;
let starsB = document . createElement ( "b" ) ;
starsB . classList . add ( "T1-bracket" ) ;
starsB . textContent = "[" ;
row . appendChild ( b ) ;
row . appendChild ( starsB ) ;
for ( let j = 0 ; j < 3 ; j ++ ) {
let star = document . createElement ( "b" ) ;
star . textContent = "\u272B" ;
if ( j < tier ) {
star . classList . add ( "T1" ) ;
} else {
star . classList . add ( "T0" ) ;
}
row . append ( star ) ;
}
let starsE = document . createElement ( "b" ) ;
starsE . classList . add ( "T1-bracket" ) ;
starsE . textContent = "]" ;
row . appendChild ( starsE ) ;
mats . appendChild ( row ) ;
}
ldiv . appendChild ( mats ) ;
let ingredTable = document . createElement ( "table" ) ;
ingredTable . classList . add ( "itemtable" ) ;
2021-01-20 17:10:27 +00:00
ingredTable . classList . add ( "ingredTable" ) ;
2021-01-20 05:59:17 +00:00
for ( let i = 0 ; i < 3 ; i ++ ) {
let row = document . createElement ( "tr" ) ;
for ( let j = 0 ; j < 2 ; j ++ ) {
let ingredName = ingreds [ 2 * i + j ] ;
let cell = document . createElement ( "td" ) ;
2021-03-27 18:17:58 +00:00
cell . style . minWidth = "50%" ;
2021-01-20 05:59:17 +00:00
cell . classList . add ( "center" ) ;
cell . classList . add ( "box" ) ;
2021-01-20 17:10:27 +00:00
cell . classList . add ( "tooltip" ) ;
2021-01-20 05:59:17 +00:00
let b = document . createElement ( "b" ) ;
b . textContent = ingredName ;
b . classList . add ( "space" ) ;
let eff = document . createElement ( "b" ) ;
let e = effectiveness [ 2 * i + j ] ;
if ( e > 0 ) {
eff . classList . add ( "positive" ) ;
} else if ( e < 0 ) {
eff . classList . add ( "negative" ) ;
}
eff . textContent = "[" + e + "%]" ;
cell . appendChild ( b ) ;
cell . appendChild ( eff ) ;
row . appendChild ( cell ) ;
2021-01-20 17:10:27 +00:00
let tooltip = document . createElement ( "div" ) ;
tooltip . classList . add ( "tooltiptext" ) ;
2021-03-27 18:17:58 +00:00
tooltip . classList . add ( "ing-tooltip" ) ;
2021-01-20 17:10:27 +00:00
tooltip . classList . add ( "center" ) ;
tooltip . id = "tooltip-" + ( 2 * i + j ) ;
cell . appendChild ( tooltip ) ;
2021-01-20 05:59:17 +00:00
}
ingredTable . appendChild ( row ) ;
}
elem . appendChild ( ldiv ) ;
elem . appendChild ( ingredTable ) ;
}
//Displays a craft. If things change, this function should be modified.
2021-01-18 01:26:39 +00:00
function displayCraftStats ( craft , parent _id ) {
2021-01-19 17:32:27 +00:00
let mock _item = craft . statMap ;
displayExpandedItem ( mock _item , parent _id ) ;
2021-01-18 01:26:39 +00:00
}
2021-01-20 05:59:17 +00:00
//Displays an ingredient in item format. However, an ingredient is too far from a normal item to display as one.
2021-01-18 01:26:39 +00:00
function displayExpandedIngredient ( ingred , parent _id ) {
2021-01-18 20:23:37 +00:00
let parent _elem = document . getElementById ( parent _id ) ;
parent _elem . textContent = "" ;
2021-01-18 01:26:39 +00:00
let display _order = [
"#cdiv" ,
2021-03-04 13:48:10 +00:00
"displayName" , //tier will be displayed w/ name
2021-01-18 01:26:39 +00:00
"#table" ,
"ids" ,
"#ldiv" ,
"posMods" ,
"itemIDs" ,
"consumableIDs" ,
"#ldiv" ,
"lvl" ,
"skills" ,
]
2021-01-18 20:23:37 +00:00
let item _order = [
"dura" ,
"strReq" ,
"dexReq" ,
"intReq" ,
"defReq" ,
"agiReq"
]
let consumable _order = [
"dura" ,
"charges"
]
let posMods _order = [
"above" ,
2021-01-19 17:32:27 +00:00
"under" ,
2021-01-18 20:23:37 +00:00
"left" ,
"right" ,
"touching" ,
"notTouching"
] ;
let id _display _order = [
2021-01-18 01:26:39 +00:00
"eDefPct" ,
"tDefPct" ,
"wDefPct" ,
"fDefPct" ,
"aDefPct" ,
"eDamPct" ,
"tDamPct" ,
"wDamPct" ,
"fDamPct" ,
"aDamPct" ,
"str" ,
"dex" ,
"int" ,
"agi" ,
"def" ,
"hpBonus" ,
"mr" ,
"ms" ,
"ls" ,
"hprRaw" ,
"hprPct" ,
"sdRaw" ,
"sdPct" ,
"mdRaw" ,
"mdPct" ,
"xpb" ,
"lb" ,
"lq" ,
"ref" ,
"thorns" ,
"expd" ,
"spd" ,
"atkTier" ,
"poison" ,
"spRegen" ,
"eSteal" ,
"spRaw1" ,
"spRaw2" ,
"spRaw3" ,
"spRaw4" ,
"spPct1" ,
"spPct2" ,
"spPct3" ,
"spPct4" ,
"jh" ,
"sprint" ,
"sprintReg" ,
"gXp" ,
"gSpd" ,
] ;
2021-01-18 20:23:37 +00:00
let active _elem ;
let elemental _format = false ;
let style ;
for ( const command of display _order ) {
if ( command . charAt ( 0 ) === "#" ) {
if ( command === "#cdiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'itemcenter' ) ;
}
else if ( command === "#ldiv" ) {
active _elem = document . createElement ( 'div' ) ;
active _elem . classList . add ( 'itemleft' ) ;
}
else if ( command === "#table" ) {
active _elem = document . createElement ( 'table' ) ;
active _elem . classList . add ( 'itemtable' ) ;
}
parent _elem . appendChild ( active _elem ) ;
} else {
let p _elem = document . createElement ( "p" ) ;
p _elem . classList . add ( "left" ) ;
2021-03-04 13:48:10 +00:00
if ( command === "displayName" ) {
2021-01-18 20:23:37 +00:00
p _elem . classList . add ( "title" ) ;
p _elem . classList . remove ( "left" ) ;
let title _elem = document . createElement ( "b" ) ;
2021-03-04 13:48:10 +00:00
title _elem . textContent = ingred . get ( "displayName" ) ;
2021-01-18 20:23:37 +00:00
p _elem . appendChild ( title _elem ) ;
let space = document . createElement ( "b" ) ;
space . classList . add ( "space" ) ;
p _elem . appendChild ( space ) ;
let tier = ingred . get ( "tier" ) ; //tier in [0,3]
let begin = document . createElement ( "b" ) ;
begin . classList . add ( "T" + tier + "-bracket" ) ;
begin . textContent = "[" ;
p _elem . appendChild ( begin ) ;
for ( let i = 0 ; i < 3 ; i ++ ) {
let tier _elem = document . createElement ( "b" ) ;
if ( i < tier ) { tier _elem . classList . add ( "T" + tier ) }
else { tier _elem . classList . add ( "T0" ) }
tier _elem . textContent = "\u272B" ;
p _elem . appendChild ( tier _elem ) ;
}
let end = document . createElement ( "b" ) ;
end . classList . add ( "T" + tier + "-bracket" ) ;
end . textContent = "]" ;
p _elem . appendChild ( end ) ;
} else if ( command === "lvl" ) {
p _elem . textContent = "Crafting Lvl Min: " + ingred . get ( "lvl" ) ;
} else if ( command === "posMods" ) {
for ( const [ key , value ] of ingred . get ( "posMods" ) ) {
2021-01-19 17:32:27 +00:00
let p = document . createElement ( "p" ) ;
p . classList . add ( "nomarginp" ) ;
2021-01-18 20:23:37 +00:00
if ( value != 0 ) {
let title = document . createElement ( "b" ) ;
title . textContent = posModPrefixes [ key ] ;
let val = document . createElement ( "b" ) ;
val . textContent = value + posModSuffixes [ key ] ;
if ( value > 0 ) {
val . classList . add ( "positive" ) ;
} else {
val . classList . add ( "negative" ) ;
}
2021-01-19 17:32:27 +00:00
p . appendChild ( title ) ;
p . appendChild ( val ) ;
p _elem . appendChild ( p ) ;
2021-01-18 20:23:37 +00:00
}
}
} else if ( command === "itemIDs" ) { //dura, reqs
for ( const [ key , value ] of ingred . get ( "itemIDs" ) ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "nomarginp" ) ;
if ( value != 0 ) {
let title = document . createElement ( "b" ) ;
title . textContent = itemIDPrefixes [ key ] ;
p . appendChild ( title ) ;
}
let desc = document . createElement ( "b" ) ;
if ( value > 0 ) {
if ( key !== "dura" ) {
desc . classList . add ( "negative" ) ;
} else {
desc . classList . add ( "positive" ) ;
}
desc . textContent = "+" + value ;
} else if ( value < 0 ) {
if ( key !== "dura" ) {
desc . classList . add ( "positive" ) ;
} else {
desc . classList . add ( "negative" ) ;
}
desc . textContent = value ;
}
if ( value != 0 ) {
p . appendChild ( desc ) ;
}
p _elem . append ( p ) ;
}
} else if ( command === "consumableIDs" ) { //dura, charges
for ( const [ key , value ] of ingred . get ( "consumableIDs" ) ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "nomarginp" ) ;
if ( value != 0 ) {
let title = document . createElement ( "b" ) ;
title . textContent = consumableIDPrefixes [ key ] ;
p . appendChild ( title ) ;
}
let desc = document . createElement ( "b" ) ;
if ( value > 0 ) {
desc . classList . add ( "positive" ) ;
desc . textContent = "+" + value ;
} else if ( value < 0 ) {
desc . classList . add ( "negative" ) ;
desc . textContent = value ;
}
if ( value != 0 ) {
p . appendChild ( desc ) ;
let suffix = document . createElement ( "b" ) ;
suffix . textContent = consumableIDSuffixes [ key ] ;
p . appendChild ( suffix ) ;
}
p _elem . append ( p ) ;
}
} else if ( command === "skills" ) {
p _elem . textContent = "Used in:" ;
for ( const skill of ingred . get ( "skills" ) ) {
let p = document . createElement ( "p" ) ;
p . textContent = skill . charAt ( 0 ) + skill . substring ( 1 ) . toLowerCase ( ) ;
p . classList . add ( "left" ) ;
p _elem . append ( p ) ;
}
} else if ( command === "ids" ) { //warp
2021-02-25 06:03:44 +00:00
for ( let [ key , value ] of ingred . get ( "ids" ) . get ( "maxRolls" ) ) {
if ( value !== undefined && value != 0 ) {
value = ingred . get ( "ids" ) . get ( "minRolls" ) . get ( key ) ;
2021-01-18 20:23:37 +00:00
if ( value > 0 ) {
style = "positive" ;
2021-02-25 06:03:44 +00:00
} else if ( value <= 0 ) {
2021-01-18 20:23:37 +00:00
style = "negative" ;
}
2021-03-16 06:11:59 +00:00
if ( reversedIDs . includes ( key ) ) {
2021-01-18 20:23:37 +00:00
style === "positive" ? style = "negative" : style = "positive" ;
}
2021-01-18 01:26:39 +00:00
2021-01-18 20:23:37 +00:00
let row = document . createElement ( 'tr' ) ;
row . classList . add ( "center" ) ;
let min _elem = document . createElement ( 'td' ) ;
min _elem . classList . add ( 'left' ) ;
min _elem . classList . add ( style ) ;
min _elem . textContent = value + idSuffixes [ key ] ;
row . appendChild ( min _elem ) ;
let desc _elem = document . createElement ( 'td' ) ;
desc _elem . classList . add ( 'center' ) ;
//TODO elemental format jank
if ( elemental _format ) {
apply _elemental _format ( desc _elem , key ) ;
}
else {
desc _elem . textContent = idPrefixes [ key ] ;
}
row . appendChild ( desc _elem ) ;
let max _elem = document . createElement ( 'td' ) ;
2021-02-25 06:03:44 +00:00
value = ingred . get ( "ids" ) . get ( "maxRolls" ) . get ( key ) ;
if ( value > 0 ) {
style = "positive" ;
} else if ( value <= 0 ) {
style = "negative" ;
}
2021-03-16 06:11:59 +00:00
if ( reversedIDs . includes ( key ) ) {
2021-02-25 06:03:44 +00:00
style === "positive" ? style = "negative" : style = "positive" ;
}
2021-01-18 20:23:37 +00:00
max _elem . classList . add ( 'right' ) ;
max _elem . classList . add ( style ) ;
2021-02-25 06:03:44 +00:00
max _elem . textContent = value + idSuffixes [ key ] ;
2021-01-18 20:23:37 +00:00
row . appendChild ( max _elem ) ;
active _elem . appendChild ( row ) ;
}
}
} else { //this shouldn't be happening
}
active _elem . appendChild ( p _elem ) ;
}
}
2021-01-18 01:26:39 +00:00
}
2021-01-09 08:52:58 +00:00
2021-01-15 18:20:17 +00:00
function displayNextCosts ( parent _id , build ) {
let p _elem = document . getElementById ( parent _id ) ;
let int = build . total _skillpoints [ 2 ] ;
let spells = spell _table [ build . weapon . get ( "type" ) ] ;
p _elem . textContent = "" ;
let title = document . createElement ( "p" ) ;
2021-01-15 19:52:11 +00:00
title . classList . add ( "title" ) ;
title . classList . add ( "Normal" ) ;
2021-01-15 18:20:17 +00:00
title . textContent = "Next Spell Costs" ;
let int _title = document . createElement ( "p" ) ;
int _title . classList . add ( "itemp" ) ;
int _title . textContent = int + " Intelligence points." ;
p _elem . append ( title ) ;
p _elem . append ( int _title ) ;
2021-01-18 20:23:37 +00:00
for ( const spell of spells ) {
2021-01-15 18:20:17 +00:00
let spellp = document . createElement ( "p" ) ;
let spelltitle = document . createElement ( "p" ) ;
spelltitle . classList . add ( "itemp" ) ;
spelltitle . textContent = spell . title ;
spellp . appendChild ( spelltitle ) ;
let row = document . createElement ( "p" ) ;
row . classList . add ( "itemp" ) ;
let init _cost = document . createElement ( "b" ) ;
init _cost . textContent = build . getSpellCost ( spells . indexOf ( spell ) + 1 , spell . cost ) ;
init _cost . classList . add ( "Mana" ) ;
let arrow = document . createElement ( "b" ) ;
arrow . textContent = "\u279C" ;
let next _cost = document . createElement ( "b" ) ;
2021-01-15 18:49:24 +00:00
next _cost . textContent = ( init _cost . textContent === "1" ? 1 : build . getSpellCost ( spells . indexOf ( spell ) + 1 , spell . cost ) - 1 ) ;
2021-01-15 18:20:17 +00:00
next _cost . classList . add ( "Mana" ) ;
let int _needed = document . createElement ( "b" ) ;
2021-01-15 18:49:24 +00:00
if ( init _cost . textContent === "1" ) {
int _needed . textContent = ": n/a (+0)" ;
} else { //do math
let target = build . getSpellCost ( spells . indexOf ( spell ) + 1 , spell . cost ) - 1 ;
let needed = int ;
2021-01-15 20:36:12 +00:00
let noUpdate = false ;
2021-01-15 18:49:24 +00:00
//forgive me... I couldn't inverse ceil, floor, and max.
2021-01-15 19:52:11 +00:00
while ( build . getSpellCost ( spells . indexOf ( spell ) + 1 , spell . cost ) > target ) {
if ( needed > 150 ) {
2021-01-15 20:36:12 +00:00
noUpdate = true ;
2021-01-15 19:52:11 +00:00
break ;
}
2021-01-15 18:49:24 +00:00
needed ++ ;
build . total _skillpoints [ 2 ] = needed ;
}
let missing = needed - int ;
2021-01-15 19:52:11 +00:00
//in rare circumstances, the next spell cost can jump.
2021-01-15 20:36:12 +00:00
if ( noUpdate ) {
next _cost . textContent = ( init _cost . textContent === "1" ? 1 : build . getSpellCost ( spells . indexOf ( spell ) + 1 , spell . cost ) - 1 ) ;
} else {
next _cost . textContent = ( init _cost . textContent === "1" ? 1 : build . getSpellCost ( spells . indexOf ( spell ) + 1 , spell . cost ) ) ;
}
2021-01-15 19:52:11 +00:00
2021-01-15 18:49:24 +00:00
build . total _skillpoints [ 2 ] = int ; //forgive me pt 2
2021-01-15 19:52:11 +00:00
int _needed . textContent = ": " + ( needed > 150 ? ">150" : needed ) + " int (+" + ( needed > 150 ? "n/a" : missing ) + ")" ;
2021-01-15 18:49:24 +00:00
}
2021-01-15 18:20:17 +00:00
row . appendChild ( init _cost ) ;
row . appendChild ( arrow ) ;
row . appendChild ( next _cost ) ;
row . appendChild ( int _needed ) ;
spellp . appendChild ( row ) ;
p _elem . append ( spellp ) ;
}
}
2021-01-18 01:26:39 +00:00
2021-01-09 12:47:25 +00:00
function displayFixedID ( active , id , value , elemental _format , style ) {
if ( style ) {
2021-01-11 17:52:21 +00:00
/ * i f ( r e v e r s e d I D s . f i l t e r ( e = > e ! = = " a t k T i e r " ) . i n c l u d e s ( i d ) ) {
2021-01-10 21:31:29 +00:00
style === "positive" ? style = "negative" : style = "positive" ;
2021-01-11 17:52:21 +00:00
} * /
2021-01-09 12:47:25 +00:00
let row = document . createElement ( 'tr' ) ;
let desc _elem = document . createElement ( 'td' ) ;
desc _elem . classList . add ( 'left' ) ;
if ( elemental _format ) {
apply _elemental _format ( desc _elem , id ) ;
}
else {
desc _elem . textContent = idPrefixes [ id ] ;
}
row . appendChild ( desc _elem ) ;
2021-01-09 11:56:10 +00:00
2021-01-09 12:47:25 +00:00
let value _elem = document . createElement ( 'td' ) ;
value _elem . classList . add ( 'right' ) ;
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
2021-01-28 00:52:34 +00:00
if ( value === "0-0" || value === "0-0\u279c0-0" ) {
2021-01-09 12:47:25 +00:00
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-01-09 11:56:10 +00:00
}
2021-01-10 21:01:59 +00:00
function displayEquipOrder ( parent _elem , buildOrder ) {
parent _elem . textContent = "" ;
const order = buildOrder . slice ( ) ;
let title _elem = document . createElement ( "p" ) ;
title _elem . textContent = "Equip order " ;
title _elem . classList . add ( "title" ) ;
2021-01-10 21:31:29 +00:00
title _elem . classList . add ( "Normal" ) ;
title _elem . classList . add ( "itemp" ) ;
2021-01-10 21:01:59 +00:00
parent _elem . append ( title _elem ) ;
2021-01-10 21:31:29 +00:00
parent _elem . append ( document . createElement ( "br" ) ) ;
2021-01-10 21:01:59 +00:00
for ( const item of order ) {
let p _elem = document . createElement ( "p" ) ;
p _elem . classList . add ( "itemp" ) ;
p _elem . classList . add ( "left" ) ;
p _elem . textContent = item . get ( "displayName" ) ;
parent _elem . append ( p _elem ) ;
}
}
2021-01-10 22:38:17 +00:00
2021-01-11 07:05:23 +00:00
function displayPoisonDamage ( overallparent _elem , build ) {
overallparent _elem . textContent = "" ;
//Title
let title _elemavg = document . createElement ( "p" ) ;
title _elemavg . classList . add ( "smalltitle" ) ;
title _elemavg . classList . add ( "Normal" ) ;
title _elemavg . textContent = "Poison Stats" ;
overallparent _elem . append ( title _elemavg ) ;
let overallpoisonDamage = document . createElement ( "p" ) ;
overallpoisonDamage . classList . add ( "itemp" ) ;
2021-01-15 08:23:55 +00:00
let overallpoisonDamageFirst = document . createElement ( "b" ) ;
let overallpoisonDamageSecond = document . createElement ( "b" ) ;
2021-01-14 06:58:32 +00:00
let poison _tick = Math . round ( build . statMap . get ( "poison" ) * ( 1 + skillPointsToPercentage ( build . total _skillpoints [ 0 ] ) ) * ( build . statMap . get ( "poisonPct" ) + build . externalStats . get ( "poisonPct" ) ) / 100 / 3 ) ;
2021-01-15 08:23:55 +00:00
overallpoisonDamageFirst . textContent = "Poison Tick: " ;
overallpoisonDamageSecond . textContent = Math . max ( poison _tick , 0 ) ;
overallpoisonDamageSecond . classList . add ( "Damage" ) ;
overallpoisonDamage . appendChild ( overallpoisonDamageFirst ) ;
overallpoisonDamage . appendChild ( overallpoisonDamageSecond ) ;
2021-01-11 07:05:23 +00:00
overallparent _elem . append ( overallpoisonDamage ) ;
overallparent _elem . append ( document . createElement ( "br" ) ) ;
}
2021-01-10 21:01:59 +00:00
function displayMeleeDamage ( parent _elem , overallparent _elem , meleeStats ) {
2021-03-31 06:44:56 +00:00
console . log ( "Melee Stats" ) ;
console . log ( meleeStats ) ;
let tooltipinfo = meleeStats [ 13 ] ;
2021-01-09 23:30:05 +00:00
let attackSpeeds = [ "Super Slow" , "Very Slow" , "Slow" , "Normal" , "Fast" , "Very Fast" , "Super Fast" ] ;
2021-01-10 21:01:59 +00:00
//let damagePrefixes = ["Neutral Damage: ","Earth Damage: ","Thunder Damage: ","Water Damage: ","Fire Damage: ","Air Damage: "];
2021-01-09 23:30:05 +00:00
parent _elem . textContent = "" ;
2021-01-10 21:01:59 +00:00
overallparent _elem . textContent = "" ;
2021-01-09 23:30:05 +00:00
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 ) {
2021-01-11 02:58:39 +00:00
for ( let j = 0 ; j < 2 ; j ++ ) {
2021-01-09 23:30:05 +00:00
stats [ i ] [ j ] = stats [ i ] [ j ] . toFixed ( 2 ) ;
}
}
for ( let i = 8 ; i < 11 ; ++ i ) {
stats [ i ] = stats [ i ] . toFixed ( 2 ) ;
}
2021-03-31 06:44:56 +00:00
//tooltipelem, tooltiptext
let tooltip ; let tooltiptext ;
2021-01-09 23:30:05 +00:00
//title
let title _elem = document . createElement ( "p" ) ;
2021-01-10 21:01:59 +00:00
title _elem . classList . add ( "title" ) ;
2021-01-10 21:31:29 +00:00
title _elem . classList . add ( "Normal" ) ;
title _elem . classList . add ( "itemp" ) ;
2021-01-09 23:30:05 +00:00
title _elem . textContent = "Melee Stats" ;
parent _elem . append ( title _elem ) ;
parent _elem . append ( document . createElement ( "br" ) ) ;
2021-01-10 21:01:59 +00:00
//overall title
let title _elemavg = document . createElement ( "p" ) ;
2021-01-11 07:05:23 +00:00
title _elemavg . classList . add ( "smalltitle" ) ;
2021-01-10 21:31:29 +00:00
title _elemavg . classList . add ( "Normal" ) ;
2021-01-10 21:01:59 +00:00
title _elemavg . textContent = "Melee Stats" ;
overallparent _elem . append ( title _elemavg ) ;
2021-01-10 21:31:29 +00:00
2021-01-09 23:30:05 +00:00
//average DPS
let averageDamage = document . createElement ( "p" ) ;
2021-01-10 21:31:29 +00:00
averageDamage . classList . add ( "left" ) ;
2021-01-10 21:01:59 +00:00
averageDamage . classList . add ( "itemp" ) ;
2021-03-31 06:44:56 +00:00
averageDamage . classList . add ( "tooltip" ) ;
2021-01-09 23:30:05 +00:00
averageDamage . textContent = "Average DPS: " + stats [ 10 ] ;
2021-03-31 06:44:56 +00:00
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 ) ;
2021-01-09 23:30:05 +00:00
parent _elem . append ( averageDamage ) ;
2021-01-10 21:01:59 +00:00
//overall average DPS
let overallaverageDamage = document . createElement ( "p" ) ;
overallaverageDamage . classList . add ( "itemp" ) ;
2021-01-15 08:23:55 +00:00
let overallaverageDamageFirst = document . createElement ( "b" ) ;
overallaverageDamageFirst . textContent = "Average DPS: "
let overallaverageDamageSecond = document . createElement ( "b" ) ;
overallaverageDamageSecond . classList . add ( "Damage" ) ;
overallaverageDamageSecond . textContent = stats [ 10 ] ;
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , overallaverageDamage , [ "melee-tooltip" , "summary-tooltip" ] ) ;
2021-01-15 08:23:55 +00:00
overallaverageDamage . appendChild ( overallaverageDamageFirst ) ;
overallaverageDamage . appendChild ( overallaverageDamageSecond ) ;
2021-01-10 21:01:59 +00:00
overallparent _elem . append ( overallaverageDamage ) ;
2021-01-19 01:57:26 +00:00
//overallparent_elem.append(document.createElement("br"));
2021-01-10 21:01:59 +00:00
2021-01-09 23:30:05 +00:00
//attack speed
let atkSpd = document . createElement ( "p" ) ;
2021-01-10 21:31:29 +00:00
atkSpd . classList . add ( "left" ) ;
2021-01-10 21:01:59 +00:00
atkSpd . classList . add ( "itemp" ) ;
2021-01-09 23:30:05 +00:00
atkSpd . textContent = "Attack Speed: " + attackSpeeds [ stats [ 11 ] ] ;
parent _elem . append ( atkSpd ) ;
parent _elem . append ( document . createElement ( "br" ) ) ;
2021-01-10 21:01:59 +00:00
//overall attack speed
let overallatkSpd = document . createElement ( "p" ) ;
overallatkSpd . classList . add ( "center" ) ;
overallatkSpd . classList . add ( "itemp" ) ;
2021-01-15 08:23:55 +00:00
let overallatkSpdFirst = document . createElement ( "b" ) ;
overallatkSpdFirst . textContent = "Attack Speed: " ;
let overallatkSpdSecond = document . createElement ( "b" ) ;
overallatkSpdSecond . classList . add ( "Damage" ) ;
overallatkSpdSecond . textContent = attackSpeeds [ stats [ 11 ] ] ;
overallatkSpd . appendChild ( overallatkSpdFirst ) ;
overallatkSpd . appendChild ( overallatkSpdSecond ) ;
2021-01-10 21:01:59 +00:00
overallparent _elem . append ( overallatkSpd ) ;
2021-01-09 23:30:05 +00:00
//Non-Crit: n->elem, total dmg, DPS
let nonCritStats = document . createElement ( "p" ) ;
2021-01-10 21:31:29 +00:00
nonCritStats . classList . add ( "left" ) ;
2021-01-10 21:01:59 +00:00
nonCritStats . classList . add ( "itemp" ) ;
2021-01-09 23:30:05 +00:00
nonCritStats . textContent = "Non-Crit Stats: " ;
nonCritStats . append ( document . createElement ( "br" ) ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
2021-03-31 06:44:56 +00:00
if ( stats [ i ] [ 1 ] != 0 ) {
2021-01-10 21:01:59 +00:00
let dmg = document . createElement ( "p" ) ;
2021-03-31 06:44:56 +00:00
dmg . textContent = stats [ i ] [ 0 ] + " \u2013 " + stats [ i ] [ 1 ] ;
2021-01-10 21:01:59 +00:00
dmg . classList . add ( damageClasses [ i ] ) ;
dmg . classList . add ( "itemp" ) ;
2021-03-31 06:44:56 +00:00
tooltiptext = tooltipinfo . get ( "damageformulas" ) [ i ] . slice ( 0 , 2 ) . join ( "\n" ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , dmg , [ "melee-tooltip" ] ) ;
2021-01-09 23:30:05 +00:00
nonCritStats . append ( dmg ) ;
}
}
2021-01-12 22:49:57 +00:00
2021-01-09 23:30:05 +00:00
let normalDamage = document . createElement ( "p" ) ;
2021-03-31 06:44:56 +00:00
normalDamage . textContent = "Total: " + stats [ 6 ] [ 0 ] + " \u2013 " + stats [ 6 ] [ 1 ] ;
2021-01-10 21:01:59 +00:00
normalDamage . classList . add ( "itemp" ) ;
2021-03-31 06:44:56 +00:00
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" ] ) ;
2021-01-09 23:30:05 +00:00
nonCritStats . append ( normalDamage ) ;
2021-01-09 11:56:10 +00:00
2021-01-09 23:30:05 +00:00
let normalDPS = document . createElement ( "p" ) ;
normalDPS . textContent = "Normal DPS: " + stats [ 8 ] ;
2021-01-10 21:01:59 +00:00
normalDPS . classList . add ( "itemp" ) ;
2021-03-31 06:44:56 +00:00
normalDPS . classList . add ( "tooltip" ) ;
tooltiptext = ` = (( ${ stats [ 6 ] [ 0 ] } + ${ stats [ 6 ] [ 1 ] } ) / 2) * ${ baseDamageMultiplier [ stats [ 11 ] ] } ` ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , normalDPS , [ "melee-tooltip" ] ) ;
2021-01-09 23:30:05 +00:00
nonCritStats . append ( normalDPS ) ;
2021-01-12 22:49:57 +00:00
//overall average DPS
let singleHitDamage = document . createElement ( "p" ) ;
singleHitDamage . classList . add ( "itemp" ) ;
2021-01-15 08:23:55 +00:00
let singleHitDamageFirst = document . createElement ( "b" ) ;
singleHitDamageFirst . textContent = "Single Hit Average: " ;
let singleHitDamageSecond = document . createElement ( "b" ) ;
singleHitDamageSecond . classList . add ( "Damage" ) ;
singleHitDamageSecond . textContent = stats [ 12 ] . toFixed ( 2 ) ;
2021-03-31 06:44:56 +00:00
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" ] ) ;
2021-01-15 08:23:55 +00:00
singleHitDamage . appendChild ( singleHitDamageFirst ) ;
singleHitDamage . appendChild ( singleHitDamageSecond ) ;
2021-01-12 22:49:57 +00:00
overallparent _elem . append ( singleHitDamage ) ;
overallparent _elem . append ( document . createElement ( "br" ) ) ;
2021-01-11 02:58:39 +00:00
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 ) ;
2021-01-09 23:30:05 +00:00
parent _elem . append ( nonCritStats ) ;
parent _elem . append ( document . createElement ( "br" ) ) ;
//Crit: n->elem, total dmg, DPS
let critStats = document . createElement ( "p" ) ;
2021-01-10 21:31:29 +00:00
critStats . classList . add ( "left" ) ;
2021-01-10 21:01:59 +00:00
critStats . classList . add ( "itemp" ) ;
2021-01-09 23:30:05 +00:00
critStats . textContent = "Crit Stats: " ;
critStats . append ( document . createElement ( "br" ) ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
2021-03-31 06:44:56 +00:00
if ( stats [ i ] [ 3 ] != 0 ) {
2021-01-10 21:01:59 +00:00
dmg = document . createElement ( "p" ) ;
2021-03-31 06:44:56 +00:00
dmg . textContent = stats [ i ] [ 2 ] + " \u2013 " + stats [ i ] [ 3 ] ;
2021-01-10 21:01:59 +00:00
dmg . classList . add ( damageClasses [ i ] ) ;
dmg . classList . add ( "itemp" ) ;
2021-03-31 06:44:56 +00:00
tooltiptext = tooltipinfo . get ( "damageformulas" ) [ i ] . slice ( 2 , 4 ) . join ( "\n" ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , dmg , [ "melee-tooltip" ] ) ;
2021-01-09 23:30:05 +00:00
critStats . append ( dmg ) ;
}
}
2021-01-10 21:01:59 +00:00
let critDamage = document . createElement ( "p" ) ;
2021-03-31 06:44:56 +00:00
critDamage . textContent = "Total: " + stats [ 7 ] [ 0 ] + " \u2013 " + stats [ 7 ] [ 1 ] ;
2021-01-10 21:01:59 +00:00
critDamage . classList . add ( "itemp" ) ;
2021-03-31 06:44:56 +00:00
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" ] ) ;
2021-01-10 21:01:59 +00:00
critStats . append ( critDamage ) ;
let critDPS = document . createElement ( "p" ) ;
critDPS . textContent = "Crit DPS: " + stats [ 9 ] ;
critDPS . classList . add ( "itemp" ) ;
2021-03-31 06:44:56 +00:00
tooltiptext = ` = (( ${ stats [ 7 ] [ 0 ] } + ${ stats [ 7 ] [ 1 ] } ) / 2) * ${ baseDamageMultiplier [ stats [ 11 ] ] } ` ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , critDPS , [ "melee-tooltip" ] ) ;
2021-01-10 21:01:59 +00:00
critStats . append ( critDPS ) ;
2021-01-09 23:30:05 +00:00
2021-01-11 02:58:39 +00:00
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 ) ;
2021-01-09 23:30:05 +00:00
parent _elem . append ( critStats ) ;
2021-01-10 21:01:59 +00:00
}
2021-03-27 18:17:58 +00:00
2021-01-11 22:25:55 +00:00
function displayDefenseStats ( parent _elem , build , insertSummary ) {
let defenseStats = build . getDefenseStats ( ) ;
insertSummary = ( typeof insertSummary !== 'undefined' ) ? insertSummary : false ;
if ( ! insertSummary ) {
parent _elem . textContent = "" ;
}
2021-01-10 21:01:59 +00:00
const stats = defenseStats . slice ( ) ;
2021-01-11 22:25:55 +00:00
if ( ! insertSummary ) {
let title _elem = document . createElement ( "p" ) ;
title _elem . textContent = "Defense Stats" ;
title _elem . classList . add ( "title" ) ;
title _elem . classList . add ( "Normal" ) ;
title _elem . classList . add ( "itemp" ) ;
parent _elem . append ( title _elem ) ;
let base _stat _elem = document . createElement ( "p" ) ;
base _stat _elem . id = "base-stat" ;
parent _elem . append ( base _stat _elem ) ;
let mock _item = new Map ( ) ;
mock _item . set ( "fixID" , true ) ;
let mock _minRolls = new Map ( ) ;
mock _item . set ( "minRolls" , mock _minRolls ) ;
2021-01-11 23:43:04 +00:00
const stats = [ "hp" , "hpBonus" , "hprRaw" , "hprPct" , "fDef" , "wDef" , "aDef" , "tDef" , "eDef" ,
2021-01-11 22:25:55 +00:00
"fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" ] ;
for ( const stat of stats ) {
if ( rolledIDs . includes ( stat ) ) {
mock _minRolls . set ( stat , build . statMap . get ( stat ) ) ;
}
else {
mock _item . set ( stat , build . statMap . get ( stat ) ) ;
}
}
mock _item . set ( "powders" , [ ] ) ;
displayExpandedItem ( mock _item , base _stat _elem . id ) ;
}
2021-01-09 23:30:05 +00:00
parent _elem . append ( document . createElement ( "br" ) ) ;
2021-01-10 21:31:29 +00:00
let statsTable = document . createElement ( "table" ) ;
statsTable . classList . add ( "itemtable" ) ;
2021-01-10 21:01:59 +00: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 ) ;
}
}
}
2021-01-11 22:25:55 +00:00
2021-01-10 21:01:59 +00:00
//total HP
2021-01-10 21:31:29 +00:00
let hpRow = document . createElement ( "tr" ) ;
let hp = document . createElement ( "td" ) ;
hp . classList . add ( "Health" ) ;
hp . classList . add ( "left" ) ;
2021-01-11 22:25:55 +00:00
hp . textContent = "Total HP:" ;
2021-01-10 21:31:29 +00:00
let boost = document . createElement ( "td" ) ;
boost . textContent = stats [ 0 ] ;
boost . classList . add ( "right" ) ;
hpRow . appendChild ( hp ) ;
hpRow . append ( boost ) ;
statsTable . appendChild ( hpRow ) ;
2021-01-11 22:25:55 +00:00
2021-03-31 06:44:56 +00:00
let tooltip ; let tooltiptext ;
2021-03-27 18:17:58 +00:00
let defMult = build . statMap . get ( "defMult" ) ;
if ( ! defMult ) { defMult = 1 }
2021-01-10 21:01:59 +00:00
//EHP
2021-01-10 21:31:29 +00:00
let ehpRow = document . createElement ( "tr" ) ;
let ehp = document . createElement ( "td" ) ;
ehp . classList . add ( "left" ) ;
ehp . textContent = "Effective HP:" ;
boost = document . createElement ( "td" ) ;
2021-01-11 00:46:30 +00:00
boost . textContent = stats [ 1 ] [ 0 ] ;
2021-01-10 21:31:29 +00:00
boost . classList . add ( "right" ) ;
2021-03-31 06:44:56 +00: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" ] ) ;
2021-01-10 21:31:29 +00:00
ehpRow . appendChild ( ehp ) ;
ehpRow . append ( boost ) ;
statsTable . append ( ehpRow ) ;
2021-01-11 00:46:30 +00:00
ehpRow = document . createElement ( "tr" ) ;
ehp = document . createElement ( "td" ) ;
ehp . classList . add ( "left" ) ;
ehp . textContent = "Effective HP (no agi):" ;
boost = document . createElement ( "td" ) ;
boost . textContent = stats [ 1 ] [ 1 ] ;
boost . classList . add ( "right" ) ;
2021-03-31 06:44:56 +00: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" ] ) ;
2021-01-11 00:46:30 +00:00
ehpRow . appendChild ( ehp ) ;
ehpRow . append ( boost ) ;
statsTable . append ( ehpRow ) ;
2021-01-10 21:01:59 +00:00
//total HPR
2021-01-10 21:31:29 +00:00
let hprRow = document . createElement ( "tr" ) ;
let hpr = document . createElement ( "td" ) ;
hpr . classList . add ( "Health" ) ;
hpr . classList . add ( "left" ) ;
2021-01-11 22:25:55 +00:00
hpr . textContent = "HP Regen (Total):" ;
2021-01-10 21:31:29 +00:00
boost = document . createElement ( "td" ) ;
2021-01-10 22:38:17 +00:00
boost . textContent = stats [ 2 ] ;
2021-01-10 21:31:29 +00:00
boost . classList . add ( "right" ) ;
2021-01-10 22:38:17 +00:00
2021-01-10 21:31:29 +00:00
hprRow . appendChild ( hpr ) ;
hprRow . appendChild ( boost ) ;
statsTable . appendChild ( hprRow ) ;
2021-01-19 10:12:36 +00:00
//EHPR
2021-01-10 21:31:29 +00:00
let ehprRow = document . createElement ( "tr" ) ;
let ehpr = document . createElement ( "td" ) ;
ehpr . classList . add ( "left" ) ;
ehpr . textContent = "Effective HP Regen:" ;
boost = document . createElement ( "td" ) ;
2021-01-11 00:46:30 +00:00
boost . textContent = stats [ 3 ] [ 0 ] ;
boost . classList . add ( "right" ) ;
2021-03-31 06:44:56 +00: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" ] ) ;
2021-01-11 00:46:30 +00:00
ehprRow . appendChild ( ehpr ) ;
ehprRow . append ( boost ) ;
statsTable . append ( ehprRow ) ;
2021-01-20 05:59:17 +00:00
/ *
ehprRow = document . createElement ( "tr" ) ;
2021-01-11 00:46:30 +00:00
ehpr = document . createElement ( "td" ) ;
ehpr . classList . add ( "left" ) ;
ehpr . textContent = "Effective HP Regen (no agi):" ;
boost = document . createElement ( "td" ) ;
boost . textContent = stats [ 3 ] [ 1 ] ;
2021-01-10 21:31:29 +00:00
boost . classList . add ( "right" ) ;
ehprRow . appendChild ( ehpr ) ;
ehprRow . append ( boost ) ;
2021-01-20 05:59:17 +00:00
statsTable . append ( ehprRow ) ; * /
2021-01-11 22:25:55 +00:00
2021-01-10 21:01:59 +00:00
//eledefs
let eledefs = stats [ 5 ] ;
for ( let i = 0 ; i < eledefs . length ; i ++ ) {
2021-01-10 21:31:29 +00:00
let eledefElemRow = document . createElement ( "tr" ) ;
2021-01-11 01:42:09 +00:00
let eledef = document . createElement ( "td" ) ;
eledef . classList . add ( "left" )
let eledefTitle = document . createElement ( "b" ) ;
2021-01-10 21:31:29 +00:00
eledefTitle . textContent = damageClasses [ i + 1 ] ;
eledefTitle . classList . add ( damageClasses [ i + 1 ] ) ;
2021-01-11 01:42:09 +00:00
let defense = document . createElement ( "b" ) ;
2021-01-11 22:25:55 +00:00
defense . textContent = " Def (Total): " ;
2021-01-11 01:42:09 +00:00
eledef . appendChild ( eledefTitle ) ;
eledef . appendChild ( defense ) ;
eledefElemRow . appendChild ( eledef ) ;
2021-01-10 21:31:29 +00:00
let boost = document . createElement ( "td" ) ;
boost . textContent = eledefs [ i ] ;
2021-03-10 18:58:24 +00:00
boost . classList . add ( eledefs [ i ] >= 0 ? "positive" : "negative" ) ;
2021-01-10 21:31:29 +00:00
boost . classList . add ( "right" ) ;
2021-03-27 18:17:58 +00: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 ;
2021-03-31 06:44:56 +00:00
tooltiptext = ` = min(0, ${ defRaw } * (1 ${ defPct } )) `
2021-03-27 18:17:58 +00:00
} else {
defPct >= 0 ? defPct = "+ " + defPct : defPct = "- " + defPct ;
2021-03-31 06:44:56 +00:00
tooltiptext = ` = ${ defRaw } * (1 ${ defPct } ) `
2021-03-27 18:17:58 +00:00
}
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , boost , [ "def-tooltip" ] ) ;
2021-03-27 18:17:58 +00:00
2021-01-11 01:42:09 +00:00
eledefElemRow . appendChild ( boost ) ;
2021-01-10 21:31:29 +00:00
2021-01-11 01:42:09 +00:00
statsTable . appendChild ( eledefElemRow ) ;
2021-01-10 21:01:59 +00:00
}
2021-01-11 22:25:55 +00:00
if ( ! insertSummary ) {
//skp
let defRow = document . createElement ( "tr" ) ;
let defElem = document . createElement ( "td" ) ;
defElem . classList . add ( "left" ) ;
defElem . textContent = "Damage Absorbed %:" ;
boost = document . createElement ( "td" ) ;
boost . classList . add ( "right" ) ;
boost . textContent = stats [ 4 ] [ 0 ] + "%" ;
defRow . appendChild ( defElem ) ;
defRow . appendChild ( boost ) ;
statsTable . append ( defRow ) ;
let agiRow = document . createElement ( "tr" ) ;
let agiElem = document . createElement ( "td" ) ;
agiElem . classList . add ( "left" ) ;
agiElem . textContent = "Dodge Chance %:" ;
boost = document . createElement ( "td" ) ;
boost . classList . add ( "right" ) ;
boost . textContent = stats [ 4 ] [ 1 ] + "%" ;
agiRow . appendChild ( agiElem ) ;
agiRow . appendChild ( boost ) ;
statsTable . append ( agiRow ) ;
}
2021-01-10 21:31:29 +00:00
parent _elem . append ( statsTable ) ;
2021-01-09 23:30:05 +00:00
}
2021-03-27 18:17:58 +00:00
2021-01-13 03:14:00 +00:00
function displayPowderSpecials ( parent _elem , powderSpecials , build ) {
2021-01-12 21:07:03 +00:00
parent _elem . textContent = "Powder Specials" ;
let specials = powderSpecials . slice ( ) ;
2021-01-13 03:14:00 +00:00
let stats = build . statMap ;
2021-01-14 03:17:01 +00:00
let expandedStats = new Map ( ) ;
2021-01-12 21:07:03 +00:00
//each entry of powderSpecials is [ps, power]
for ( special of specials ) {
2021-01-13 06:57:07 +00:00
//iterate through the special and display its effects.
2021-01-12 21:07:03 +00:00
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 ( "itemp" ) ;
specialTitle . classList . add ( damageClasses [ powderSpecialStats . indexOf ( special [ 0 ] ) + 1 ] ) ;
specialEffects . classList . add ( "left" ) ;
specialEffects . classList . add ( "itemp" ) ;
specialEffects . classList . add ( "nocolor" ) ;
2021-01-12 22:49:02 +00:00
let effects = special [ 0 ] [ "weaponSpecialEffects" ] ;
let power = special [ 1 ] ;
2021-01-13 03:14:00 +00:00
specialTitle . textContent = special [ 0 ] [ "weaponSpecialName" ] + " " + Math . floor ( ( power - 1 ) * 0.5 + 4 ) + ( power % 2 == 0 ? ".5" : "" ) ;
2021-01-12 22:49:02 +00:00
for ( const [ key , value ] of effects ) {
let effect = document . createElement ( "p" ) ;
effect . classList . add ( "itemp" ) ;
effect . textContent += key + ": " + value [ power - 1 ] + specialSuffixes . get ( key ) ;
if ( key === "Damage" ) {
effect . textContent += elementIcons [ powderSpecialStats . indexOf ( special [ 0 ] ) ] ;
}
2021-03-14 07:55:08 +00:00
if ( special [ 0 ] [ "weaponSpecialName" ] === "Wind Prison" && key === "Damage Boost" ) {
2021-01-14 03:17:01 +00:00
effect . textContent += " (only 1st hit)" ;
2021-01-12 22:49:02 +00:00
}
specialEffects . appendChild ( effect ) ;
}
2021-01-12 21:07:03 +00:00
2021-01-13 06:57:07 +00:00
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" ) ;
2021-01-13 08:30:55 +00:00
let spells = spell _table [ "powder" ] ;
2021-01-14 03:17:01 +00:00
if ( powderSpecialStats . indexOf ( special [ 0 ] ) == 0 || powderSpecialStats . indexOf ( special [ 0 ] ) == 1 || powderSpecialStats . indexOf ( special [ 0 ] ) == 3 ) { //Quake, Chain Lightning, or Courage
2021-01-13 08:30:55 +00:00
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 ,
2021-01-14 03:17:01 +00:00
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
2021-01-13 08:30:55 +00:00
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 ) ;
}
2021-01-12 21:07:03 +00:00
}
2021-01-13 08:30:55 +00:00
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" ) ;
specialDamage . append ( averageLabel ) ;
let nonCritLabel = document . createElement ( "p" ) ;
nonCritLabel . textContent = "Non-Crit Average: " + nonCritAverage . toFixed ( 2 ) ;
nonCritLabel . classList . add ( "damageSubtitle" ) ;
specialDamage . append ( nonCritLabel ) ;
2021-01-12 22:49:02 +00:00
2021-01-13 08:30:55 +00:00
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" ) ;
2021-01-12 21:07:03 +00:00
2021-01-13 08:30:55 +00:00
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 ) ;
2021-01-12 21:07:03 +00:00
2021-01-13 08:30:55 +00:00
let critChanceLabel = document . createElement ( "p" ) ;
critChanceLabel . textContent = "Crit Chance: " + ( critChance * 100 ) . toFixed ( 2 ) + "%" ;
specialDamage . append ( critChanceLabel ) ;
save _damages . push ( averageDamage ) ;
2021-01-13 06:57:07 +00:00
powder _special . append ( specialDamage ) ;
2021-01-13 08:30:55 +00:00
}
2021-01-12 21:07:03 +00:00
2021-01-13 06:57:07 +00:00
parent _elem . appendChild ( powder _special ) ;
}
2021-01-12 21:07:03 +00:00
}
2021-03-27 18:17:58 +00:00
2021-01-10 21:01:59 +00:00
function displaySpellDamage ( parent _elem , overallparent _elem , build , spell , spellIdx ) {
2021-01-09 08:52:58 +00:00
parent _elem . textContent = "" ;
2021-03-31 06:44:56 +00:00
let tooltip ; let tooltiptext ;
2021-01-09 08:52:58 +00:00
const stats = build . statMap ;
let title _elem = document . createElement ( "p" ) ;
2021-01-11 07:05:23 +00:00
title _elem . classList . add ( "smalltitle" ) ;
2021-01-10 21:31:29 +00:00
title _elem . classList . add ( "Normal" ) ;
2021-01-10 21:01:59 +00:00
overallparent _elem . textContent = "" ;
let title _elemavg = document . createElement ( "p" ) ;
2021-01-11 07:05:23 +00:00
title _elemavg . classList . add ( 'smalltitle' ) ;
2021-01-10 21:31:29 +00:00
title _elemavg . classList . add ( 'Normal' ) ;
2021-01-09 08:52:58 +00:00
if ( spellIdx != 0 ) {
2021-01-15 18:20:17 +00:00
let first = document . createElement ( "b" ) ;
2021-01-15 08:23:55 +00:00
first . textContent = spell . title + " (" ;
2021-01-16 07:30:19 +00:00
title _elem . appendChild ( first . cloneNode ( true ) ) ; //cloneNode is needed here.
2021-01-15 08:23:55 +00:00
title _elemavg . appendChild ( first ) ;
2021-03-27 18:17:58 +00:00
2021-01-15 08:23:55 +00:00
let second = document . createElement ( "b" ) ;
second . textContent = build . getSpellCost ( spellIdx , spell . cost ) ;
2021-01-15 18:20:17 +00:00
second . classList . add ( "Mana" ) ;
2021-03-27 18:17:58 +00:00
second . classList . add ( "tooltip" ) ;
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 ) ;
2021-03-31 06:44:56 +00:00
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 ) ;
2021-01-16 07:30:19 +00:00
title _elem . appendChild ( second . cloneNode ( true ) ) ;
2021-01-15 08:23:55 +00:00
title _elemavg . appendChild ( second ) ;
2021-03-27 18:17:58 +00:00
2021-01-16 07:30:19 +00:00
let third = document . createElement ( "b" ) ;
third . textContent = ")" ;
title _elem . appendChild ( third . cloneNode ( true ) ) ;
title _elemavg . appendChild ( third ) ;
2021-01-15 08:23:55 +00:00
2021-01-09 08:52:58 +00:00
}
else {
title _elem . textContent = spell . title ;
2021-01-10 21:01:59 +00:00
title _elemavg . textContent = spell . title ;
2021-01-09 08:52:58 +00:00
}
parent _elem . append ( title _elem ) ;
2021-01-10 21:01:59 +00:00
overallparent _elem . append ( title _elemavg ) ;
2021-01-09 08:52:58 +00:00
let critChance = skillPointsToPercentage ( build . total _skillpoints [ 1 ] ) ;
2021-01-09 09:35:18 +00:00
let save _damages = [ ] ;
2021-01-19 01:57:26 +00:00
let part _divavg = document . createElement ( "p" ) ;
part _divavg . classList . add ( "nomargin" ) ;
overallparent _elem . append ( part _divavg ) ;
2021-01-30 12:03:40 +00:00
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 ;
}
}
}
2021-03-27 18:17:58 +00:00
//console.log(spell_parts);
2021-01-30 12:03:40 +00:00
for ( const part of spell _parts ) {
2021-01-09 08:52:58 +00:00
parent _elem . append ( document . createElement ( "br" ) ) ;
let part _div = document . createElement ( "p" ) ;
parent _elem . append ( part _div ) ;
let subtitle _elem = document . createElement ( "p" ) ;
subtitle _elem . textContent = part . subtitle ;
2021-01-19 01:57:26 +00:00
subtitle _elem . classList . add ( "nomargin" ) ;
2021-01-09 08:52:58 +00:00
part _div . append ( subtitle _elem ) ;
2021-01-10 21:01:59 +00:00
2021-01-09 08:52:58 +00:00
if ( part . type === "damage" ) {
2021-01-14 03:17:01 +00:00
//console.log(build.expandedStats);
2021-01-09 08:52:58 +00:00
let _results = calculateSpellDamage ( stats , part . conversion ,
2021-01-14 03:17:01 +00:00
stats . get ( "sdRaw" ) , stats . get ( "sdPct" ) + build . externalStats . get ( "sdPct" ) ,
part . multiplier / 100 , build . weapon , build . total _skillpoints , build . damageMultiplier , build . externalStats ) ;
2021-01-09 08:52:58 +00:00
let totalDamNormal = _results [ 0 ] ;
let totalDamCrit = _results [ 1 ] ;
let results = _results [ 2 ] ;
2021-03-31 06:44:56 +00:00
let tooltipinfo = _results [ 3 ] ;
2021-01-09 08:52:58 +00:00
for ( let i = 0 ; i < 6 ; ++ i ) {
for ( let j in results [ i ] ) {
2021-01-09 11:01:57 +00:00
results [ i ] [ j ] = results [ i ] [ j ] . toFixed ( 2 ) ;
2021-01-09 08:52:58 +00:00
}
}
2021-01-13 02:48:00 +00:00
let nonCritAverage = ( totalDamNormal [ 0 ] + totalDamNormal [ 1 ] ) / 2 || 0 ;
let critAverage = ( totalDamCrit [ 0 ] + totalDamCrit [ 1 ] ) / 2 || 0 ;
let averageDamage = ( 1 - critChance ) * nonCritAverage + critChance * critAverage || 0 ;
2021-01-09 08:52:58 +00:00
2021-01-09 09:35:18 +00:00
let averageLabel = document . createElement ( "p" ) ;
2021-01-09 11:01:57 +00:00
averageLabel . textContent = "Average: " + averageDamage . toFixed ( 2 ) ;
2021-03-31 06:44:56 +00:00
tooltiptext = ` = ((1 - ${ critChance } ) * ${ nonCritAverage . toFixed ( 2 ) } ) + ( ${ critChance } * ${ critAverage . toFixed ( 2 ) } ) `
2021-01-09 09:35:18 +00:00
averageLabel . classList . add ( "damageSubtitle" ) ;
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , averageLabel , [ "spell-tooltip" ] ) ;
2021-01-09 09:35:18 +00:00
part _div . append ( averageLabel ) ;
2021-01-09 08:52:58 +00:00
2021-03-27 18:17:58 +00:00
2021-01-10 22:16:22 +00:00
if ( part . summary == true ) {
let overallaverageLabel = document . createElement ( "p" ) ;
2021-01-15 08:23:55 +00:00
let first = document . createElement ( "b" ) ;
let second = document . createElement ( "b" ) ;
2021-01-19 01:57:26 +00:00
first . textContent = part . subtitle + " Average: " ;
2021-01-15 08:23:55 +00:00
second . textContent = averageDamage . toFixed ( 2 ) ;
overallaverageLabel . appendChild ( first ) ;
overallaverageLabel . appendChild ( second ) ;
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , overallaverageLabel , [ "spell-tooltip" , "summary-tooltip" ] ) ;
2021-01-15 08:23:55 +00:00
second . classList . add ( "Damage" ) ;
2021-01-19 01:57:26 +00:00
overallaverageLabel . classList . add ( "overallp" ) ;
2021-01-10 22:16:22 +00:00
part _divavg . append ( overallaverageLabel ) ;
}
2021-01-10 21:01:59 +00:00
2021-01-09 08:52:58 +00:00
let nonCritLabel = document . createElement ( "p" ) ;
2021-01-09 11:01:57 +00:00
nonCritLabel . textContent = "Non-Crit Average: " + nonCritAverage . toFixed ( 2 ) ;
2021-01-09 08:52:58 +00:00
nonCritLabel . classList . add ( "damageSubtitle" ) ;
part _div . append ( nonCritLabel ) ;
2021-01-10 21:31:29 +00:00
2021-03-31 06:44:56 +00:00
let noncritarrmin = [ ] ;
let noncritarrmax = [ ] ;
2021-01-09 08:52:58 +00:00
for ( let i = 0 ; i < 6 ; i ++ ) {
2021-03-31 06:44:56 +00:00
if ( results [ i ] [ 1 ] != 0 ) {
2021-01-09 08:52:58 +00:00
let p = document . createElement ( "p" ) ;
p . classList . add ( "damagep" ) ;
p . classList . add ( damageClasses [ i ] ) ;
2021-03-31 06:44:56 +00:00
p . textContent = results [ i ] [ 0 ] + " \u2013 " + results [ i ] [ 1 ] ;
tooltiptext = tooltipinfo . get ( "damageformulas" ) [ i ] . slice ( 0 , 2 ) . join ( "\n" ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , p , [ "spell-tooltip" ] ) ;
noncritarrmin . push ( results [ i ] [ 0 ] ) ;
noncritarrmax . push ( results [ i ] [ 1 ] ) ;
2021-01-09 08:52:58 +00:00
part _div . append ( p ) ;
}
}
2021-03-31 06:44:56 +00:00
tooltiptext = ` = (( ${ noncritarrmin . join ( " + " ) } ) + ( ${ noncritarrmax . join ( " + " ) } )) / 2 ` ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , nonCritLabel , [ "spell-tooltip" ] ) ;
2021-01-09 08:52:58 +00:00
//part_div.append(document.createElement("br"));
let critLabel = document . createElement ( "p" ) ;
2021-01-09 11:01:57 +00:00
critLabel . textContent = "Crit Average: " + critAverage . toFixed ( 2 ) ;
2021-01-09 08:52:58 +00:00
critLabel . classList . add ( "damageSubtitle" ) ;
part _div . append ( critLabel ) ;
2021-03-31 06:44:56 +00:00
let critarrmin = [ ] ;
let critarrmax = [ ] ;
2021-01-09 08:52:58 +00:00
for ( let i = 0 ; i < 6 ; i ++ ) {
2021-03-31 06:44:56 +00:00
if ( results [ i ] [ 1 ] != 0 ) {
2021-01-09 08:52:58 +00:00
let p = document . createElement ( "p" ) ;
p . classList . add ( "damagep" ) ;
p . classList . add ( damageClasses [ i ] ) ;
2021-03-31 06:44:56 +00:00
p . textContent = results [ i ] [ 2 ] + " \u2013 " + results [ i ] [ 3 ] ;
tooltiptext = tooltipinfo . get ( "damageformulas" ) [ i ] . slice ( 2 , 4 ) . join ( "\n" ) ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , p , [ "spell-tooltip" ] ) ;
critarrmin . push ( results [ i ] [ 2 ] ) ;
critarrmax . push ( results [ i ] [ 3 ] ) ;
2021-01-09 08:52:58 +00:00
part _div . append ( p ) ;
}
}
2021-03-31 06:44:56 +00:00
tooltiptext = ` = (( ${ critarrmin . join ( " + " ) } ) + ( ${ critarrmax . join ( " + " ) } )) / 2 ` ;
tooltip = createTooltip ( tooltip , "p" , tooltiptext , critLabel , [ "spell-tooltip" ] ) ;
2021-01-09 09:35:18 +00:00
save _damages . push ( averageDamage ) ;
2021-03-27 18:17:58 +00:00
} else if ( part . type === "heal" ) {
2021-01-11 22:25:55 +00:00
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 ) ;
2021-03-31 06:44:56 +00:00
tooltiptext = ` = ${ part . strength } * ${ build . getDefenseStats ( ) [ 0 ] } * max(0.5, min(1.75, 1 + 0.5 * ${ stats . get ( "wDamPct" ) / 100 } )) ` ;
2021-01-09 11:56:10 +00:00
let healLabel = document . createElement ( "p" ) ;
healLabel . textContent = heal _amount ;
healLabel . classList . add ( "damagep" ) ;
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , healLabel , [ "spell-tooltip" ] ) ;
2021-01-09 11:56:10 +00:00
part _div . append ( healLabel ) ;
2021-01-10 22:16:22 +00:00
if ( part . summary == true ) {
let overallhealLabel = document . createElement ( "p" ) ;
2021-01-19 01:57:26 +00:00
let first = document . createElement ( "b" ) ;
let second = document . createElement ( "b" ) ;
2021-01-20 11:49:42 +00:00
first . textContent = part . subtitle + ": " ;
2021-01-19 01:57:26 +00:00
second . textContent = heal _amount ;
overallhealLabel . appendChild ( first ) ;
second . classList . add ( "Set" ) ;
overallhealLabel . appendChild ( second ) ;
overallhealLabel . classList . add ( "overallp" ) ;
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , second , [ "spell-tooltip" ] ) ;
2021-01-10 22:16:22 +00:00
part _divavg . append ( overallhealLabel ) ;
}
2021-03-27 18:17:58 +00:00
} else if ( part . type === "total" ) {
2021-01-09 09:35:18 +00:00
let total _damage = 0 ;
2021-03-31 06:44:56 +00:00
tooltiptext = "" ;
2021-01-09 09:35:18 +00:00
for ( let i in part . factors ) {
2021-01-09 09:37:01 +00:00
total _damage += save _damages [ i ] * part . factors [ i ] ;
2021-01-09 09:35:18 +00:00
}
2021-03-31 06:44:56 +00:00
let dmgarr = part . factors . slice ( ) ;
dmgarr = dmgarr . map ( x => "(" + x + " * " + save _damages [ dmgarr . indexOf ( x ) ] . toFixed ( 2 ) + ")" ) ;
tooltiptext = " = " + dmgarr . join ( " + " ) ;
2021-01-09 09:35:18 +00:00
let averageLabel = document . createElement ( "p" ) ;
2021-01-09 11:01:57 +00:00
averageLabel . textContent = "Average: " + total _damage . toFixed ( 2 ) ;
2021-01-09 09:35:18 +00:00
averageLabel . classList . add ( "damageSubtitle" ) ;
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , averageLabel , [ "spell-tooltip" ] ) ;
2021-01-09 09:35:18 +00:00
part _div . append ( averageLabel ) ;
2021-01-10 21:01:59 +00:00
let overallaverageLabel = document . createElement ( "p" ) ;
overallaverageLabel . classList . add ( "damageSubtitle" ) ;
2021-01-15 18:20:17 +00:00
let overallaverageLabelFirst = document . createElement ( "b" ) ;
let overallaverageLabelSecond = document . createElement ( "b" ) ;
overallaverageLabelFirst . textContent = "Average: " ;
overallaverageLabelSecond . textContent = total _damage . toFixed ( 2 ) ;
overallaverageLabelSecond . classList . add ( "Damage" ) ;
2021-03-31 06:44:56 +00:00
tooltip = createTooltip ( tooltip , "p" , tooltiptext , overallaverageLabel , [ "spell-tooltip" , "summary-tooltip" ] ) ;
2021-01-15 18:20:17 +00:00
overallaverageLabel . appendChild ( overallaverageLabelFirst ) ;
overallaverageLabel . appendChild ( overallaverageLabelSecond ) ;
2021-01-10 22:16:22 +00:00
part _divavg . append ( overallaverageLabel ) ;
2021-01-09 08:52:58 +00:00
}
}
}
2021-03-14 07:55:08 +00:00
/ * * D i s p l a y s t h e I D c o s t s o f a n i t e m
*
* @ param { String } elemID - the id of the parent element .
2021-03-24 22:49:17 +00:00
* @ param { Map } item - the statMap of an item .
2021-03-14 07:55:08 +00:00
* /
2021-03-24 22:49:17 +00:00
function displayIDCosts ( elemID , item ) {
2021-03-14 07:55:08 +00:00
let parent _elem = document . getElementById ( elemID ) ;
let tier = item . get ( "tier" ) ;
if ( ( item . has ( "fixID" ) && item . get ( "fixID" ) ) || [ "Normal" , "Crafted" , "Custom" , "none" , " " , ] . includes ( item . get ( "tier" ) ) ) {
return ;
} else {
/ * * R e t u r n s t h e n u m b e r o f i n v e n t o r y s l o t s m i n i m u m a n a m o u n t o f e m e r a l d s w o u l d t a k e u p + t h e c o n f i g u r a t i o n o f d o i n g s o .
* Returns an array of [ invSpace , E , EB , LE , Stx LE ]
*
* @ param { number } ems - the total numerical value of emeralds to compact .
* /
function emsToInvSpace ( ems ) {
let stx = Math . floor ( ems / 262144 ) ;
ems -= stx * 4096 * 64 ;
let LE = Math . floor ( ems / 4096 ) ;
ems -= LE * 4096 ;
let EB = Math . floor ( ems / 64 ) ;
ems -= EB * 64 ;
let e = ems ;
return [ stx + Math . ceil ( LE / 64 ) + Math . ceil ( EB / 64 ) + Math . ceil ( e / 64 ) , e , EB , LE , stx ] ;
}
/ * *
*
* @ param { String } tier - item tier
* @ param { Number } lvl - item level
* /
function getIDCost ( tier , lvl ) {
switch ( tier ) {
case "Unique" :
return Math . round ( 0.5 * lvl + 3 ) ;
case "Rare" :
return Math . round ( 1.2 * lvl + 8 ) ;
case "Legendary" :
return Math . round ( 4.5 * lvl + 12 ) ;
case "Fabled" :
return Math . round ( 12 * lvl + 26 ) ;
case "Mythic" :
return Math . round ( 18 * lvl + 90 ) ;
case "Set" :
return Math . round ( 1.5 * lvl + 8 )
default :
return - 1 ;
}
}
parent _elem . style = "display: visible" ;
let lvl = item . get ( "lvl" ) ;
if ( typeof ( lvl ) === "string" ) { lvl = parseFloat ( lvl ) ; }
let title _elem = document . createElement ( "p" ) ;
title _elem . classList . add ( "smalltitle" ) ;
title _elem . style . color = "white" ;
title _elem . textContent = "Identification Costs" ;
parent _elem . appendChild ( title _elem ) ;
parent _elem . appendChild ( document . createElement ( "br" ) ) ;
let grid _item = document . createElement ( "div" ) ;
grid _item . style . display = "flex" ;
grid _item . style . flexDirection = "rows" ;
grid _item . style . flexWrap = "wrap" ;
grid _item . style . gap = "5px" ;
parent _elem . appendChild ( grid _item ) ;
let IDcost = getIDCost ( tier , lvl ) ;
let initIDcost = IDcost ;
let invSpace = emsToInvSpace ( IDcost ) ;
let rerolls = 0 ;
while ( invSpace [ 0 ] <= 28 && IDcost > 0 ) {
let container = document . createElement ( "div" ) ;
container . classList . add ( "container" ) ;
container . style = "grid-item-" + ( rerolls + 1 ) ;
container . style . maxWidth = "max(120px, 15%)" ;
let container _title = document . createElement ( "p" ) ;
container _title . style . color = "white" ;
if ( rerolls == 0 ) {
container _title . textContent = "Initial ID Cost: " ;
} else {
container _title . textContent = "Reroll to [" + ( rerolls + 1 ) + "] Cost:" ;
}
container . appendChild ( container _title ) ;
let total _cost _container = document . createElement ( "p" ) ;
let total _cost _number = document . createElement ( "b" ) ;
total _cost _number . classList . add ( "Set" ) ;
total _cost _number . textContent = IDcost + " " ;
let total _cost _suffix = document . createElement ( "b" ) ;
total _cost _suffix . textContent = "emeralds."
total _cost _container . appendChild ( total _cost _number ) ;
total _cost _container . appendChild ( total _cost _suffix ) ;
container . appendChild ( total _cost _container ) ;
let OR = document . createElement ( "p" ) ;
OR . classList . add ( "center" ) ;
OR . textContent = "OR" ;
container . appendChild ( OR ) ;
let esuffixes = [ "" , "emeralds." , "EB." , "LE." , "stacks of LE." ] ;
for ( let i = 4 ; i > 0 ; i -- ) {
let n _container = document . createElement ( "p" ) ;
let n _number = document . createElement ( "b" ) ;
n _number . classList . add ( "Set" ) ;
n _number . textContent = invSpace [ i ] + " " ;
let n _suffix = document . createElement ( "b" ) ;
n _suffix . textContent = esuffixes [ i ] ;
n _container . appendChild ( n _number ) ;
n _container . appendChild ( n _suffix ) ;
container . appendChild ( n _container ) ;
}
grid _item . appendChild ( container ) ;
rerolls += 1 ;
IDcost = Math . round ( initIDcost * ( 5 * * rerolls ) ) ;
invSpace = emsToInvSpace ( IDcost ) ;
}
}
}
/ * * D i s p l a y s A d d i t i o n a l I n f o f o r
*
* @ param { String } elemID - the parent element ' s id
2021-03-24 22:49:17 +00:00
* @ param { Map } item - the statMap of the item
2021-03-14 07:55:08 +00:00
* @ returns
* /
2021-03-24 22:49:17 +00:00
function displayAdditionalInfo ( elemID , item ) {
2021-03-14 07:55:08 +00:00
let parent _elem = document . getElementById ( elemID ) ;
parent _elem . classList . add ( "left" ) ;
let droptype _elem = document . createElement ( "div" ) ;
droptype _elem . classList . add ( "container" ) ;
droptype _elem . style . marginBottom = "5px" ;
droptype _elem . textContent = "Drop type: " + ( item . has ( "drop" ) ? item . get ( "drop" ) : "NEVER" ) ;
parent _elem . appendChild ( droptype _elem ) ;
let warning _elem = document . createElement ( "div" ) ;
warning _elem . classList . add ( "container" ) ;
warning _elem . style . marginBottom = "5px" ;
warning _elem . textContent = "This page is incomplete. Will work on it later." ;
parent _elem . appendChild ( warning _elem ) ;
return ;
2021-03-16 06:09:28 +00:00
}
2021-03-24 22:49:17 +00:00
/ * * D i s p l a y s a l l s e t b o n u s e s ( 0 / n , 1 / n , . . . n / n ) f o r a g i v e n s e t
*
* @ param { String } parent _id - id of the parent element
* @ param { String } setName - the name of the set
* /
function displayAllSetBonuses ( parent _id , setName ) {
let parent _elem = document . getElementById ( parent _id ) ;
parent _elem . style . display = "" ;
let set = sets [ setName ] ;
let title _elem = document . createElement ( "p" ) ;
title _elem . textContent = setName + " Set Bonuses" ;
title _elem . classList . add ( "Set" ) ;
title _elem . classList . add ( "title" ) ;
parent _elem . appendChild ( title _elem ) ;
let grid _elem = document . createElement ( "div" ) ;
grid _elem . style . display = "flex" ;
grid _elem . style . flexDirection = "rows" ;
grid _elem . style . flexWrap = "wrap" ;
grid _elem . style . gap = "5px" ;
parent _elem . appendChild ( grid _elem ) ;
for ( let i = 0 ; i < set . items . length ; i ++ ) {
let set _elem = document . createElement ( 'p' ) ;
set _elem . classList . add ( "container" ) ;
set _elem . style = "grid-item-" + ( i + 1 ) ;
set _elem . style . maxWidth = "max(180px, 15%)" ;
set _elem . id = "set-" + setName + "-" + i ;
grid _elem . appendChild ( set _elem ) ;
const bonus = set . bonuses [ i ] ;
let mock _item = new Map ( ) ;
mock _item . set ( "fixID" , true ) ;
mock _item . set ( "displayName" , setName + " Set: " + ( i + 1 ) + "/" + sets [ setName ] . items . length ) ;
set _elem . textContent = mock _item . get ( "displayName" ) ;
let mock _minRolls = new Map ( ) ;
let mock _maxRolls = new Map ( ) ;
mock _item . set ( "minRolls" , mock _minRolls ) ;
mock _item . set ( "maxRolls" , mock _maxRolls ) ;
for ( const id in bonus ) {
if ( rolledIDs . includes ( id ) ) {
mock _minRolls . set ( id , bonus [ id ] ) ;
mock _maxRolls . set ( id , bonus [ id ] ) ;
}
else {
mock _item . set ( id , bonus [ id ] ) ;
}
}
mock _item . set ( "powders" , [ ] ) ;
displayExpandedItem ( mock _item , set _elem . id ) ;
}
}
/ * * D i s p l a y s t h e i n d i v i d u a l p r o b a b i l i t i e s o f e a c h p o s s i b l e v a l u e o f e a c h r o l l a b l e I D f o r t h i s i t e m .
*
* @ param { String } parent _id the document id of the parent element
* @ param { String } item expandedItem object
* /
function displayIDProbabilities ( parent _id , item ) {
2021-03-26 02:19:07 +00:00
if ( item . has ( "fixID" ) && item . get ( "fixID" ) ) { return }
2021-03-24 22:49:17 +00:00
let parent _elem = document . getElementById ( parent _id ) ;
parent _elem . style . display = "" ;
let title _elem = document . createElement ( "p" ) ;
title _elem . textContent = "Identification Probabilities" ;
title _elem . classList . add ( "Legendary" ) ;
title _elem . classList . add ( "title" ) ;
parent _elem . appendChild ( title _elem ) ;
2021-03-26 02:19:07 +00:00
let disclaimer _elem = document . createElement ( "p" ) ;
disclaimer _elem . textContent = "IDs are rolled on a uniform distribution. A chance of 0% means that either the minimum or maximum possible multiplier must be rolled to get this value."
parent _elem . appendChild ( disclaimer _elem ) ;
2021-03-24 22:49:17 +00:00
let item _name = item . get ( "displayName" ) ;
console . log ( itemMap . get ( item _name ) )
2021-03-26 02:19:07 +00:00
let table _elem = document . createElement ( "table" ) ;
parent _elem . appendChild ( table _elem ) ;
for ( const [ id , val ] of Object . entries ( itemMap . get ( item _name ) ) ) {
if ( rolledIDs . includes ( id ) ) {
let min = item . get ( "minRolls" ) . get ( id ) ;
let max = item . get ( "maxRolls" ) . get ( id ) ;
let row _title = document . createElement ( "tr" ) ;
//row_title.style.textAlign = "left";
let title _left = document . createElement ( "td" ) ;
let left _elem = document . createElement ( "p" ) ;
let left _val _title = document . createElement ( "b" ) ;
let left _val _elem = document . createElement ( "b" ) ;
title _left . style . textAlign = "left" ;
left _val _title . textContent = idPrefixes [ id ] + "Base " ;
left _val _elem . textContent = val + idSuffixes [ id ] ;
if ( val > 0 == ! reversedIDs . includes ( id ) ) {
left _val _elem . classList . add ( "positive" ) ;
} else if ( val > 0 == reversedIDs . includes ( id ) ) {
left _val _elem . classList . add ( "negative" ) ;
}
left _elem . appendChild ( left _val _title ) ;
left _elem . appendChild ( left _val _elem ) ;
title _left . appendChild ( left _elem ) ;
row _title . appendChild ( title _left ) ;
let title _right = document . createElement ( "td" ) ;
let title _right _text = document . createElement ( "b" ) ;
title _right . style . textAlign = "left" ;
title _right _text . textContent = "[ " + min + idSuffixes [ id ] + ", " + max + idSuffixes [ id ] + " ]" ;
if ( ( min > 0 && max > 0 && ! reversedIDs . includes ( id ) ) || ( min < 0 && max < 0 && reversedIDs . includes ( id ) ) ) {
title _right _text . classList . add ( "positive" ) ;
} else if ( ( min < 0 && max < 0 && ! reversedIDs . includes ( id ) ) || ( min > 0 && max > 0 && reversedIDs . includes ( id ) ) ) {
title _right _text . classList . add ( "negative" ) ;
}
title _right . appendChild ( title _right _text ) ;
let title _input = document . createElement ( "td" ) ;
let title _input _slider = document . createElement ( "input" ) ;
title _input _slider . type = "range" ;
title _input _slider . id = id + "-slider" ;
if ( ! reversedIDs . includes ( id ) ) {
title _input _slider . step = 1 ;
title _input _slider . min = ` ${ min } ` ;
title _input _slider . max = ` ${ max } ` ;
title _input _slider . value = ` ${ max } ` ;
} else {
title _input _slider . step = 1 ;
title _input _slider . min = ` ${ - 1 * min } ` ;
title _input _slider . max = ` ${ - 1 * max } ` ;
title _input _slider . value = ` ${ - 1 * max } ` ;
}
let title _input _textbox = document . createElement ( "input" ) ;
title _input _textbox . type = "text" ;
title _input _textbox . value = ` ${ max } ` ;
title _input _textbox . id = id + "-textbox" ;
title _input _textbox . classList . add ( "small-input" ) ;
title _input . appendChild ( title _input _slider ) ;
title _input . appendChild ( title _input _textbox ) ;
row _title . appendChild ( title _left ) ;
row _title . appendChild ( title _right ) ;
row _title . appendChild ( title _input ) ;
let row _chances = document . createElement ( "tr" ) ;
let chance _cdf = document . createElement ( "td" ) ;
let chance _pdf = document . createElement ( "td" ) ;
let cdf _p = document . createElement ( "p" ) ;
cdf _p . id = id + "-cdf" ;
let pdf _p = document . createElement ( "p" ) ;
pdf _p . id = id + "-pdf" ;
chance _cdf . appendChild ( cdf _p ) ;
chance _pdf . appendChild ( pdf _p ) ;
row _chances . appendChild ( chance _cdf ) ;
row _chances . appendChild ( chance _pdf ) ;
table _elem . appendChild ( row _title ) ;
table _elem . appendChild ( row _chances ) ;
stringPDF ( id , max , val ) ; //val is base roll
stringCDF ( id , max , val ) ; //val is base roll
title _input _slider . addEventListener ( "change" , ( event ) => {
let id _name = event . target . id . split ( "-" ) [ 0 ] ;
let textbox _elem = document . getElementById ( id _name + "-textbox" ) ;
if ( reversedIDs . includes ( id _name ) ) {
if ( event . target . value < - 1 * min ) { event . target . value = - 1 * min }
if ( event . target . value > - 1 * max ) { event . target . value = - 1 * max }
stringPDF ( id _name , - 1 * event . target . value , val ) ; //val is base roll
stringCDF ( id _name , - 1 * event . target . value , val ) ; //val is base roll
} else {
if ( event . target . value < min ) { event . target . value = min }
if ( event . target . value > max ) { event . target . value = max }
stringPDF ( id _name , 1 * event . target . value , val ) ; //val is base roll
stringCDF ( id _name , 1 * event . target . value , val ) ; //val is base roll
}
if ( textbox _elem && textbox _elem . value !== event . target . value ) {
if ( reversedIDs . includes ( id _name ) ) {
textbox _elem . value = - event . target . value ;
} else {
textbox _elem . value = event . target . value ;
}
}
} ) ;
title _input _textbox . addEventListener ( "change" , ( event ) => {
let id _name = event . target . id . split ( "-" ) [ 0 ] ;
if ( reversedIDs . includes ( id _name ) ) {
if ( event . target . value > min ) { event . target . value = min }
if ( event . target . value < max ) { event . target . value = max }
} else {
if ( event . target . value < min ) { event . target . value = min }
if ( event . target . value > max ) { event . target . value = max }
}
let slider _elem = document . getElementById ( id _name + "-slider" ) ;
if ( slider _elem . value !== event . target . value ) {
slider _elem . value = - event . target . value ;
}
stringPDF ( id _name , 1 * event . target . value , val ) ;
stringCDF ( id _name , 1 * event . target . value , val ) ;
} ) ;
}
}
}
//helper functions. id - the string of the id's name, val - the value of the id, base - the base value of the item for this id
function stringPDF ( id , val , base ) {
/ * * [ 0 . 3 b , 1 . 3 b ] p o s i t i v e n o r m a l
* [ 1.3 b , 0.3 b ] positive reversed
* [ 1.3 b , 0.7 b ] negative normal
* [ 0.7 b , 1.3 b ] negative reversed
*
* [ 0.3 , 1.3 ] minr , maxr [ 0.3 b , 1.3 b ] min , max
* the minr / maxr decimal roll that corresponds to val - > minround , maxround
* /
let p ; let min ; let max ; let minr ; let maxr ; let minround ; let maxround ;
if ( base > 0 ) {
minr = 0.3 ; maxr = 1.3 ;
min = Math . max ( 1 , Math . round ( minr * base ) ) ; max = Math . max ( 1 , Math . round ( maxr * base ) ) ;
minround = ( min == max ) ? ( minr ) : ( Math . max ( minr , ( val - 0.5 ) / base ) ) ;
maxround = ( min == max ) ? ( maxr ) : ( Math . min ( maxr , ( val + 0.5 ) / base ) ) ;
} else {
minr = 1.3 ; maxr = 0.7 ;
min = Math . min ( - 1 , Math . round ( minr * base ) ) ; max = Math . min ( - 1 , Math . round ( maxr * base ) ) ;
minround = ( min == max ) ? ( minr ) : ( Math . min ( minr , ( val - 0.5 ) / base ) ) ;
maxround = ( min == max ) ? ( maxr ) : ( Math . max ( maxr , ( val + 0.5 ) / base ) ) ;
}
console . log ( ( Math . min ( maxr , ( val + 0.5 ) / base ) ) ) ;
p = Math . abs ( maxround - minround ) / Math . abs ( maxr - minr ) * 100 ;
p = p . toFixed ( 3 ) ;
let b1 = document . createElement ( "b" ) ;
b1 . textContent = "Roll exactly " ;
let b2 = document . createElement ( "b" ) ;
b2 . textContent = val + idSuffixes [ id ] ;
if ( val > 0 == ! reversedIDs . includes ( id ) ) { b2 . classList . add ( "positive" ) }
if ( val > 0 == reversedIDs . includes ( id ) ) { b2 . classList . add ( "negative" ) }
let b3 = document . createElement ( "b" ) ;
b3 . textContent = ": " + p + "%" ;
document . getElementById ( id + "-pdf" ) . innerHTML = "" ;
document . getElementById ( id + "-pdf" ) . appendChild ( b1 ) ;
document . getElementById ( id + "-pdf" ) . appendChild ( b2 ) ;
document . getElementById ( id + "-pdf" ) . appendChild ( b3 ) ;
document . getElementById ( id + "-pdf" ) . style . textAlign = "left" ;
}
function stringCDF ( id , val , base ) {
let p ; let min ; let max ; let minr ; let maxr ; let minround ; let maxround ;
if ( base > 0 ) {
minr = 0.3 ; maxr = 1.3 ;
min = Math . max ( 1 , Math . round ( minr * base ) ) ; max = Math . max ( 1 , Math . round ( maxr * base ) ) ;
minround = ( min == max ) ? ( minr ) : ( Math . max ( minr , ( val - 0.5 ) / base ) ) ;
maxround = ( min == max ) ? ( maxr ) : ( Math . min ( maxr , ( val + 0.5 ) / base ) ) ;
} else {
minr = 1.3 ; maxr = 0.7 ;
min = Math . min ( - 1 , Math . round ( minr * base ) ) ; max = Math . min ( - 1 , Math . round ( maxr * base ) ) ;
minround = ( min == max ) ? ( minr ) : ( Math . min ( minr , ( val - 0.5 ) / base ) ) ;
maxround = ( min == max ) ? ( maxr ) : ( Math . max ( maxr , ( val + 0.5 ) / base ) ) ;
}
console . log ( ( Math . min ( maxr , ( val + 0.5 ) / base ) ) ) ;
if ( reversedIDs . includes ( id ) ) {
p = Math . abs ( minr - maxround ) / Math . abs ( maxr - minr ) * 100 ;
} else {
p = Math . abs ( maxr - minround ) / Math . abs ( maxr - minr ) * 100 ;
}
p = p . toFixed ( 3 ) ;
let b1 = document . createElement ( "b" ) ;
b1 . textContent = "Roll " ;
let b2 = document . createElement ( "b" ) ;
b2 . textContent = val + idSuffixes [ id ] ;
if ( val > 0 == ! reversedIDs . includes ( id ) ) { b2 . classList . add ( "positive" ) }
if ( val > 0 == reversedIDs . includes ( id ) ) { b2 . classList . add ( "negative" ) }
let b3 = document . createElement ( "b" ) ;
b3 . textContent = " or better: " + p + "%" ;
document . getElementById ( id + "-cdf" ) . innerHTML = "" ;
document . getElementById ( id + "-cdf" ) . appendChild ( b1 ) ;
document . getElementById ( id + "-cdf" ) . appendChild ( b2 ) ;
document . getElementById ( id + "-cdf" ) . appendChild ( b3 ) ;
document . getElementById ( id + "-cdf" ) . style . textAlign = "left" ;
2021-03-25 08:38:52 +00:00
}