2022-07-24 21:31:23 +00:00
const itemBGPositions = { "bow" : "0 0" , "spear" : "9.090909090909088% 0" , "wand" : "18.181818181818183% 0" , "dagger" : "27.27272727272727% 0" , "relik" : "36.36363636363637% 0" ,
"helmet" : "45.45454545454546% 0" , "chestplate" : "54.54545454545454% 0" , "leggings" : "63.63636363636363% 0" , "boots" : "72.72727272727272% 0" ,
"ring" : "81.81818181818181% 0" , "bracelet" : "90.90909090909092% 0" , "necklace" : "100% 0" ,
"potion" : "25% 0" , "scroll" : "50% 0" , "food" : "75% 0" } ;
2021-01-10 21:31:29 +00:00
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 ] ;
2022-07-17 02:43:13 +00:00
let i _elem = make _elem ( 'span' , [ element _prefix ] , { textContent : element _prefix } ) ;
2021-01-09 12:47:25 +00:00
p _elem . appendChild ( i _elem ) ;
2022-07-17 03:06:01 +00:00
let i _elem2 = make _elem ( 'span' , [ ] , { textContent : " " + desc + suffix } ) ;
2021-01-09 12:47:25 +00:00
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 ) ;
2022-07-17 02:43:13 +00:00
let set _summary _elem = make _elem ( 'p' , [ 'text-center' ] , { textContent : "Set Bonuses" } ) ;
2021-01-10 21:01:59 +00:00
parent _div . append ( set _summary _elem ) ;
for ( const [ setName , count ] of build . activeSetCounts ) {
2022-06-19 20:44:02 +00:00
const active _set = sets . get ( setName ) ;
2021-02-04 10:55:15 +00:00
if ( active _set [ "hidden" ] ) { continue ; }
2022-07-17 02:43:13 +00:00
let set _elem = make _elem ( 'p' , [ ] , { id : "set-" + setName } ) ;
2021-01-10 21:01:59 +00:00
set _summary _elem . append ( set _elem ) ;
2021-02-04 10:55:15 +00:00
const bonus = active _set . bonuses [ count - 1 ] ;
2022-06-29 06:23:27 +00:00
let mock _item = new Map ( [ [ "fixID" , true ] ,
[ "displayName" , setName + " Set: " + count + "/" + sets . get ( setName ) . items . length ] ] ) ;
2021-01-10 21:01:59 +00:00
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 ) ;
}
}
2022-06-20 13:12:22 +00:00
function displayBuildStats ( parent _id , build , command _group , stats ) {
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.
2022-06-19 18:30:10 +00:00
let display _commands = command _group ;
2021-01-09 12:47:25 +00:00
let parent _div = document . getElementById ( parent _id ) ;
2022-06-19 18:30:10 +00:00
// Clear the parent div.
if ( parent _div != null ) {
setHTML ( parent _id , "" ) ;
2021-01-10 21:01:59 +00:00
}
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 ) {
2022-06-19 18:30:10 +00:00
// style instructions
2021-01-09 12:47:25 +00:00
if ( command . charAt ( 0 ) === "#" ) {
2022-06-19 18:30:10 +00:00
if ( command === "#defense-stats" ) {
2022-06-20 13:12:22 +00:00
displayDefenseStats ( parent _div , stats , true ) ;
2021-01-09 12:47:25 +00:00
}
}
2022-06-19 18:30:10 +00:00
if ( command . charAt ( 0 ) === "!" ) {
2021-01-09 12:47:25 +00:00
// TODO: This is sooo incredibly janky.....
if ( command === "!elemental" ) {
elemental _format = ! elemental _format ;
}
}
2022-06-19 18:30:10 +00:00
// id instruction
2021-01-09 12:47:25 +00:00
else {
let id = command ;
if ( stats . get ( id ) ) {
let style = null ;
2022-06-19 18:30:10 +00:00
// TODO: add pos and neg style
2021-01-09 12:47:25 +00:00
if ( ! staticIDs . includes ( id ) ) {
style = "positive" ;
if ( stats . get ( id ) < 0 ) {
style = "negative" ;
}
}
2022-06-19 18:30:10 +00:00
// ignore
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 ) {
2022-06-20 13:12:22 +00:00
id _val = Math . ceil ( id _val * stats . get ( "poisonPct" ) / 100 ) ;
2021-01-14 06:58:32 +00:00
}
2022-06-19 18:30:10 +00:00
displayFixedID ( parent _div , id , id _val , elemental _format , style ) ;
2021-01-11 07:05:23 +00:00
if ( id === "poison" && id _val > 0 ) {
2022-07-17 02:43:13 +00:00
let row = make _elem ( 'div' , [ 'row' ] ) ;
let value _elem = make _elem ( 'div' , [ 'col' , 'text-end' ] ) ;
let prefix _elem = make _elem ( 'b' , [ ] , { textContent : "\u279C With Strength: " } ) ;
let number _elem = make _elem ( 'b' , [ style ] , {
textContent : ( id _val * ( 1 + skillPointsToPercentage ( stats . get ( 'str' ) ) ) ) . 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 ) ;
2022-06-19 18:30:10 +00:00
parent _div . appendChild ( row ) ;
}
else if ( id === "ls" && id _val != 0 ) {
2022-07-17 02:43:13 +00:00
let row = make _elem ( 'div' , [ 'row' ] ) ;
let value _elem = make _elem ( 'div' , [ 'col' , 'text-end' ] ) ;
2022-06-19 18:30:10 +00:00
2022-07-17 03:06:01 +00:00
let prefix _elem = make _elem ( 'b' , [ ] , { textContent : "\u279C Effective LS: " } ) ;
2021-01-11 07:05:23 +00:00
2022-06-20 13:12:22 +00:00
let defStats = getDefenseStats ( stats ) ;
2022-07-18 07:34:29 +00:00
let number _elem = make _elem ( 'b' , [ style ] , {
2022-07-17 02:43:13 +00:00
textContent : Math . round ( defStats [ 1 ] [ 0 ] * id _val / defStats [ 0 ] ) + "/3s"
} ) ;
2022-06-19 18:30:10 +00:00
value _elem . append ( prefix _elem ) ;
value _elem . append ( number _elem ) ;
row . appendChild ( value _elem ) ;
parent _div . appendChild ( row ) ;
2021-01-11 07:05:23 +00:00
}
2022-06-19 18:30:10 +00:00
}
// sp thingy (WHY IS THIS HANDLED SEPARATELY TODO
else if ( skp _order . includes ( id ) ) {
2021-01-20 05:59:17 +00:00
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 ) {
2022-06-19 18:30:10 +00:00
displayFixedID ( parent _div , id , diff , false , style ) ;
2021-01-20 05:59:17 +00:00
}
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.
2022-06-26 07:08:02 +00:00
item = new Map ( item ) ; // shallow copy
2021-01-09 00:56:07 +00:00
if ( item . get ( "category" ) === "weapon" ) {
2022-06-24 10:35:03 +00:00
item . set ( 'basedps' , get _base _dps ( item ) ) ;
2021-01-30 08:50:25 +00:00
} else if ( item . get ( "category" ) === "armor" ) {
2021-01-09 00:56:07 +00:00
}
2022-06-19 18:30:10 +00:00
let display _commands = sq2 _item _display _commands ;
2021-01-07 22:44:52 +00:00
// Clear the parent div.
setHTML ( parent _id , "" ) ;
let parent _div = document . getElementById ( parent _id ) ;
2022-06-19 18:30:10 +00:00
parent _div . classList . add ( "border" , "border-2" , "border-dark" ) ;
2021-01-07 22:44:52 +00:00
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 ] ;
2022-06-19 18:30:10 +00:00
if ( command . charAt ( 0 ) === "!" ) {
2021-01-08 01:02:12 +00:00
// TODO: This is sooo incredibly janky.....
if ( command === "!elemental" ) {
elemental _format = ! elemental _format ;
2022-06-19 18:30:10 +00:00
}
else if ( command === "!spacer" ) {
2022-07-18 06:46:23 +00:00
let spacer = make _elem ( 'div' , [ "row" , "my-2" ] , { } ) ;
2022-06-19 18:30:10 +00:00
parent _div . appendChild ( spacer ) ;
continue ;
}
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-09-06 05:45:01 +00:00
if ( nonRolledIDs . includes ( id ) ) { //nonRolledID & non-0/non-null/non-und ID
if ( ! item . get ( id ) ) {
2022-07-18 06:46:23 +00:00
if ( ! ( item . get ( "crafted" ) && skp _order . includes ( id ) &&
2021-09-06 05:45:01 +00:00
( item . get ( "maxRolls" ) . get ( id ) || item . get ( "minRolls" ) . get ( id ) ) ) ) {
continue ;
}
}
2021-01-09 23:31:14 +00:00
if ( id === "slots" ) {
2022-07-18 06:46:23 +00:00
let p _elem = make _elem ( "div" , [ "col" ] ) ;
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
2022-07-18 07:34:29 +00:00
p _elem . appendChild ( make _elem ( "b" , [ ] , {
2022-07-18 06:46:23 +00:00
textContent : "Powder Slots: " + item . get ( id ) + " ["
2022-07-18 07:34:29 +00:00
} ) ) ;
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 ++ ) {
2022-07-18 07:34:29 +00:00
p _elem . appendChild ( make _elem ( "b" , [ damageClasses [ Math . floor ( powders [ i ] / 6 ) + 1 ] + "_powder" ] , {
textContent : numerals . get ( ( powders [ i ] % 6 ) + 1 ) + " "
} ) ) ;
2021-01-10 21:31:29 +00:00
}
2022-07-18 07:34:29 +00:00
p _elem . appendChild ( make _elem ( "b" , [ ] , { textContent : "]" } ) ) ;
2022-06-19 18:30:10 +00:00
parent _div . appendChild ( p _elem ) ;
2021-02-04 10:55:15 +00:00
} else if ( id === "set" ) {
if ( item . get ( "hideSet" ) ) { continue ; }
2022-07-18 07:34:29 +00:00
parent _div . appendChild ( make _elem ( "div" , [ "col" ] , { textContent : "Set: " + item . get ( id ) . toString ( ) } ) ) ;
2021-01-30 12:09:32 +00:00
} else if ( id === "majorIds" ) {
2022-06-19 18:30:10 +00:00
//console.log(item.get(id));
2021-07-19 21:31:02 +00:00
for ( let majorID of item . get ( id ) ) {
2022-07-18 06:46:23 +00:00
let p _elem = make _elem ( "div" , [ 'col' ] ) ;
2021-07-19 21:31:02 +00:00
2022-07-18 07:34:29 +00:00
let title _elem = make _elem ( "b" ) ;
let b _elem = make _elem ( "b" ) ;
2021-07-19 21:31:02 +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 ) ;
}
2022-06-19 18:30:10 +00:00
parent _div . appendChild ( p _elem ) ;
2021-03-27 18:17:58 +00:00
}
2021-03-14 07:55:08 +00:00
} else if ( id === "lvl" && item . get ( "tier" ) === "Crafted" ) {
2022-07-18 07:34:29 +00:00
parent _div . appendChild ( make _elem ( "div" , [ "col" ] , {
textContent : "Combat Level Min: " + item . get ( "lvlLow" ) + "-" + item . get ( id )
} ) ) ;
2021-09-25 18:57:57 +00:00
} else if ( id === "displayName" ) {
2022-07-18 07:34:29 +00:00
let row = make _elem ( "div" , [ "row" , "justify-content-center" ] ) ;
2022-06-19 18:30:10 +00:00
2022-07-18 07:34:29 +00:00
let nolink _row = make _elem ( "div" , [ "row" , "justify-content-center" ] ) ;
nolink _row . style . display = "none" ;
const tier _class = item . has ( "tier" ) ? item . get ( "tier" ) . replace ( " " , "" ) : "Normal" ;
let item _link ;
if ( item . get ( "custom" ) ) {
item _link = "../custom/#" + item . get ( "hash" ) ;
} else if ( item . get ( "crafted" ) ) {
a _item _link = "../crafter/#" + item . get ( "hash" ) ;
} else {
item _link = "../item/#" + item . get ( "displayName" ) ;
}
const item _name _elem = make _elem ( "a" , [ "col-auto" , "text-center" , "item-title" , "p-0" , tier _class ] , {
textContent : item . get ( 'displayName' )
} ) ;
nolink _row . appendChild ( item _name _elem . cloneNode ( true ) ) ;
item _name _elem . href = item _link ;
2022-07-19 03:43:25 +00:00
row . appendChild ( item _name _elem ) ;
2022-06-19 18:30:10 +00:00
/ *
FUNCTIONALITY FOR THIS FEATURE HAS SINCE BEEN REMOVED ( WITH SQ2 ) .
IF WE WANT TO USE IT IN THE FUTURE , I ' VE LEFT THE CODE TO ADD IT IN HERE
* /
//allow the plus minus element to toggle upon click: ➕ ➖
2022-06-19 20:44:02 +00:00
//let plusminus = document.createElement("div");
//plusminus.id = parent_div.id.split("-")[0] + "-pm";
//plusminus.classList.add("col", "plus_minus", "text_end");
//plusminus.style.flexGrow = 0;
//plusminus.textContent = "\u2795";
//row.appendChild(plusminus);
2022-06-19 18:30:10 +00:00
parent _div . appendChild ( row ) ;
parent _div . appendChild ( nolink _row ) ;
2021-09-25 18:57:57 +00:00
2022-07-18 07:34:29 +00:00
if ( item . has ( "type" ) ) {
2022-07-24 21:31:23 +00:00
let img = make _elem ( "div" , [ ] , {
2022-07-18 07:34:29 +00:00
alt : item . get ( "type" ) ,
2022-07-24 21:31:23 +00:00
style : "z-index: 1; position: relative; image-rendering: pixelated; width: 50%; height: 50%; background-position: " + itemBGPositions [ item . get ( "type" ) ] + ";"
2022-07-18 07:34:29 +00:00
} ) ;
2022-07-24 21:31:23 +00:00
if ( [ "potion" , "scroll" , "food" ] . includes ( item . get ( "type" ) ) ) {
img . style . backgroundImage = "url('../media/items/common.png')" ;
img . style . backgroundSize = "500% 100%" ;
} else {
img . style . backgroundImage = "url('../media/items/" + ( newIcons ? "new.png')" : "old.png')" ) ;
img . style . backgroundSize = "1200% 100%" ;
}
2022-07-18 07:34:29 +00:00
let container = make _elem ( "div" ) ;
2022-06-19 18:30:10 +00:00
2022-07-18 07:34:29 +00:00
let bckgrd = make _elem ( "div" , [ "col" , "px-0" , "d-flex" , "align-items-center" , "justify-content-center" , 'scaled-bckgrd' ] , { // , "no-collapse"
style : "border-radius: 50%;background-image: radial-gradient(closest-side, " + colorMap . get ( item . get ( "tier" ) ) + " 20%," + "hsl(0, 0%, 16%) 80%); margin-left: auto; margin-right: auto;"
} ) ;
2021-09-25 18:57:57 +00:00
bckgrd . appendChild ( img ) ;
2022-07-18 07:34:29 +00:00
container . appendChild ( bckgrd ) ;
parent _div . appendChild ( container ) ;
2021-09-25 18:57:57 +00:00
}
2021-01-19 17:32:27 +00:00
} else {
2022-06-26 07:08:02 +00:00
if ( id . endsWith ( 'Dam_' ) ) {
// TODO: kinda jank but replacing lists with txt at this step
let damages = item . get ( id ) ;
if ( item . get ( "tier" ) !== "Crafted" ) {
damages = damages . map ( x => Math . round ( x ) ) ;
item . set ( id , damages [ 0 ] + "-" + damages [ 1 ] ) ;
}
else {
damages = damages . map ( x => x . map ( y => Math . round ( y ) ) ) ;
item . set ( id , damages [ 0 ] [ 0 ] + "-" + damages [ 0 ] [ 1 ] + "\u279c" + damages [ 1 ] [ 0 ] + "-" + damages [ 1 ] [ 1 ] ) ;
}
}
2021-01-19 17:32:27 +00:00
let p _elem ;
2022-06-26 07:08:02 +00:00
// TODO: wtf is this if statement
2022-06-19 18:30:10 +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" && parent _div . nodeName === "table" ) ) { //skp warp
p _elem = displayFixedID ( parent _div , 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" ) {
2022-06-19 18:30:10 +00:00
p _elem = displayFixedID ( parent _div , id , item . get ( id + "Low" ) + "-" + item . get ( id ) , elemental _format ) ;
2021-09-25 18:57:57 +00:00
}
if ( id === "lore" ) {
2021-03-05 16:28:00 +00:00
p _elem . style = "font-style: italic" ;
2021-01-11 07:05:23 +00:00
} else if ( skp _order . includes ( id ) ) { //id = str, dex, int, def, or agi
2022-06-19 18:30:10 +00:00
if ( item . get ( "tier" ) !== "Crafted" ) {
2022-07-18 07:34:29 +00:00
row = make _elem ( "div" , [ "col" ] ) ;
2021-01-19 17:32:27 +00:00
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 ) ;
2022-06-19 18:30:10 +00:00
parent _div . appendChild ( row ) ;
} else if ( item . get ( "tier" ) === "Crafted" ) {
2021-09-25 18:57:57 +00:00
let row = displayRolledID ( item , id , elemental _format ) ;
2022-06-19 18:30:10 +00:00
parent _div . 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-09-06 05:45:01 +00:00
else if ( rolledIDs . includes ( id ) &&
( ( item . get ( "maxRolls" ) && item . get ( "maxRolls" ) . get ( id ) )
|| ( item . get ( "minRolls" ) && item . get ( "minRolls" ) . get ( 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 ) {
2022-06-19 18:30:10 +00:00
p _elem = document . createElement ( "div" ) ;
p _elem . classList . add ( "col" , "text-nowrap" ) ;
if ( id == "dex" ) {
console . log ( "dex activated at fix_id" )
}
displayFixedID ( p _elem , id , item . get ( "minRolls" ) . get ( id ) , elemental _format , style ) ;
parent _div . appendChild ( p _elem ) ;
2021-01-08 01:02:12 +00:00
}
else {
2021-09-25 18:57:57 +00:00
let row = displayRolledID ( item , id , elemental _format ) ;
2022-06-19 18:30:10 +00:00
parent _div . 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 ;-;
2022-06-26 08:07:43 +00:00
let nonConsumables = [ "relik" , "wand" , "bow" , "spear" , "dagger" , "chestplate" , "helmet" , "leggings" , "boots" ] ; //, "ring", "bracelet", "necklace"];
2021-01-19 17:32:27 +00:00
if ( nonConsumables . includes ( item . get ( "type" ) ) ) {
2022-06-19 18:30:10 +00:00
let powder _special = document . createElement ( "div" ) ;
powder _special . classList . add ( "col" ) ;
2021-01-19 17:32:27 +00:00
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" ] ] ) ;
2022-06-19 18:30:10 +00:00
let specialTitle = document . createElement ( "span" ) ;
let specialEffects = document . createElement ( "span" ) ;
addClasses ( specialTitle , [ damageClasses [ skp _elements . indexOf ( element ) + 1 ] ] ) ;
2021-01-19 17:32:27 +00:00
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-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" ) ;
2022-06-19 18:30:10 +00:00
effect . classList . add ( "m-0" ) ;
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-01-19 17:32:27 +00:00
powder _special . appendChild ( specialTitle ) ;
2021-02-03 17:47:48 +00:00
powder _special . appendChild ( specialEffects ) ;
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" ) {
2022-06-19 18:30:10 +00:00
let dura _elem = document . createElement ( "div" ) ;
dura _elem . classList . add ( "col" ) ;
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" ) ;
2022-06-19 18:30:10 +00:00
parent _div . 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 ;
}
2022-06-19 18:30:10 +00:00
parent _div . 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" ) !== " " ) {
2022-06-19 18:30:10 +00:00
let item _desc _elem = document . createElement ( "div" ) ;
item _desc _elem . classList . add ( "col" ) ;
2021-01-10 21:01:59 +00:00
item _desc _elem . classList . add ( item . get ( "tier" ) ) ;
2022-06-19 18:30:10 +00:00
if ( tome _types . includes ( item . get ( "type" ) ) ) {
tome _type _map = new Map ( [ [ "weaponTome" , "Weapon Tome" ] , [ "armorTome" , "Armor Tome" ] , [ "guildTome" , "Guild Tome" ] ] ) ;
item _desc _elem . textContent = item . get ( "tier" ) + " " + tome _type _map . get ( item . get ( "type" ) ) ;
} else {
item _desc _elem . textContent = item . get ( "tier" ) + " " + item . get ( "type" ) ;
}
parent _div . 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" ) ;
2022-06-19 18:30:10 +00:00
parent _div . append ( item _desc _elem ) ;
2021-04-17 09:54:44 +00:00
}
if ( item . get ( "category" ) === "weapon" ) {
let total _damages = item . get ( "basedps" ) ;
let base _dps _elem = document . createElement ( "p" ) ;
base _dps _elem . classList . add ( "left" ) ;
base _dps _elem . classList . add ( "itemp" ) ;
if ( item . get ( "tier" ) === "Crafted" ) {
2022-06-24 10:35:03 +00:00
let base _dps _min = total _damages [ 0 ] ;
let base _dps _max = total _damages [ 1 ] ;
2021-04-17 09:54:44 +00:00
2021-04-30 03:10:29 +00:00
base _dps _elem . textContent = "Base DPS: " + base _dps _min . toFixed ( 3 ) + "\u279c" + base _dps _max . toFixed ( 3 ) ;
2021-04-17 09:54:44 +00:00
}
else {
2022-06-24 10:35:03 +00:00
base _dps _elem . textContent = "Base DPS: " + ( total _damages ) ;
2021-04-17 09:54:44 +00:00
}
parent _div . appendChild ( document . createElement ( "p" ) ) ;
parent _div . appendChild ( base _dps _elem ) ;
2021-03-14 07:55:08 +00:00
}
2021-01-07 22:44:52 +00:00
}
2021-01-20 05:59:17 +00:00
2022-06-19 20:44:02 +00:00
/ *
* Displays stats about a recipe that are NOT displayed in the craft stats .
* Includes : mat name and amounts , ingred names in an "array" with ingred effectiveness
2021-01-20 05:59:17 +00:00
* /
function displayRecipeStats ( craft , parent _id ) {
let elem = document . getElementById ( parent _id ) ;
2022-06-19 20:44:02 +00:00
//local vars
2021-01-20 05:59:17 +00:00
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" ) ;
2022-06-19 20:44:02 +00:00
let title = document . createElement ( "div" ) ;
2022-07-12 05:10:55 +00:00
title . classList . add ( "col" , "box-title" , "fw-bold" , "justify-content-center" , "scaled-font" ) ;
2021-01-20 05:59:17 +00:00
title . textContent = "Recipe Stats" ;
2022-06-19 20:44:02 +00:00
elem . appendChild ( title ) ;
let mats = document . createElement ( "div" ) ;
2022-07-12 05:10:55 +00:00
mats . classList . add ( "col" ) ;
2021-01-20 05:59:17 +00:00
mats . textContent = "Crafting Materials: " ;
2022-06-19 20:44:02 +00:00
elem . appendChild ( mats ) ;
2021-01-20 05:59:17 +00:00
for ( let i = 0 ; i < 2 ; i ++ ) {
2021-03-14 07:55:08 +00:00
let tier = mat _tiers [ i ] ;
2022-07-12 05:10:55 +00:00
let col = document . createElement ( "div" ) ;
col . classList . add ( "col" , "ps-4" ) ;
let b = document . createElement ( "span" ) ;
2021-01-20 05:59:17 +00:00
let mat = recipe . get ( "materials" ) [ i ] ;
b . textContent = "- " + mat . get ( "amount" ) + "x " + mat . get ( "item" ) . split ( " " ) . slice ( 1 ) . join ( " " ) ;
2022-06-19 20:44:02 +00:00
b . classList . add ( "col" ) ;
2022-07-12 05:10:55 +00:00
col . appendChild ( b ) ;
2022-06-19 20:44:02 +00:00
2022-07-12 05:10:55 +00:00
let starsContainer = document . createElement ( "span" ) ;
let starsB = document . createElement ( "span" ) ;
starsB . classList . add ( "T1-bracket" , "px-0" ) ;
2022-06-19 20:44:02 +00:00
starsB . textContent = "[" ;
2022-07-12 05:10:55 +00:00
starsContainer . appendChild ( starsB ) ;
2021-01-20 05:59:17 +00:00
for ( let j = 0 ; j < 3 ; j ++ ) {
2022-07-12 05:10:55 +00:00
let star = document . createElement ( "span" ) ;
star . classList . add ( "px-0" ) ;
2021-01-20 05:59:17 +00:00
star . textContent = "\u272B" ;
if ( j < tier ) {
star . classList . add ( "T1" ) ;
} else {
star . classList . add ( "T0" ) ;
}
2022-07-12 05:10:55 +00:00
starsContainer . append ( star ) ;
2021-01-20 05:59:17 +00:00
}
2022-07-12 05:10:55 +00:00
let starsE = document . createElement ( "span" ) ;
starsE . classList . add ( "T1-bracket" , "px-0" ) ;
2021-01-20 05:59:17 +00:00
starsE . textContent = "]" ;
2022-07-12 05:10:55 +00:00
starsContainer . appendChild ( starsE ) ;
col . appendChild ( starsContainer ) ;
2022-06-19 20:44:02 +00:00
2022-07-12 05:10:55 +00:00
elem . appendChild ( col ) ;
2021-01-20 05:59:17 +00:00
}
2022-06-19 20:44:02 +00:00
let ingredTable = document . createElement ( "div" ) ;
2022-07-12 05:10:55 +00:00
ingredTable . classList . add ( "col" , "mt-2" ) ;
let ingredContainer = document . createElement ( "div" ) ;
ingredContainer . classList . add ( "row" , "row-cols-2" , "g-3" ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
let ingredCell = document . createElement ( "div" ) ;
ingredCell . classList . add ( "col" ) ;
let ingredTextContainer = document . createElement ( "div" ) ;
ingredTextContainer . classList . add ( "border" , "border-3" , "rounded" )
let ingredName = ingreds [ i ] ;
let ingred _text = document . createElement ( "p" ) ;
ingred _text . classList . add ( "mb-2" , "ps-2" ) ;
ingred _text . textContent = ingredName ;
ingredTextContainer . appendChild ( ingred _text ) ;
let eff _div = document . createElement ( "p" ) ;
eff _div . classList . add ( "mb-2" , "ps-2" ) ;
let e = effectiveness [ i ] ;
if ( e > 0 ) {
eff _div . classList . add ( "positive" ) ;
} else if ( e < 0 ) {
eff _div . classList . add ( "negative" ) ;
}
eff _div . textContent = "[" + e + "%]" ;
ingredTextContainer . appendChild ( eff _div ) ;
2022-06-19 20:44:02 +00:00
2022-07-12 05:10:55 +00:00
ingredCell . appendChild ( ingredTextContainer ) ;
2022-06-19 20:44:02 +00:00
2022-07-12 05:10:55 +00:00
ingredContainer . appendChild ( ingredCell ) ;
2021-01-20 05:59:17 +00:00
}
2022-07-12 05:10:55 +00:00
ingredTable . appendChild ( ingredContainer ) ;
2021-01-20 05:59:17 +00:00
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
}
2022-06-19 20:44:02 +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 = "" ;
2022-06-19 20:44:02 +00:00
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 ;
2022-06-19 20:44:02 +00:00
for ( const command of sq2 _ing _display _order ) {
if ( command . charAt ( 0 ) === "!" ) {
// TODO: This is sooo incredibly janky.....
if ( command === "!elemental" ) {
elemental _format = ! elemental _format ;
2021-01-18 20:23:37 +00:00
}
2022-06-19 20:44:02 +00:00
else if ( command === "!spacer" ) {
let spacer = document . createElement ( 'div' ) ;
spacer . classList . add ( "row" , "my-2" ) ;
parent _elem . appendChild ( spacer ) ;
continue ;
2021-01-18 20:23:37 +00:00
}
2022-06-19 20:44:02 +00:00
} else {
let div = document . createElement ( "div" ) ;
div . classList . add ( "row" ) ;
2021-03-04 13:48:10 +00:00
if ( command === "displayName" ) {
2022-06-19 20:44:02 +00:00
div . classList . add ( "box-title" ) ;
let title _elem = document . createElement ( "div" ) ;
title _elem . classList . add ( "col-auto" , "justify-content-center" , "pr-1" ) ;
2021-03-04 13:48:10 +00:00
title _elem . textContent = ingred . get ( "displayName" ) ;
2022-06-19 20:44:02 +00:00
div . appendChild ( title _elem ) ;
2021-01-18 20:23:37 +00:00
let tier = ingred . get ( "tier" ) ; //tier in [0,3]
let begin = document . createElement ( "b" ) ;
2022-06-19 20:44:02 +00:00
begin . classList . add ( "T" + tier + "-bracket" , "col-auto" , "px-0" ) ;
2021-01-18 20:23:37 +00:00
begin . textContent = "[" ;
2022-06-19 20:44:02 +00:00
div . appendChild ( begin ) ;
2021-01-18 20:23:37 +00:00
for ( let i = 0 ; i < 3 ; i ++ ) {
let tier _elem = document . createElement ( "b" ) ;
2022-06-19 20:44:02 +00:00
if ( i < tier ) {
tier _elem . classList . add ( "T" + tier ) ;
} else {
tier _elem . classList . add ( "T0" ) ;
}
tier _elem . classList . add ( "px-0" , "col-auto" ) ;
2021-01-18 20:23:37 +00:00
tier _elem . textContent = "\u272B" ;
2022-06-19 20:44:02 +00:00
div . appendChild ( tier _elem ) ;
2021-01-18 20:23:37 +00:00
}
let end = document . createElement ( "b" ) ;
2022-06-19 20:44:02 +00:00
end . classList . add ( "T" + tier + "-bracket" , "px-0" , "col-auto" ) ;
2021-01-18 20:23:37 +00:00
end . textContent = "]" ;
2022-06-19 20:44:02 +00:00
div . appendChild ( end ) ;
2021-01-18 20:23:37 +00:00
} else if ( command === "lvl" ) {
2022-06-19 20:44:02 +00:00
div . textContent = "Crafting Lvl Min: " + ingred . get ( "lvl" ) ;
2021-01-18 20:23:37 +00:00
} else if ( command === "posMods" ) {
for ( const [ key , value ] of ingred . get ( "posMods" ) ) {
2022-06-19 20:44:02 +00:00
let posModRow = document . createElement ( "div" ) ;
posModRow . classList . add ( "row" ) ;
2021-01-18 20:23:37 +00:00
if ( value != 0 ) {
2022-06-19 20:44:02 +00:00
let posMod = document . createElement ( "div" ) ;
posMod . classList . add ( "col-auto" ) ;
posMod . textContent = posModPrefixes [ key ] ;
posModRow . appendChild ( posMod ) ;
let val = document . createElement ( "div" ) ;
val . classList . add ( "col-auto" , "px-0" ) ;
2021-01-18 20:23:37 +00:00
val . textContent = value + posModSuffixes [ key ] ;
if ( value > 0 ) {
val . classList . add ( "positive" ) ;
} else {
val . classList . add ( "negative" ) ;
}
2022-06-19 20:44:02 +00:00
posModRow . appendChild ( val ) ;
div . appendChild ( posModRow ) ;
2021-01-18 20:23:37 +00:00
}
}
} else if ( command === "itemIDs" ) { //dura, reqs
for ( const [ key , value ] of ingred . get ( "itemIDs" ) ) {
2022-06-19 20:44:02 +00:00
let idRow = document . createElement ( "div" ) ;
idRow . classList . add ( "row" ) ;
2021-01-18 20:23:37 +00:00
if ( value != 0 ) {
2022-06-19 20:44:02 +00:00
let title = document . createElement ( "div" ) ;
title . classList . add ( "col-auto" ) ;
2021-01-18 20:23:37 +00:00
title . textContent = itemIDPrefixes [ key ] ;
2022-06-19 20:44:02 +00:00
idRow . appendChild ( title ) ;
2021-01-18 20:23:37 +00:00
}
2022-06-19 20:44:02 +00:00
let desc = document . createElement ( "div" ) ;
desc . classList . add ( "col-auto" ) ;
2021-01-18 20:23:37 +00:00
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 ) {
2022-06-19 20:44:02 +00:00
idRow . appendChild ( desc ) ;
2021-01-18 20:23:37 +00:00
}
2022-06-19 20:44:02 +00:00
div . appendChild ( idRow ) ;
2021-01-18 20:23:37 +00:00
}
} else if ( command === "consumableIDs" ) { //dura, charges
for ( const [ key , value ] of ingred . get ( "consumableIDs" ) ) {
2022-06-19 20:44:02 +00:00
let idRow = document . createElement ( "div" ) ;
idRow . classList . add ( "row" ) ;
2021-01-18 20:23:37 +00:00
if ( value != 0 ) {
2022-06-19 20:44:02 +00:00
let title = document . createElement ( "div" ) ;
title . classList . add ( "col-auto" ) ;
2021-01-18 20:23:37 +00:00
title . textContent = consumableIDPrefixes [ key ] ;
2022-06-19 20:44:02 +00:00
idRow . appendChild ( title ) ;
2021-01-18 20:23:37 +00:00
}
2022-06-19 20:44:02 +00:00
let desc = document . createElement ( "div" ) ;
desc . classList . add ( "col-auto" ) ;
2021-01-18 20:23:37 +00:00
if ( value > 0 ) {
desc . classList . add ( "positive" ) ;
desc . textContent = "+" + value ;
} else if ( value < 0 ) {
desc . classList . add ( "negative" ) ;
desc . textContent = value ;
}
if ( value != 0 ) {
2022-06-19 20:44:02 +00:00
idRow . appendChild ( desc ) ;
let suffix = document . createElement ( "div" ) ;
suffix . classList . add ( "col-auto" ) ;
2021-01-18 20:23:37 +00:00
suffix . textContent = consumableIDSuffixes [ key ] ;
2022-06-19 20:44:02 +00:00
idRow . appendChild ( suffix ) ;
2021-01-18 20:23:37 +00:00
}
2022-06-19 20:44:02 +00:00
div . appendChild ( idRow ) ;
2021-01-18 20:23:37 +00:00
}
} else if ( command === "skills" ) {
2022-06-19 20:44:02 +00:00
let row = document . createElement ( "div" ) ;
row . classList . add ( "row" ) ;
let title = document . createElement ( "div" ) ;
title . classList . add ( "row" ) ;
title . textContent = "Used in:" ;
row . appendChild ( title ) ;
2021-01-18 20:23:37 +00:00
for ( const skill of ingred . get ( "skills" ) ) {
2022-06-19 20:44:02 +00:00
let skill _div = document . createElement ( "div" ) ;
2022-07-12 05:10:55 +00:00
skill _div . classList . add ( "row" , "ps-4" ) ;
2022-06-19 20:44:02 +00:00
skill _div . textContent = skill . charAt ( 0 ) + skill . substring ( 1 ) . toLowerCase ( ) ;
row . appendChild ( skill _div ) ;
2021-01-18 20:23:37 +00:00
}
2022-06-19 20:44:02 +00:00
div . appendChild ( row ) ;
2021-01-18 20:23:37 +00:00
} 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 ) {
2022-06-19 20:44:02 +00:00
let row = displayRolledID ( ingred . get ( "ids" ) , key , elemental _format ) ;
row . classList . remove ( "col" ) ;
row . classList . remove ( "col-12" ) ;
div . appendChild ( row ) ;
2021-01-18 20:23:37 +00:00
}
}
} else { //this shouldn't be happening
}
2022-06-19 20:44:02 +00:00
parent _elem . appendChild ( div ) ;
2021-01-18 20:23:37 +00:00
}
}
2021-01-18 01:26:39 +00:00
}
2021-01-09 08:52:58 +00:00
2022-06-20 14:37:14 +00:00
function displayNextCosts ( _stats , spell , spellIdx ) {
let stats = new Map ( _stats ) ;
let intel = stats . get ( 'int' ) ;
2022-06-19 18:02:28 +00:00
let row = document . createElement ( "div" ) ;
row . classList . add ( "spellcost-tooltip" ) ;
let init _cost = document . createElement ( "b" ) ;
2022-06-20 14:37:14 +00:00
init _cost . textContent = getSpellCost ( stats , spellIdx , spell . cost ) ;
2022-06-19 18:02:28 +00:00
init _cost . classList . add ( "Mana" ) ;
let arrow = document . createElement ( "b" ) ;
arrow . textContent = "\u279C" ;
let next _cost = document . createElement ( "b" ) ;
2022-06-20 14:37:14 +00:00
next _cost . textContent = ( init _cost . textContent === "1" ? 1 : getSpellCost ( stats , spellIdx , spell . cost ) - 1 ) ;
2022-06-19 18:02:28 +00:00
next _cost . classList . add ( "Mana" ) ;
let int _needed = document . createElement ( "b" ) ;
if ( init _cost . textContent === "1" ) {
int _needed . textContent = ": n/a (+0)" ;
2022-07-22 17:27:59 +00:00
} else { //do math
2022-06-20 14:37:14 +00:00
let target = getSpellCost ( stats , spellIdx , spell . cost ) - 1 ;
let needed = intel ;
2022-06-19 18:02:28 +00:00
let noUpdate = false ;
//forgive me... I couldn't inverse ceil, floor, and max.
2022-06-20 14:37:14 +00:00
while ( getSpellCost ( stats , spellIdx , spell . cost ) > target ) {
2022-06-19 18:02:28 +00:00
if ( needed > 150 ) {
noUpdate = true ;
break ;
2021-01-15 20:36:12 +00:00
}
2022-06-19 18:02:28 +00:00
needed ++ ;
2022-06-20 14:37:14 +00:00
stats . set ( 'int' , stats . get ( 'int' ) + 1 ) ;
2022-06-19 18:02:28 +00:00
}
2022-06-20 14:37:14 +00:00
let missing = needed - intel ;
2022-06-19 18:02:28 +00:00
//in rare circumstances, the next spell cost can jump.
if ( noUpdate ) {
2022-06-20 14:37:14 +00:00
next _cost . textContent = ( init _cost . textContent === "1" ? 1 : getSpellCost ( stats , spellIdx , spell . cost ) - 1 ) ;
2022-06-19 18:02:28 +00:00
} else {
2022-06-20 14:37:14 +00:00
next _cost . textContent = ( init _cost . textContent === "1" ? 1 : getSpellCost ( stats , spellIdx , spell . cost ) ) ;
2021-01-15 18:49:24 +00:00
}
2022-06-19 18:02:28 +00:00
int _needed . textContent = ": " + ( needed > 150 ? ">150" : needed ) + " int (+" + ( needed > 150 ? "n/a" : missing ) + ")" ;
2021-01-15 18:20:17 +00:00
}
2022-06-19 18:02:28 +00:00
// row.appendChild(init_cost);
row . appendChild ( arrow ) ;
row . appendChild ( next _cost ) ;
row . appendChild ( int _needed ) ;
return row ;
2021-01-15 18:20:17 +00:00
}
2021-09-25 18:57:57 +00:00
function displayRolledID ( item , id , elemental _format ) {
2022-06-20 17:51:17 +00:00
let row = document . createElement ( 'div' ) ;
row . classList . add ( 'col' ) ;
let item _div = document . createElement ( 'div' ) ;
item _div . classList . add ( 'row' ) ;
let min _elem = document . createElement ( 'div' ) ;
min _elem . classList . add ( 'col' , 'text-start' ) ;
min _elem . style . cssText += "flex-grow: 0" ;
2021-09-25 18:57:57 +00:00
let id _min = item . get ( "minRolls" ) . get ( id )
let style = id _min < 0 ? "negative" : "positive" ;
if ( reversedIDs . includes ( id ) ) {
style === "positive" ? style = "negative" : style = "positive" ;
}
min _elem . classList . add ( style ) ;
min _elem . textContent = id _min + idSuffixes [ id ] ;
2022-06-20 17:51:17 +00:00
item _div . appendChild ( min _elem ) ;
2021-09-25 18:57:57 +00:00
2022-06-20 17:51:17 +00:00
let desc _elem = document . createElement ( 'div' ) ;
desc _elem . classList . add ( 'col' , 'text-center' ) ; //, 'text-nowrap');
desc _elem . style . cssText += "flex-grow: 1" ;
2021-09-25 18:57:57 +00:00
//TODO elemental format jank
if ( elemental _format ) {
apply _elemental _format ( desc _elem , id ) ;
}
else {
desc _elem . textContent = idPrefixes [ id ] ;
}
2022-06-20 17:51:17 +00:00
item _div . appendChild ( desc _elem ) ;
2021-09-25 18:57:57 +00:00
2022-06-20 17:51:17 +00:00
let max _elem = document . createElement ( 'div' ) ;
2021-09-25 18:57:57 +00:00
let id _max = item . get ( "maxRolls" ) . get ( id )
2022-06-20 17:51:17 +00:00
max _elem . classList . add ( 'col' , 'text-end' ) ;
max _elem . style . cssText += "flex-grow: 0" ;
2021-09-25 18:57:57 +00:00
style = id _max < 0 ? "negative" : "positive" ;
2022-06-20 17:51:17 +00:00
if ( reversedIDs . includes ( id ) ) {
2021-09-25 18:57:57 +00:00
style === "positive" ? style = "negative" : style = "positive" ;
}
max _elem . classList . add ( style ) ;
max _elem . textContent = id _max + idSuffixes [ id ] ;
2022-06-20 17:51:17 +00:00
item _div . appendChild ( max _elem ) ;
row . appendChild ( item _div ) ;
2021-09-25 18:57:57 +00:00
return row ;
}
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 ) {
2022-06-19 18:30:10 +00:00
let row = document . createElement ( 'div' ) ;
row . classList . add ( "row" ) ;
let desc _elem = document . createElement ( 'div' ) ;
desc _elem . classList . add ( 'col' ) ;
desc _elem . classList . add ( 'text-start' ) ;
2021-01-09 12:47:25 +00:00
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
2022-06-19 18:30:10 +00:00
let value _elem = document . createElement ( 'div' ) ;
value _elem . classList . add ( 'col' ) ;
value _elem . classList . add ( 'text-end' ) ;
2021-01-09 12:47:25 +00:00
value _elem . classList . add ( style ) ;
value _elem . textContent = value + idSuffixes [ id ] ;
row . appendChild ( value _elem ) ;
active . appendChild ( row ) ;
return row ;
}
else {
// HACK TO AVOID DISPLAYING ZERO DAMAGE! TODO
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 ;
}
2022-06-19 18:30:10 +00:00
let p _elem = document . createElement ( 'div' ) ;
p _elem . classList . add ( 'col' ) ;
2021-01-09 12:47:25 +00:00
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
}
2022-06-19 18:30:10 +00:00
function displayPoisonDamage ( overallparent _elem , build ) {
overallparent _elem . textContent = "" ;
2022-07-19 08:09:21 +00:00
if ( build . statMap . get ( 'poison' ) <= 0 ) {
overallparent _elem . style = "display: none" ;
return ;
}
overallparent _elem . style = "" ;
let container = make _elem ( 'div' , [ 'col' , 'pe-0' ] ) ;
let spell _summary = make _elem ( 'div' , [ "col" , "spell-display" , "dark-5" , "rounded" , "dark-shadow" , "py-2" , "border" , "border-dark" ] ) ;
2022-06-19 18:30:10 +00:00
//Title
2022-07-19 08:09:21 +00:00
let title _elemavg = make _elem ( "b" ) ;
title _elemavg . append ( make _elem ( 'span' , [ ] , { textContent : "Poison Stats" } ) ) ;
spell _summary . append ( title _elemavg ) ;
2022-06-19 18:30:10 +00:00
let poison _tick = Math . ceil ( build . statMap . get ( "poison" ) * ( 1 + skillPointsToPercentage ( build . total _skillpoints [ 0 ] ) ) * ( build . statMap . get ( "poisonPct" ) ) / 100 / 3 ) ;
2022-07-19 08:09:21 +00:00
let overallpoisonDamage = make _elem ( "p" ) ;
overallpoisonDamage . append (
make _elem ( "span" , [ ] , { textContent : "Poison Tick: " } ) ,
make _elem ( "span" , [ "Damage" ] , { textContent : Math . max ( poison _tick , 0 ) } )
) ;
spell _summary . append ( overallpoisonDamage ) ;
container . append ( spell _summary ) ;
overallparent _elem . append ( container ) ;
2022-06-19 18:30:10 +00:00
}
2022-06-19 20:44:02 +00:00
function displayEquipOrder ( parent _elem , buildOrder ) {
2021-01-10 21:01:59 +00:00
parent _elem . textContent = "" ;
const order = buildOrder . slice ( ) ;
2022-06-19 20:44:02 +00:00
let title _elem = document . createElement ( "b" ) ;
2021-01-10 21:01:59 +00:00
title _elem . textContent = "Equip order " ;
2022-06-19 20:44:02 +00:00
title _elem . classList . add ( "Normal" , "text-center" ) ;
2021-01-10 21:01:59 +00:00
parent _elem . append ( title _elem ) ;
for ( const item of order ) {
2022-06-19 20:44:02 +00:00
let p _elem = document . createElement ( "b" ) ;
2021-01-10 21:01:59 +00:00
p _elem . textContent = item . get ( "displayName" ) ;
parent _elem . append ( p _elem ) ;
}
}
2021-01-10 22:38:17 +00:00
2022-06-20 13:12:22 +00:00
function displayDefenseStats ( parent _elem , statMap , insertSummary ) {
let defenseStats = getDefenseStats ( statMap ) ;
2021-01-11 22:25:55 +00:00
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
2022-06-19 18:30:10 +00:00
// parent_elem.append(document.createElement("br"));
let statsTable = document . createElement ( "div" ) ;
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
2022-06-19 18:30:10 +00:00
let hpRow = document . createElement ( "div" ) ;
hpRow . classList . add ( 'row' ) ;
let hp = document . createElement ( "div" ) ;
hp . classList . add ( 'col' ) ;
2021-01-10 21:31:29 +00:00
hp . classList . add ( "Health" ) ;
2022-06-19 18:30:10 +00:00
hp . classList . add ( "text-start" ) ;
2021-01-11 22:25:55 +00:00
hp . textContent = "Total HP:" ;
2022-06-19 18:30:10 +00:00
let boost = document . createElement ( "div" ) ;
boost . classList . add ( 'col' ) ;
2021-01-10 21:31:29 +00:00
boost . textContent = stats [ 0 ] ;
2022-06-19 18:30:10 +00:00
boost . classList . add ( "text-end" ) ;
2021-01-10 21:31:29 +00:00
hpRow . appendChild ( hp ) ;
hpRow . append ( boost ) ;
2022-06-19 18:30:10 +00:00
if ( insertSummary ) {
parent _elem . appendChild ( hpRow ) ;
} else {
statsTable . appendChild ( hpRow ) ;
}
2021-01-11 22:25:55 +00:00
2021-01-10 21:01:59 +00:00
//EHP
2022-06-19 18:30:10 +00:00
let ehpRow = document . createElement ( "div" ) ;
ehpRow . classList . add ( "row" ) ;
let ehp = document . createElement ( "div" ) ;
ehp . classList . add ( "col" ) ;
ehp . classList . add ( "text-start" ) ;
2021-01-10 21:31:29 +00:00
ehp . textContent = "Effective HP:" ;
2022-06-19 18:30:10 +00:00
boost = document . createElement ( "div" ) ;
2021-01-11 00:46:30 +00:00
boost . textContent = stats [ 1 ] [ 0 ] ;
2022-06-19 18:30:10 +00:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-01-10 21:31:29 +00:00
ehpRow . appendChild ( ehp ) ;
ehpRow . append ( boost ) ;
2021-01-11 00:46:30 +00:00
2022-06-19 18:30:10 +00:00
if ( insertSummary ) {
parent _elem . appendChild ( ehpRow )
} else {
statsTable . append ( ehpRow ) ;
}
ehpRow = document . createElement ( "div" ) ;
ehpRow . classList . add ( "row" ) ;
ehp = document . createElement ( "div" ) ;
ehp . classList . add ( "col" ) ;
ehp . classList . add ( "text-start" ) ;
2021-01-11 00:46:30 +00:00
ehp . textContent = "Effective HP (no agi):" ;
2022-06-19 18:30:10 +00:00
boost = document . createElement ( "div" ) ;
2021-01-11 00:46:30 +00:00
boost . textContent = stats [ 1 ] [ 1 ] ;
2022-06-19 18:30:10 +00:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-01-11 00:46:30 +00:00
ehpRow . appendChild ( ehp ) ;
ehpRow . append ( boost ) ;
2022-06-19 20:59:16 +00:00
if ( insertSummary ) {
parent _elem . appendChild ( ehpRow )
} else {
statsTable . append ( ehpRow ) ;
}
2021-01-11 00:46:30 +00:00
2021-01-10 21:01:59 +00:00
//total HPR
2022-06-19 18:30:10 +00:00
let hprRow = document . createElement ( "div" ) ;
hprRow . classList . add ( "row" )
let hpr = document . createElement ( "div" ) ;
2021-01-10 21:31:29 +00:00
hpr . classList . add ( "Health" ) ;
2022-06-19 18:30:10 +00:00
hpr . classList . add ( "col" ) ;
hpr . classList . add ( "text-start" ) ;
2021-01-11 22:25:55 +00:00
hpr . textContent = "HP Regen (Total):" ;
2022-06-19 18:30:10 +00:00
boost = document . createElement ( "div" ) ;
2021-01-10 22:38:17 +00:00
boost . textContent = stats [ 2 ] ;
2022-06-19 18:30:10 +00:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-01-10 22:38:17 +00:00
2021-01-10 21:31:29 +00:00
hprRow . appendChild ( hpr ) ;
hprRow . appendChild ( boost ) ;
2022-06-19 18:30:10 +00:00
if ( insertSummary ) {
parent _elem . appendChild ( hprRow ) ;
} else {
statsTable . appendChild ( hprRow ) ;
}
2021-01-19 10:12:36 +00:00
//EHPR
2022-06-19 18:30:10 +00:00
let ehprRow = document . createElement ( "div" ) ;
ehprRow . classList . add ( "row" )
let ehpr = document . createElement ( "div" ) ;
ehpr . classList . add ( "col" ) ;
ehpr . classList . add ( "text-start" ) ;
2021-01-10 21:31:29 +00:00
ehpr . textContent = "Effective HP Regen:" ;
2022-06-19 18:30:10 +00:00
boost = document . createElement ( "div" ) ;
2021-01-11 00:46:30 +00:00
boost . textContent = stats [ 3 ] [ 0 ] ;
2022-06-19 18:30:10 +00:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-01-11 00:46:30 +00:00
ehprRow . appendChild ( ehpr ) ;
ehprRow . append ( boost ) ;
2022-06-19 20:59:16 +00:00
if ( insertSummary ) {
parent _elem . appendChild ( ehprRow ) ;
} else {
statsTable . appendChild ( 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 ++ ) {
2022-06-19 18:30:10 +00:00
let eledefElemRow = document . createElement ( "div" ) ;
eledefElemRow . classList . add ( "row" )
2021-01-10 21:31:29 +00:00
2022-06-19 18:30:10 +00:00
let eledef = document . createElement ( "div" ) ;
eledef . classList . add ( "col" ) ;
eledef . classList . add ( "text-start" ) ;
let eledefTitle = document . createElement ( "span" ) ;
2021-01-10 21:31:29 +00:00
eledefTitle . textContent = damageClasses [ i + 1 ] ;
eledefTitle . classList . add ( damageClasses [ i + 1 ] ) ;
2022-06-19 18:30:10 +00:00
let defense = document . createElement ( "span" ) ;
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
2022-06-19 18:30:10 +00:00
let boost = document . createElement ( "div" ) ;
2021-01-10 21:31:29 +00:00
boost . textContent = eledefs [ i ] ;
2021-03-10 18:58:24 +00:00
boost . classList . add ( eledefs [ i ] >= 0 ? "positive" : "negative" ) ;
2022-06-19 18:30:10 +00:00
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-03-27 18:17:58 +00:00
2022-06-22 05:39:10 +00:00
let defRaw = statMap . get ( skp _elements [ i ] + "Def" ) ;
let defPct = statMap . get ( skp _elements [ i ] + "DefPct" ) / 100 ;
2021-03-27 18:17:58 +00:00
if ( defRaw < 0 ) {
defPct >= 0 ? defPct = "- " + defPct : defPct = "+ " + defPct ;
} else {
defPct >= 0 ? defPct = "+ " + defPct : defPct = "- " + defPct ;
}
2021-01-11 01:42:09 +00:00
eledefElemRow . appendChild ( boost ) ;
2022-06-19 18:30:10 +00:00
if ( insertSummary ) {
parent _elem . appendChild ( eledefElemRow ) ;
} else {
statsTable . appendChild ( eledefElemRow ) ;
}
2021-01-10 21:01:59 +00:00
}
2021-01-11 22:25:55 +00:00
if ( ! insertSummary ) {
//skp
2022-06-19 18:30:10 +00:00
let defRow = document . createElement ( "div" ) ;
defRow . classList . add ( "row" ) ;
let defElem = document . createElement ( "div" ) ;
defElem . classList . add ( "col" ) ;
defElem . classList . add ( "text-start" ) ;
2021-01-11 22:25:55 +00:00
defElem . textContent = "Damage Absorbed %:" ;
2022-06-19 18:30:10 +00:00
boost = document . createElement ( "div" ) ;
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-01-11 22:25:55 +00:00
boost . textContent = stats [ 4 ] [ 0 ] + "%" ;
defRow . appendChild ( defElem ) ;
defRow . appendChild ( boost ) ;
statsTable . append ( defRow ) ;
2022-06-19 18:30:10 +00:00
let agiRow = document . createElement ( "div" ) ;
agiRow . classList . add ( "row" ) ;
let agiElem = document . createElement ( "div" ) ;
agiElem . classList . add ( "col" ) ;
agiElem . classList . add ( "text-start" ) ;
2021-01-11 22:25:55 +00:00
agiElem . textContent = "Dodge Chance %:" ;
2022-06-19 18:30:10 +00:00
boost = document . createElement ( "div" ) ;
boost . classList . add ( "col" ) ;
boost . classList . add ( "text-end" ) ;
2021-01-11 22:25:55 +00:00
boost . textContent = stats [ 4 ] [ 1 ] + "%" ;
agiRow . appendChild ( agiElem ) ;
agiRow . appendChild ( boost ) ;
statsTable . append ( agiRow ) ;
}
2021-01-10 21:31:29 +00:00
2022-06-19 18:30:10 +00:00
if ( ! insertSummary ) {
parent _elem . append ( statsTable ) ;
}
2021-01-09 23:30:05 +00:00
}
2021-03-27 18:17:58 +00:00
2022-06-20 17:51:17 +00:00
function displayPowderSpecials ( parent _elem , powderSpecials , stats , weapon , overall = false ) {
2022-07-19 08:09:21 +00:00
parent _elem . textContent = "" ;
if ( powderSpecials . length === 0 ) {
parent _elem . style = "display: none" ;
return ;
}
parent _elem . style = "" ;
2022-06-20 17:51:17 +00:00
const skillpoints = [
stats . get ( 'str' ) ,
stats . get ( 'dex' ) ,
stats . get ( 'int' ) ,
stats . get ( 'def' ) ,
stats . get ( 'agi' )
] ;
2022-07-19 08:09:21 +00:00
parent _elem . append ( make _elem ( "b" , [ ] , { textContent : "Powder Specials" } ) ) ;
2021-01-12 21:07:03 +00:00
let specials = powderSpecials . slice ( ) ;
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.
2022-07-19 08:09:21 +00:00
let powder _special = make _elem ( "p" , [ "pt-3" ] ) ;
2021-01-12 21:07:03 +00:00
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 ( damageClasses [ powderSpecialStats . indexOf ( special [ 0 ] ) + 1 ] ) ;
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" : "" ) ;
2022-06-20 17:51:17 +00:00
if ( ! overall || powderSpecialStats . indexOf ( special [ 0 ] ) == 2 || powderSpecialStats . indexOf ( special [ 0 ] ) == 3 || powderSpecialStats . indexOf ( special [ 0 ] ) == 4 ) {
for ( const [ key , value ] of effects ) {
let effect = document . createElement ( "p" ) ;
effect . textContent += key + ": " + value [ power - 1 ] + specialSuffixes . get ( key ) ;
if ( key === "Damage" ) {
effect . textContent += elementIcons [ powderSpecialStats . indexOf ( special [ 0 ] ) ] ;
}
if ( special [ 0 ] [ "weaponSpecialName" ] === "Wind Prison" && key === "Damage Boost" ) {
effect . textContent += " (only 1st hit)" ;
}
specialEffects . appendChild ( effect ) ;
2021-01-12 22:49:02 +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" ) ;
2022-06-20 17:51:17 +00:00
// specialDamage.classList.add("item-margin");
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 ] ;
2022-06-24 10:35:03 +00:00
let tmp _conv = [ ] ;
for ( let i in part . conversion ) {
2022-06-27 03:24:38 +00:00
tmp _conv . push ( part . conversion [ i ] * part . multiplier [ power - 1 ] / 100 ) ;
2022-06-24 10:35:03 +00:00
}
2022-06-27 03:24:38 +00:00
console . log ( tmp _conv ) ;
let _results = calculateSpellDamage ( stats , weapon , tmp _conv , false , true ) ;
2021-01-13 08:30:55 +00:00
2022-06-20 17:51:17 +00:00
let critChance = skillPointsToPercentage ( skillpoints [ 1 ] ) ;
2021-01-13 08:30:55 +00:00
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 ;
2022-06-20 17:51:17 +00:00
let averageWrap = document . createElement ( "p" ) ;
let averageLabel = document . createElement ( "span" ) ;
averageLabel . textContent = "Average: " ;
let averageLabelDmg = document . createElement ( "span" ) ;
averageLabelDmg . classList . add ( "Damage" ) ;
averageLabelDmg . textContent = averageDamage . toFixed ( 2 ) ;
2021-01-13 08:30:55 +00:00
2022-06-20 17:51:17 +00:00
averageWrap . appendChild ( averageLabel ) ;
averageWrap . appendChild ( averageLabelDmg ) ;
specialDamage . appendChild ( averageWrap ) ;
2021-01-12 22:49:02 +00:00
2022-06-20 17:51:17 +00:00
if ( ! overall ) {
let nonCritLabel = document . createElement ( "p" ) ;
nonCritLabel . textContent = "Non-Crit Average: " + nonCritAverage . toFixed ( 2 ) ;
nonCritLabel . classList . add ( "damageSubtitle" ) ;
nonCritLabel . classList . add ( "item-margin" ) ;
specialDamage . append ( nonCritLabel ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( results [ i ] [ 1 ] > 0 ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "damagep" ) ;
p . classList . add ( damageClasses [ i ] ) ;
p . textContent = results [ i ] [ 0 ] + "-" + results [ i ] [ 1 ] ;
specialDamage . append ( p ) ;
}
2021-01-13 08:30:55 +00:00
}
2022-06-20 17:51:17 +00:00
let normalDamage = document . createElement ( "p" ) ;
normalDamage . textContent = "Total: " + totalDamNormal [ 0 ] . toFixed ( 2 ) + "-" + totalDamNormal [ 1 ] . toFixed ( 2 ) ;
normalDamage . classList . add ( "itemp" ) ;
specialDamage . append ( normalDamage ) ;
let nonCritChanceLabel = document . createElement ( "p" ) ;
nonCritChanceLabel . textContent = "Non-Crit Chance: " + ( ( 1 - critChance ) * 100 ) . toFixed ( 2 ) + "%" ;
specialDamage . append ( nonCritChanceLabel ) ;
let critLabel = document . createElement ( "p" ) ;
critLabel . textContent = "Crit Average: " + critAverage . toFixed ( 2 ) ;
critLabel . classList . add ( "damageSubtitle" ) ;
critLabel . classList . add ( "item-margin" ) ;
specialDamage . append ( critLabel ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
if ( results [ i ] [ 1 ] > 0 ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "damagep" ) ;
p . classList . add ( damageClasses [ i ] ) ;
p . textContent = results [ i ] [ 2 ] + "-" + results [ i ] [ 3 ] ;
specialDamage . append ( p ) ;
}
2021-01-13 08:30:55 +00:00
}
2022-06-20 17:51:17 +00:00
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
2022-06-20 17:51:17 +00:00
let critChanceLabel = document . createElement ( "p" ) ;
critChanceLabel . textContent = "Crit Chance: " + ( critChance * 100 ) . toFixed ( 2 ) + "%" ;
specialDamage . append ( critChanceLabel ) ;
2021-01-13 08:30:55 +00:00
2022-06-20 17:51:17 +00:00
save _damages . push ( averageDamage ) ;
}
2021-01-13 08:30:55 +00:00
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
2022-06-29 06:23:27 +00:00
function getSpellCost ( stats , spell ) {
return Math . max ( 1 , getBaseSpellCost ( stats , spell ) ) ;
2022-06-20 14:37:14 +00:00
}
2022-06-29 06:23:27 +00:00
function getBaseSpellCost ( stats , spell ) {
2022-07-22 17:27:59 +00:00
let cost = spell . cost * ( 1 - skillPointsToPercentage ( stats . get ( 'int' ) ) * skillpoint _final _mult [ 2 ] ) ;
2022-06-29 06:23:27 +00:00
cost += stats . get ( "spRaw" + spell . base _spell ) ;
2022-07-22 17:27:59 +00:00
return cost * ( 1 + stats . get ( "spPct" + spell . base _spell ) / 100 ) ;
2022-06-20 14:37:14 +00:00
}
2022-07-23 12:19:32 +00:00
function displaySpellDamage ( parent _elem , _overallparent _elem , stats , spell , spellIdx , spell _results ) {
2022-06-19 18:02:28 +00:00
// TODO: remove spellIdx (just used to flag melee and cost)
// TODO: move cost calc out
2021-01-09 08:52:58 +00:00
parent _elem . textContent = "" ;
2022-07-19 07:33:05 +00:00
let title _elem = make _elem ( "p" ) ;
2021-01-10 21:01:59 +00:00
2022-07-23 12:19:32 +00:00
_overallparent _elem . textContent = "" ;
const overallparent _elem = make _elem ( "div" , [ 'col' ] )
2022-06-19 18:02:28 +00:00
let title _elemavg = document . createElement ( "b" ) ;
2021-01-10 21:31:29 +00:00
2022-06-27 06:42:00 +00:00
if ( 'cost' in spell ) {
2022-07-19 07:33:05 +00:00
let first = make _elem ( "span" , [ ] , { textContent : spell . name + " (" } ) ;
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
2022-07-22 17:27:59 +00:00
let second = make _elem ( "span" , [ "Mana" ] , { textContent : getSpellCost ( stats , spell ) . toFixed ( 2 ) } ) ;
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
2022-07-19 07:33:05 +00:00
let third = make _elem ( "span" , [ ] , { textContent : ")" } ) ; // " + getBaseSpellCost(stats, spellIdx, spell.cost) + " ]";
title _elem . appendChild ( third . cloneNode ( true ) ) ;
title _elemavg . appendChild ( third ) ;
2021-01-09 08:52:58 +00:00
}
else {
2022-06-27 06:42:00 +00:00
title _elem . textContent = spell . name ;
title _elemavg . textContent = spell . name ;
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 ) ;
2022-06-29 06:23:27 +00:00
// if ('cost' in spell) {
2022-07-22 17:27:59 +00:00
// overallparent_elem.append(displayNextCosts(stats, spell, spellIdx));
2022-06-29 06:23:27 +00:00
// }
2022-06-19 18:02:28 +00:00
2022-06-20 14:37:14 +00:00
let critChance = skillPointsToPercentage ( stats . get ( 'dex' ) ) ;
2021-01-09 08:52:58 +00:00
2022-07-19 07:33:05 +00:00
let part _divavg = make _elem ( "p" ) ;
2021-01-19 01:57:26 +00:00
overallparent _elem . append ( part _divavg ) ;
2022-07-20 07:35:20 +00:00
function add _summary ( text , val , fmt ) {
2022-07-19 07:33:05 +00:00
if ( typeof ( val ) === 'number' ) { val = val . toFixed ( 2 ) ; }
2022-07-20 07:35:20 +00:00
let summary _elem = make _elem ( "p" ) ;
summary _elem . append (
make _elem ( "span" , [ ] , { textContent : text } ) ,
make _elem ( "span" , [ fmt ] , { textContent : val } )
) ;
part _divavg . append ( summary _elem ) ;
2022-06-27 06:54:05 +00:00
}
2022-06-27 06:42:00 +00:00
for ( let i = 0 ; i < spell _results . length ; ++ i ) {
2022-06-28 05:16:23 +00:00
const spell _info = spell _results [ i ] ;
2021-01-30 12:03:40 +00:00
2022-07-19 07:33:05 +00:00
let part _div = make _elem ( "p" , [ "pt-3" ] ) ;
2021-01-09 08:52:58 +00:00
parent _elem . append ( part _div ) ;
2022-07-19 07:33:05 +00:00
part _div . append ( make _elem ( "p" , [ ] , { textContent : spell _info . name } ) ) ;
2021-01-10 21:01:59 +00:00
2022-06-28 05:16:23 +00:00
if ( spell _info . type === "damage" ) {
let totalDamNormal = spell _info . normal _total ;
let totalDamCrit = spell _info . crit _total ;
2022-06-27 06:42:00 +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
2022-07-19 07:33:05 +00:00
let averageLabel = make _elem ( "p" , [ ] , { textContent : "Average: " + averageDamage . toFixed ( 2 ) } ) ;
2022-06-19 18:02:28 +00:00
// averageLabel.classList.add("damageSubtitle");
2021-01-09 09:35:18 +00:00
part _div . append ( averageLabel ) ;
2021-01-09 08:52:58 +00:00
2022-06-28 05:16:23 +00:00
if ( spell _info . name === spell . display ) {
2022-07-19 07:33:05 +00:00
if ( spellIdx === 0 ) {
2022-07-20 18:59:29 +00:00
let display _attack _speeds = [ "Super Slow" , "Very Slow" , "Slow" , "Normal" , "Fast" , "Very Fast" , "Super Fast" ] ;
2022-07-19 07:33:05 +00:00
let adjAtkSpd = attackSpeeds . indexOf ( stats . get ( "atkSpd" ) ) + stats . get ( "atkTier" ) ;
if ( adjAtkSpd > 6 ) {
adjAtkSpd = 6 ;
} else if ( adjAtkSpd < 0 ) {
adjAtkSpd = 0 ;
}
2022-07-20 07:35:20 +00:00
add _summary ( "Average DPS: " , averageDamage * baseDamageMultiplier [ adjAtkSpd ] , "Damage" ) ;
2022-07-20 18:59:29 +00:00
add _summary ( "Attack Speed: " , display _attack _speeds [ adjAtkSpd ] , "Damage" ) ;
2022-07-20 07:35:20 +00:00
add _summary ( "Per Attack: " , averageDamage , "Damage" ) ;
2022-07-19 07:33:05 +00:00
}
else {
2022-07-20 07:35:20 +00:00
add _summary ( spell _info . name + ": " , averageDamage , "Damage" ) ;
2022-07-19 07:33:05 +00:00
}
2021-01-10 22:16:22 +00:00
}
2021-01-10 21:31:29 +00:00
2022-06-27 06:42:00 +00:00
function _damage _display ( label _text , average , dmg _min , dmg _max ) {
2021-07-27 10:04:12 +00:00
let label = document . createElement ( "p" ) ;
label . textContent = label _text + average . toFixed ( 2 ) ;
part _div . append ( label ) ;
for ( let i = 0 ; i < 6 ; i ++ ) {
2022-06-27 06:42:00 +00:00
if ( dmg _max [ i ] != 0 ) {
2021-07-27 10:04:12 +00:00
let p = document . createElement ( "p" ) ;
p . classList . add ( damageClasses [ i ] ) ;
2022-06-27 06:42:00 +00:00
p . textContent = dmg _min [ i ] . toFixed ( 2 ) + " \u2013 " + dmg _max [ i ] . toFixed ( 2 ) ;
2021-07-27 10:04:12 +00:00
part _div . append ( p ) ;
}
2021-01-09 08:52:58 +00:00
}
}
2022-06-28 05:16:23 +00:00
_damage _display ( "Non-Crit Average: " , nonCritAverage , spell _info . normal _min , spell _info . normal _max ) ;
_damage _display ( "Crit Average: " , critAverage , spell _info . crit _min , spell _info . crit _max ) ;
} else if ( spell _info . type === "heal" ) {
let heal _amount = spell _info . heal _amount ;
2021-01-09 11:56:10 +00:00
let healLabel = document . createElement ( "p" ) ;
healLabel . textContent = heal _amount ;
2022-06-19 18:02:28 +00:00
// healLabel.classList.add("damagep");
2021-01-09 11:56:10 +00:00
part _div . append ( healLabel ) ;
2022-06-28 05:16:23 +00:00
if ( spell _info . name === spell . display ) {
2022-07-20 07:35:20 +00:00
add _summary ( spell _info . name + ": " , heal _amount , "Set" ) ;
2021-01-10 22:16:22 +00:00
}
2021-01-09 08:52:58 +00:00
}
}
2022-06-19 18:43:02 +00:00
2022-06-29 06:23:27 +00:00
addClickableArrow ( overallparent _elem , parent _elem ) ;
2022-07-23 12:19:32 +00:00
_overallparent _elem . append ( overallparent _elem ) ;
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 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
2021-04-07 06:01:05 +00:00
* @ param { String } amp the level of corkian amplifier used . 0 means no amp , 1 means Corkian Amplifier I , etc . [ 0 , 3 ]
2021-03-24 22:49:17 +00:00
* /
2021-04-07 06:01:05 +00:00
function displayIDProbabilities ( parent _id , item , amp ) {
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 = "" ;
2021-04-07 06:01:05 +00:00
parent _elem . innerHTML = "" ;
2021-03-24 22:49:17 +00:00
let title _elem = document . createElement ( "p" ) ;
title _elem . textContent = "Identification Probabilities" ;
2021-04-07 06:01:05 +00:00
title _elem . id = "ID_PROB_TITLE" ;
2021-03-24 22:49:17 +00:00
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
2021-04-07 06:01:05 +00:00
let amp _row = document . createElement ( "p" ) ;
amp _row . id = "amp_row" ;
let amp _text = document . createElement ( "b" ) ;
amp _text . textContent = "Corkian Amplifier Used: "
amp _row . appendChild ( amp _text ) ;
let amp _1 = document . createElement ( "button" ) ;
amp _1 . id = "cork_amp_1" ;
amp _1 . textContent = "I" ;
amp _row . appendChild ( amp _1 ) ;
let amp _2 = document . createElement ( "button" ) ;
amp _2 . id = "cork_amp_2" ;
amp _2 . textContent = "II" ;
amp _row . appendChild ( amp _2 ) ;
let amp _3 = document . createElement ( "button" ) ;
amp _3 . id = "cork_amp_3" ;
amp _3 . textContent = "III" ;
amp _row . appendChild ( amp _3 ) ;
amp _1 . addEventListener ( "click" , ( event ) => { toggleAmps ( 1 ) } ) ;
amp _2 . addEventListener ( "click" , ( event ) => { toggleAmps ( 2 ) } ) ;
amp _3 . addEventListener ( "click" , ( event ) => { toggleAmps ( 3 ) } ) ;
parent _elem . appendChild ( amp _row ) ;
if ( amp != 0 ) { toggleButton ( "cork_amp_" + amp ) }
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 ) ) {
2022-07-17 03:49:06 +00:00
if ( ! item . get ( "maxRolls" ) . get ( id ) ) { continue ; }
2021-03-26 02:19:07 +00:00
let min = item . get ( "minRolls" ) . get ( id ) ;
let max = item . get ( "maxRolls" ) . get ( id ) ;
2021-04-07 06:01:05 +00:00
//Apply corkian amps
if ( val > 0 ) {
let base = itemMap . get ( item _name ) [ id ] ;
if ( reversedIDs . includes ( id ) ) { max = Math . max ( Math . round ( ( 0.3 + 0.05 * amp ) * base ) , 1 ) }
else { min = Math . max ( Math . round ( ( 0.3 + 0.05 * amp ) * base ) , 1 ) }
}
2021-03-26 02:19:07 +00:00
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 ) ;
2021-04-07 06:01:05 +00:00
stringPDF ( id , max , val , amp ) ; //val is base roll
stringCDF ( id , max , val , amp ) ; //val is base roll
2021-03-26 02:19:07 +00:00
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 }
2021-04-07 06:01:05 +00:00
stringPDF ( id _name , - 1 * event . target . value , val , amp ) ; //val is base roll
stringCDF ( id _name , - 1 * event . target . value , val , amp ) ; //val is base roll
2021-03-26 02:19:07 +00:00
} else {
if ( event . target . value < min ) { event . target . value = min }
if ( event . target . value > max ) { event . target . value = max }
2021-04-07 06:01:05 +00:00
stringPDF ( id _name , 1 * event . target . value , val , amp ) ; //val is base roll
stringCDF ( id _name , 1 * event . target . value , val , amp ) ; //val is base roll
2021-03-26 02:19:07 +00:00
}
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 ;
}
2021-04-07 06:01:05 +00:00
stringPDF ( id _name , 1 * event . target . value , val , amp ) ;
stringCDF ( id _name , 1 * event . target . value , val , amp ) ;
2021-03-26 02:19:07 +00:00
} ) ;
}
}
}
//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
2021-04-07 06:01:05 +00:00
function stringPDF ( id , val , base , amp ) {
2021-03-26 02:19:07 +00:00
/ * * [ 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 ) {
2021-04-07 06:01:05 +00:00
minr = 0.3 + 0.05 * amp ; maxr = 1.3 ;
2021-03-26 02:19:07 +00:00
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 ) ) ;
}
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 ) ;
}
2022-06-19 20:44:02 +00:00
2021-04-07 06:01:05 +00:00
function stringCDF ( id , val , base , amp ) {
2021-03-26 02:19:07 +00:00
let p ; let min ; let max ; let minr ; let maxr ; let minround ; let maxround ;
if ( base > 0 ) {
2021-04-07 06:01:05 +00:00
minr = 0.3 + 0.05 * amp ; maxr = 1.3 ;
2021-03-26 02:19:07 +00:00
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 ) ) ;
}
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 ) ;
2021-03-25 08:38:52 +00:00
}
2022-06-23 09:51:51 +00:00
2022-06-29 06:23:27 +00:00
function addClickableArrow ( elem , target ) {
2022-06-23 09:51:51 +00:00
//up and down arrow - done ugly
2022-07-19 07:39:01 +00:00
let arrow = make _elem ( "img" , [ ] , { id : "arrow_" + elem . id , src : "../media/icons/" + ( newIcons ? "new" : "old" ) + "/toggle_down.png" } ) ;
2022-06-23 09:51:51 +00:00
arrow . style . maxWidth = document . body . clientWidth > 900 ? "3rem" : "10rem" ;
2022-07-20 17:25:32 +00:00
elem . appendChild ( arrow ) ;
elem . addEventListener ( "click" , ( ) => toggle _spell _tab ( arrow , target ) ) ;
2022-06-29 06:23:27 +00:00
}
// toggle arrow thinger
function toggle _spell _tab ( arrow _img , target ) {
if ( target . style . display == "none" ) {
target . style . display = "" ;
arrow _img . src = arrow _img . src . replace ( "down" , "up" ) ;
} else {
target . style . display = "none" ;
arrow _img . src = arrow _img . src . replace ( "up" , "down" ) ;
}
2022-06-23 09:51:51 +00:00
}