2021-01-07 10:23:54 +00:00
const url _base = location . href . split ( "#" ) [ 0 ] ;
const url _tag = location . hash . slice ( 1 ) ;
console . log ( url _base ) ;
console . log ( url _tag ) ;
2021-01-07 00:36:11 +00:00
2021-01-19 20:31:49 +00:00
const BUILD _VERSION = "6.9.7" ;
2021-01-07 10:30:23 +00:00
2021-01-12 23:14:12 +00:00
function setTitle ( ) {
2021-01-20 06:22:55 +00:00
let text ;
if ( url _base . includes ( "hppeng-wynn" ) ) {
text = "WynnBuilder UNSTABLE version " + BUILD _VERSION + " (db version " + DB _VERSION + ")" ;
}
else {
text = "WynnBuilder version " + BUILD _VERSION + " (db version " + DB _VERSION + ")" ;
document . getElementById ( "header" ) . classList . add ( "funnynumber" ) ;
}
document . getElementById ( "header" ) . textContent = text ;
2021-01-12 23:14:12 +00:00
}
setTitle ( ) ;
2021-01-07 10:30:23 +00:00
2021-01-07 00:04:16 +00:00
let player _build ;
2021-01-06 22:51:02 +00:00
// Set up item lists for quick access later.
2021-01-06 12:48:41 +00:00
let armorTypes = [ "helmet" , "chestplate" , "leggings" , "boots" ] ;
let accessoryTypes = [ "ring" , "bracelet" , "necklace" ] ;
let weaponTypes = [ "wand" , "spear" , "bow" , "dagger" , "relik" ] ;
2021-01-09 03:53:57 +00:00
// THIS IS SUPER DANGEROUS, WE SHOULD NOT BE KEEPING THIS IN SO MANY PLACES
2021-01-09 11:15:28 +00:00
let item _fields = [ "name" , "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" , "hprPct" , "mr" , "sdPct" , "mdPct" , "ls" , "ms" , "xpb" , "lb" , "ref" , "str" , "dex" , "int" , "agi" , "def" , "thorns" , "expd" , "spd" , "atkTier" , "poison" , "hpBonus" , "spRegen" , "eSteal" , "hprRaw" , "sdRaw" , "mdRaw" , "fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" , "fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" , "fixID" , "category" , "spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" , "rainbowRaw" , "sprint" , "sprintReg" , "jh" , "lq" , "gXp" , "gSpd" , "id" ] ;
2021-01-18 14:18:14 +00:00
let editable _item _fields = [ "sdPct" , "sdRaw" , "mdPct" , "mdRaw" , "poison" , "fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" , "fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" , "hprRaw" , "hprPct" , "hpBonus" , "atkTier" , "spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" ] ;
2021-01-09 08:52:58 +00:00
2021-01-19 11:56:09 +00:00
let editable _elems = [ ] ;
for ( let i of editable _item _fields ) {
let elem = document . getElementById ( i ) ;
elem . addEventListener ( "change" , ( event ) => {
elem . classList . add ( "highlight" ) ;
} ) ;
editable _elems . push ( elem ) ;
}
for ( let i of skp _order ) {
let elem = document . getElementById ( i + "-skp" ) ;
elem . addEventListener ( "change" , ( event ) => {
elem . classList . add ( "highlight" ) ;
} ) ;
editable _elems . push ( elem ) ;
}
function clear _highlights ( ) {
for ( let i of editable _elems ) {
i . classList . remove ( "highlight" ) ;
}
}
2021-01-18 20:23:37 +00:00
2021-01-08 20:17:37 +00:00
2021-01-09 03:53:57 +00:00
let equipment _fields = [
"helmet" ,
"chestplate" ,
"leggings" ,
"boots" ,
"ring1" ,
"ring2" ,
"bracelet" ,
"necklace" ,
"weapon"
] ;
let equipment _names = [
"Helmet" ,
"Chestplate" ,
"Leggings" ,
"Boots" ,
"Ring 1" ,
"Ring 2" ,
"Bracelet" ,
"Necklace" ,
"Weapon"
] ;
let equipmentInputs = equipment _fields . map ( x => x + "-choice" ) ;
let buildFields = equipment _fields . map ( x => "build-" + x ) ;
2021-01-08 20:17:37 +00:00
let powderInputs = [
"helmet-powder" ,
"chestplate-powder" ,
"leggings-powder" ,
"boots-powder" ,
"weapon-powder" ,
] ;
2021-01-11 06:49:52 +00:00
2021-01-06 12:48:41 +00:00
let itemTypes = armorTypes . concat ( accessoryTypes ) . concat ( weaponTypes ) ;
let itemLists = new Map ( ) ;
for ( const it of itemTypes ) {
itemLists . set ( it , [ ] ) ;
}
let itemMap = new Map ( ) ;
2021-01-10 03:40:15 +00:00
/* Mapping from item names to set names. */
2021-01-07 10:23:54 +00:00
let idMap = new Map ( ) ;
2021-01-06 12:48:41 +00:00
2021-01-06 22:51:02 +00:00
/ *
* Function that takes an item list and populates its corresponding dropdown .
* Used for armors and bracelet / necklace .
* /
2021-01-06 12:48:41 +00:00
function populateItemList ( type ) {
let item _list = document . getElementById ( type + "-items" ) ;
for ( const item of itemLists . get ( type ) ) {
let el = document . createElement ( "option" ) ;
el . value = item ;
item _list . appendChild ( el ) ;
}
}
2021-01-06 22:51:02 +00:00
/ *
* Populate dropdowns , add listeners , etc .
* /
2021-01-06 12:48:41 +00:00
function init ( ) {
2021-01-06 22:46:00 +00:00
let noneItems = [
2021-01-08 04:31:29 +00:00
[ "armor" , "helmet" , "No Helmet" ] ,
[ "armor" , "chestplate" , "No Chestplate" ] ,
[ "armor" , "leggings" , "No Leggings" ] ,
[ "armor" , "boots" , "No Boots" ] ,
[ "accessory" , "ring" , "No Ring 1" ] ,
[ "accessory" , "ring" , "No Ring 2" ] ,
[ "accessory" , "bracelet" , "No Bracelet" ] ,
[ "accessory" , "necklace" , "No Necklace" ] ,
2021-01-10 10:02:23 +00:00
[ "weapon" , "dagger" , "No Weapon" ] ,
2021-01-07 06:41:41 +00:00
] ;
for ( let i = 0 ; i < 9 ; i ++ ) {
let item = Object ( ) ;
2021-01-10 12:20:59 +00:00
item . slots = 0 ;
2021-01-08 04:31:29 +00:00
item . category = noneItems [ i ] [ 0 ] ;
item . type = noneItems [ i ] [ 1 ] ;
item . name = noneItems [ i ] [ 2 ] ;
2021-01-07 06:41:41 +00:00
item . displayName = item . name ;
item . set = null ;
item . quest = null ;
item . skillpoints = [ 0 , 0 , 0 , 0 , 0 ] ;
item . has _negstat = false ;
item . reqs = [ 0 , 0 , 0 , 0 , 0 ] ;
2021-01-08 01:16:06 +00:00
item . fixID = true ;
item . tier = " " ; //do not get rid of this @hpp
2021-01-07 10:23:54 +00:00
item . id = 10000 + i ;
2021-01-08 20:17:37 +00:00
item . nDam = "0-0" ;
item . eDam = "0-0" ;
item . tDam = "0-0" ;
item . wDam = "0-0" ;
item . fDam = "0-0" ;
item . aDam = "0-0" ;
2021-01-07 06:41:41 +00:00
noneItems [ i ] = item ;
}
2021-01-06 23:31:35 +00:00
items = items . concat ( noneItems ) ;
2021-01-06 12:48:41 +00:00
console . log ( items ) ;
for ( const item of items ) {
2021-01-06 22:51:02 +00:00
itemLists . get ( item . type ) . push ( item . displayName ) ;
itemMap . set ( item . displayName , item ) ;
2021-01-11 01:42:09 +00:00
if ( noneItems . includes ( item ) ) {
idMap . set ( item . id , "" ) ;
}
else {
idMap . set ( item . id , item . displayName ) ;
}
2021-01-06 12:48:41 +00:00
}
for ( const armorType of armorTypes ) {
populateItemList ( armorType ) ;
2021-01-06 22:51:02 +00:00
// Add change listener to update armor slots.
2021-01-06 12:48:41 +00:00
document . getElementById ( armorType + "-choice" ) . addEventListener ( "change" , ( event ) => {
let item = itemMap . get ( event . target . value ) ;
if ( item !== undefined ) {
document . getElementById ( armorType + "-slots" ) . textContent = item . slots + " slots" ;
}
else {
document . getElementById ( armorType + "-slots" ) . textContent = "X slots" ;
}
} ) ;
}
let ring1 _list = document . getElementById ( "ring1-items" ) ;
let ring2 _list = document . getElementById ( "ring2-items" ) ;
for ( const ring of itemLists . get ( "ring" ) ) {
let el1 = document . createElement ( "option" ) ;
let el2 = document . createElement ( "option" ) ;
el1 . value = ring ;
el2 . value = ring ;
ring1 _list . appendChild ( el1 ) ;
ring2 _list . appendChild ( el2 ) ;
}
populateItemList ( "bracelet" ) ;
populateItemList ( "necklace" ) ;
let weapon _list = document . getElementById ( "weapon-items" ) ;
for ( const weaponType of weaponTypes ) {
for ( const weapon of itemLists . get ( weaponType ) ) {
let el = document . createElement ( "option" ) ;
el . value = weapon ;
weapon _list . appendChild ( el ) ;
}
}
2021-01-06 22:51:02 +00:00
// Add change listener to update weapon slots.
2021-01-06 12:48:41 +00:00
document . getElementById ( "weapon-choice" ) . addEventListener ( "change" , ( event ) => {
let item = itemMap . get ( event . target . value ) ;
if ( item !== undefined ) {
document . getElementById ( "weapon-slots" ) . textContent = item . slots + " slots" ;
}
2021-01-18 01:26:39 +00:00
else {
2021-01-06 12:48:41 +00:00
document . getElementById ( "weapon-slots" ) . textContent = "X slots" ;
}
} ) ;
2021-01-07 10:23:54 +00:00
2021-01-11 12:09:58 +00:00
decodeBuild ( url _tag ) ;
2021-01-07 10:23:54 +00:00
}
/ *
* Populate fields based on url , and calculate build .
* /
2021-01-11 12:09:58 +00:00
function decodeBuild ( url _tag ) {
2021-01-07 10:23:54 +00:00
if ( url _tag ) {
2021-01-09 03:53:57 +00:00
let equipment = [ null , null , null , null , null , null , null , null , null ] ;
2021-01-08 20:17:37 +00:00
let powdering = [ "" , "" , "" , "" , "" ] ;
2021-01-07 10:30:23 +00:00
let info = url _tag . split ( "_" ) ;
2021-01-07 10:23:54 +00:00
let version = info [ 0 ] ;
2021-01-09 08:52:58 +00:00
let save _skp = false ;
let skillpoints = [ 0 , 0 , 0 , 0 , 0 ] ;
2021-01-11 00:08:14 +00:00
let level = 106 ;
if ( version === "0" || version === "1" || version === "2" || version === "3" ) {
2021-01-07 10:23:54 +00:00
let equipments = info [ 1 ] ;
2021-01-09 03:53:57 +00:00
for ( let i = 0 ; i < 9 ; ++ i ) {
equipment [ i ] = idMap . get ( Base64 . toInt ( equipments . slice ( i * 3 , i * 3 + 3 ) ) ) ;
}
2021-01-07 10:23:54 +00:00
}
2021-01-08 20:17:37 +00:00
if ( version === "1" ) {
let powder _info = info [ 1 ] . slice ( 27 ) ;
console . log ( powder _info ) ;
2021-01-11 00:08:14 +00:00
// TODO: Make this run in linear instead of quadratic time... ew
2021-01-08 20:17:37 +00:00
for ( let i = 0 ; i < 5 ; ++ i ) {
let powders = "" ;
let n _blocks = Base64 . toInt ( powder _info . charAt ( 0 ) ) ;
console . log ( n _blocks + " blocks" ) ;
powder _info = powder _info . slice ( 1 ) ;
for ( let j = 0 ; j < n _blocks ; ++ j ) {
let block = powder _info . slice ( 0 , 5 ) ;
console . log ( block ) ;
let six _powders = Base64 . toInt ( block ) ;
for ( let k = 0 ; k < 6 && six _powders != 0 ; ++ k ) {
powders += powderNames . get ( ( six _powders & 0x1f ) - 1 ) ;
six _powders >>>= 5 ;
}
powder _info = powder _info . slice ( 5 ) ;
}
powdering [ i ] = powders ;
}
}
2021-01-09 08:52:58 +00:00
if ( version === "2" ) {
save _skp = true ;
let skillpoint _info = info [ 1 ] . slice ( 27 , 37 ) ;
for ( let i = 0 ; i < 5 ; ++ i ) {
2021-01-09 09:09:47 +00:00
skillpoints [ i ] = Base64 . toIntSigned ( skillpoint _info . slice ( i * 2 , i * 2 + 2 ) ) ;
2021-01-09 08:52:58 +00:00
}
let powder _info = info [ 1 ] . slice ( 37 ) ;
console . log ( powder _info ) ;
// TODO: Make this run in linear instead of quadratic time...
for ( let i = 0 ; i < 5 ; ++ i ) {
let powders = "" ;
let n _blocks = Base64 . toInt ( powder _info . charAt ( 0 ) ) ;
console . log ( n _blocks + " blocks" ) ;
powder _info = powder _info . slice ( 1 ) ;
for ( let j = 0 ; j < n _blocks ; ++ j ) {
let block = powder _info . slice ( 0 , 5 ) ;
console . log ( block ) ;
let six _powders = Base64 . toInt ( block ) ;
for ( let k = 0 ; k < 6 && six _powders != 0 ; ++ k ) {
powders += powderNames . get ( ( six _powders & 0x1f ) - 1 ) ;
six _powders >>>= 5 ;
}
powder _info = powder _info . slice ( 5 ) ;
}
powdering [ i ] = powders ;
}
}
2021-01-11 00:08:14 +00:00
if ( version === "3" ) {
level = Base64 . toInt ( info [ 1 ] . slice ( 37 , 39 ) ) ;
setValue ( "level-choice" , level ) ;
save _skp = true ;
let skillpoint _info = info [ 1 ] . slice ( 27 , 37 ) ;
for ( let i = 0 ; i < 5 ; ++ i ) {
skillpoints [ i ] = Base64 . toIntSigned ( skillpoint _info . slice ( i * 2 , i * 2 + 2 ) ) ;
}
2021-01-07 10:23:54 +00:00
2021-01-11 00:08:14 +00:00
let powder _info = info [ 1 ] . slice ( 39 ) ;
// TODO: Make this run in linear instead of quadratic time...
for ( let i = 0 ; i < 5 ; ++ i ) {
let powders = "" ;
let n _blocks = Base64 . toInt ( powder _info . charAt ( 0 ) ) ;
powder _info = powder _info . slice ( 1 ) ;
for ( let j = 0 ; j < n _blocks ; ++ j ) {
let block = powder _info . slice ( 0 , 5 ) ;
console . log ( block ) ;
let six _powders = Base64 . toInt ( block ) ;
for ( let k = 0 ; k < 6 && six _powders != 0 ; ++ k ) {
powders += powderNames . get ( ( six _powders & 0x1f ) - 1 ) ;
six _powders >>>= 5 ;
}
powder _info = powder _info . slice ( 5 ) ;
}
powdering [ i ] = powders ;
}
}
2021-01-09 03:53:57 +00:00
for ( let i in powderInputs ) {
setValue ( powderInputs [ i ] , powdering [ i ] ) ;
}
for ( let i in equipment ) {
setValue ( equipmentInputs [ i ] , equipment [ i ] ) ;
}
2021-01-09 08:52:58 +00:00
calculateBuild ( save _skp , skillpoints ) ;
2021-01-07 10:23:54 +00:00
}
}
2021-01-12 07:11:20 +00:00
/ * S t o r e s t h e e n t i r e b u i l d i n a s t r i n g u s i n g B 6 4 e n c r y p t i o n a n d a d d s i t t o t h e U R L .
* /
2021-01-07 10:23:54 +00:00
function encodeBuild ( ) {
if ( player _build ) {
2021-01-11 00:08:14 +00:00
let build _string = "3_" + Base64 . fromIntN ( player _build . helmet . get ( "id" ) , 3 ) +
2021-01-09 00:56:07 +00:00
Base64 . fromIntN ( player _build . chestplate . get ( "id" ) , 3 ) +
Base64 . fromIntN ( player _build . leggings . get ( "id" ) , 3 ) +
Base64 . fromIntN ( player _build . boots . get ( "id" ) , 3 ) +
Base64 . fromIntN ( player _build . ring1 . get ( "id" ) , 3 ) +
Base64 . fromIntN ( player _build . ring2 . get ( "id" ) , 3 ) +
Base64 . fromIntN ( player _build . bracelet . get ( "id" ) , 3 ) +
Base64 . fromIntN ( player _build . necklace . get ( "id" ) , 3 ) +
Base64 . fromIntN ( player _build . weapon . get ( "id" ) , 3 ) ;
2021-01-07 10:23:54 +00:00
2021-01-09 08:52:58 +00:00
for ( const skp of skp _order ) {
2021-01-09 09:09:47 +00:00
build _string += Base64 . fromIntN ( getValue ( skp + "-skp" ) , 2 ) ; // Maximum skillpoints: 2048
2021-01-09 08:52:58 +00:00
}
2021-01-11 00:08:14 +00:00
build _string += Base64 . fromIntN ( player _build . level , 2 ) ;
2021-01-08 20:17:37 +00:00
for ( const _powderset of player _build . powders ) {
let n _bits = Math . ceil ( _powderset . length / 6 ) ;
build _string += Base64 . fromIntN ( n _bits , 1 ) ; // Hard cap of 378 powders.
// Slice copy.
let powderset = _powderset . slice ( ) ;
while ( powderset . length != 0 ) {
let firstSix = powderset . slice ( 0 , 6 ) . reverse ( ) ;
let powder _hash = 0 ;
for ( const powder of firstSix ) {
powder _hash = ( powder _hash << 5 ) + 1 + powder ; // LSB will be extracted first.
}
build _string += Base64 . fromIntN ( powder _hash , 5 ) ;
powderset = powderset . slice ( 6 ) ;
}
}
2021-01-11 00:08:14 +00:00
2021-01-07 10:23:54 +00:00
return build _string ;
}
return "" ;
2021-01-06 12:48:41 +00:00
}
2021-01-09 08:52:58 +00:00
function calculateBuild ( save _skp , skp ) {
2021-01-12 23:14:12 +00:00
try {
2021-01-13 19:55:13 +00:00
let specialNames = [ "Quake" , "Chain_Lightning" , "Curse" , "Courage" , "Air_Prison" ] ;
for ( const sName of specialNames ) {
for ( let i = 1 ; i < 6 ; i ++ ) {
let elem = document . getElementById ( sName + "-" + i ) ;
let name = sName . replace ( "_" , " " ) ;
if ( elem . classList . contains ( "toggleOn" ) ) { //toggle the pressed button off
elem . classList . remove ( "toggleOn" ) ;
let special = powderSpecialStats [ specialNames . indexOf ( sName ) ] ;
console . log ( special ) ;
if ( special [ "weaponSpecialEffects" ] . has ( "Damage Boost" ) ) {
2021-01-14 03:17:01 +00:00
if ( name === "Courage" || name === "Curse" ) { //courage is universal damage boost
//player_build.damageMultiplier -= special.weaponSpecialEffects.get("Damage Boost")[i-1]/100;
player _build . externalStats . set ( "sdPct" , player _build . externalStats . get ( "sdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
player _build . externalStats . set ( "mdPct" , player _build . externalStats . get ( "mdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
2021-01-14 06:58:32 +00:00
player _build . externalStats . set ( "poisonPct" , player _build . externalStats . get ( "poisonPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
2021-01-13 19:55:13 +00:00
} else if ( name === "Air Prison" ) {
2021-01-14 03:17:01 +00:00
player _build . externalStats . set ( "aDamPct" , player _build . externalStats . get ( "aDamPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
player _build . externalStats . get ( "damageBonus" ) [ 4 ] -= special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ;
2021-01-13 19:55:13 +00:00
}
}
}
}
}
if ( player _build ) {
2021-01-19 17:50:34 +00:00
updateBoosts ( "skip" , false ) ;
updatePowderSpecials ( "skip" , false ) ;
2021-01-13 19:55:13 +00:00
}
//updatePowderSpecials("skip"); //jank pt 1
2021-01-12 23:14:12 +00:00
save _skp = ( typeof save _skp !== 'undefined' ) ? save _skp : false ;
/ * T O D O : i m p l e m e n t l e v e l c h a n g i n g
Make this entire function prettier
* /
let equipment = [ null , null , null , null , null , null , null , null , null ] ;
for ( let i in equipment ) {
let equip = getValue ( equipmentInputs [ i ] ) ;
if ( equip === "" ) equip = "No " + equipment _names [ i ] ;
equipment [ i ] = equip ;
}
let powderings = [ ] ;
2021-01-17 21:01:20 +00:00
let errors = [ ] ;
2021-01-12 23:14:12 +00:00
for ( const i in powderInputs ) {
// read in two characters at a time.
// TODO: make this more robust.
let input = getValue ( powderInputs [ i ] ) ;
let powdering = [ ] ;
2021-01-18 04:32:58 +00:00
let errorederrors = [ ] ;
2021-01-12 23:14:12 +00:00
while ( input ) {
let first = input . slice ( 0 , 2 ) ;
let powder = powderIDs . get ( first ) ;
console . log ( powder ) ;
if ( powder === undefined ) {
2021-01-18 04:32:58 +00:00
errorederrors . push ( first ) ;
} else {
powdering . push ( powder ) ;
2021-01-12 23:14:12 +00:00
}
input = input . slice ( 2 ) ;
}
2021-01-18 04:32:58 +00:00
if ( errorederrors . length > 0 ) {
if ( errorederrors . length > 1 )
errors . push ( new IncorrectInput ( errorederrors . join ( "" ) , "t6w6" , powderInputs [ i ] ) ) ;
else
errors . push ( new IncorrectInput ( errorederrors [ 0 ] , "t6 or e3" , powderInputs [ i ] ) ) ;
2021-01-17 21:01:20 +00:00
}
2021-01-18 04:32:58 +00:00
console . log ( "POWDERING" + powdering ) ;
2021-01-12 23:14:12 +00:00
powderings . push ( powdering ) ;
}
2021-01-17 21:01:20 +00:00
console . log ( equipment ) ;
2021-01-17 21:06:40 +00:00
player _build = new Build ( document . getElementById ( "level-choice" ) . value , equipment , powderings , new Map ( ) , errors ) ;
2021-01-11 00:08:14 +00:00
2021-01-14 02:13:41 +00:00
for ( let i of document . getElementsByClassName ( "hide-container-block" ) ) {
i . style . display = "block" ;
}
for ( let i of document . getElementsByClassName ( "hide-container-grid" ) ) {
i . style . display = "grid" ;
2021-01-18 10:14:08 +00:00
}
2021-01-13 01:38:13 +00:00
2021-01-12 23:14:12 +00:00
console . log ( player _build . toString ( ) ) ;
displayEquipOrder ( document . getElementById ( "build-order" ) , player _build . equip _order ) ;
2021-01-07 06:41:41 +00:00
2021-01-12 23:14:12 +00:00
2021-01-09 11:21:46 +00:00
2021-01-12 23:14:12 +00:00
const assigned = player _build . base _skillpoints ;
const skillpoints = player _build . total _skillpoints ;
for ( let i in skp _order ) { //big bren
setText ( skp _order [ i ] + "-skp-base" , "Original Value: " + skillpoints [ i ] ) ;
}
2021-01-18 14:18:14 +00:00
for ( let id of editable _item _fields ) {
setValue ( id , player _build . statMap . get ( id ) ) ;
setText ( id + "-base" , "Original Value: " + player _build . statMap . get ( id ) ) ;
}
2021-01-12 23:14:12 +00:00
if ( save _skp ) {
// TODO: reduce duplicated code, @updateStats
let skillpoints = player _build . total _skillpoints ;
let delta _total = 0 ;
for ( let i in skp _order ) {
let manual _assigned = skp [ i ] ;
let delta = manual _assigned - skillpoints [ i ] ;
skillpoints [ i ] = manual _assigned ;
player _build . base _skillpoints [ i ] += delta ;
delta _total += delta ;
}
player _build . assigned _skillpoints += delta _total ;
}
calculateBuildStats ( ) ;
setTitle ( ) ;
2021-01-17 21:01:20 +00:00
if ( player _build . errored )
throw new ListError ( player _build . errors ) ;
2021-01-11 23:43:04 +00:00
}
2021-01-12 23:14:12 +00:00
catch ( error ) {
2021-01-17 21:01:20 +00:00
if ( error instanceof ListError ) {
for ( let i of error . errors ) {
if ( i instanceof ItemNotFound ) {
i . element . textContent = i . message ;
} else if ( i instanceof IncorrectInput ) {
if ( document . getElementById ( i . id ) !== null ) {
document . getElementById ( i . id ) . parentElement . querySelectorAll ( "p.error" ) [ 0 ] . textContent = i . message ;
}
} else {
let msg = i . stack ;
let lines = msg . split ( "\n" ) ;
let header = document . getElementById ( "header" ) ;
header . textContent = "" ;
for ( const line of lines ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "itemp" ) ;
p . textContent = line ;
header . appendChild ( p ) ;
}
let p2 = document . createElement ( "p" ) ;
p2 . textContent = "If you believe this is an error, contact hppeng on forums or discord." ;
header . appendChild ( p2 ) ;
}
}
} else {
let msg = error . stack ;
let lines = msg . split ( "\n" ) ;
let header = document . getElementById ( "header" ) ;
header . textContent = "" ;
for ( const line of lines ) {
let p = document . createElement ( "p" ) ;
p . classList . add ( "itemp" ) ;
p . textContent = line ;
header . appendChild ( p ) ;
}
let p2 = document . createElement ( "p" ) ;
p2 . textContent = "If you believe this is an error, contact hppeng on forums or discord." ;
header . appendChild ( p2 ) ;
2021-01-09 08:52:58 +00:00
}
}
}
2021-01-12 07:11:20 +00:00
/ * U p d a t e s a l l b u i l d s t a t i s t i c s b a s e d o n ( f o r n o w ) t h e s k i l l p o i n t i n p u t f i e l d s a n d t h e n c a l c u l a t e s b u i l d s t a t s .
* /
2021-01-09 08:52:58 +00:00
function updateStats ( ) {
2021-01-15 18:20:17 +00:00
2021-01-14 03:17:01 +00:00
let specialNames = [ "Quake" , "Chain_Lightning" , "Curse" , "Courage" , "Air_Prison" ] ;
for ( const sName of specialNames ) {
for ( let i = 1 ; i < 6 ; i ++ ) {
let elem = document . getElementById ( sName + "-" + i ) ;
let name = sName . replace ( "_" , " " ) ;
if ( elem . classList . contains ( "toggleOn" ) ) { //toggle the pressed button off
elem . classList . remove ( "toggleOn" ) ;
let special = powderSpecialStats [ specialNames . indexOf ( sName ) ] ;
console . log ( special ) ;
if ( special [ "weaponSpecialEffects" ] . has ( "Damage Boost" ) ) {
if ( name === "Courage" || name === "Curse" ) { //courage is universal damage boost
//player_build.damageMultiplier -= special.weaponSpecialEffects.get("Damage Boost")[i-1]/100;
player _build . externalStats . set ( "sdPct" , player _build . externalStats . get ( "sdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
player _build . externalStats . set ( "mdPct" , player _build . externalStats . get ( "mdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
2021-01-14 06:58:32 +00:00
player _build . externalStats . set ( "poisonPct" , player _build . externalStats . get ( "poisonPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
2021-01-14 03:17:01 +00:00
} else if ( name === "Air Prison" ) {
player _build . externalStats . set ( "aDamPct" , player _build . externalStats . get ( "aDamPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
player _build . externalStats . get ( "damageBonus" ) [ 4 ] -= special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ;
}
}
}
}
}
2021-01-15 18:20:17 +00:00
2021-01-14 03:17:01 +00:00
2021-01-11 17:52:21 +00:00
//WILL BREAK WEBSITE IF NO BUILD HAS BEEN INITIALIZED! @HPP
2021-01-09 08:52:58 +00:00
let skillpoints = player _build . total _skillpoints ;
let delta _total = 0 ;
for ( let i in skp _order ) {
2021-01-14 06:58:32 +00:00
let value = document . getElementById ( skp _order [ i ] + "-skp" ) . value ;
let manual _assigned = 0 ;
if ( value . includes ( "+" ) ) {
let skp = value . split ( "+" ) ;
for ( const s of skp ) {
manual _assigned += parseInt ( s , 10 ) ;
}
2021-01-14 08:10:46 +00:00
} else {
2021-01-14 06:58:32 +00:00
manual _assigned = parseInt ( value , 10 ) ;
}
2021-01-09 08:52:58 +00:00
let delta = manual _assigned - skillpoints [ i ] ;
skillpoints [ i ] = manual _assigned ;
player _build . base _skillpoints [ i ] += delta ;
delta _total += delta ;
}
player _build . assigned _skillpoints += delta _total ;
2021-01-15 18:20:17 +00:00
if ( player _build ) {
2021-01-18 14:18:14 +00:00
updatePowderSpecials ( "skip" , false ) ;
updateBoosts ( "skip" , false ) ;
2021-01-15 18:20:17 +00:00
}
2021-01-18 14:18:14 +00:00
for ( let id of editable _item _fields ) {
player _build . statMap . set ( id , parseInt ( getValue ( id ) ) ) ;
2021-01-15 18:20:17 +00:00
}
2021-01-18 14:18:14 +00:00
player _build . aggregateStats ( ) ;
console . log ( player _build . statMap ) ;
calculateBuildStats ( ) ;
2021-01-09 08:52:58 +00:00
}
2021-01-12 21:07:03 +00:00
/ * U p d a t e s a l l s p e l l b o o s t s
2021-01-12 07:11:20 +00:00
* /
2021-01-18 14:18:14 +00:00
function updateBoosts ( buttonId , recalcStats ) {
2021-01-15 18:20:17 +00:00
let elem = document . getElementById ( buttonId ) ;
let name = buttonId . split ( "-" ) [ 0 ] ;
if ( buttonId !== "skip" ) {
2021-01-13 19:55:13 +00:00
if ( elem . classList . contains ( "toggleOn" ) ) {
2021-01-14 06:58:32 +00:00
player _build . damageMultiplier -= damageMultipliers . get ( name ) ;
if ( name === "warscream" ) {
2021-01-18 07:43:57 +00:00
player _build . defenseMultiplier -= . 20 ;
2021-01-14 06:58:32 +00:00
}
2021-01-13 19:55:13 +00:00
elem . classList . remove ( "toggleOn" ) ;
} else {
2021-01-14 06:58:32 +00:00
player _build . damageMultiplier += damageMultipliers . get ( name ) ;
if ( name === "warscream" ) {
2021-01-18 07:43:57 +00:00
player _build . defenseMultiplier += . 20 ;
2021-01-14 06:58:32 +00:00
}
2021-01-13 19:55:13 +00:00
elem . classList . add ( "toggleOn" ) ;
}
2021-01-20 05:35:25 +00:00
updatePowderSpecials ( "skip" , false ) ; //jank pt 1
2021-01-15 18:20:17 +00:00
} else {
for ( const [ key , value ] of damageMultipliers ) {
let elem = document . getElementById ( key + "-boost" )
if ( elem . classList . contains ( "toggleOn" ) ) {
elem . classList . remove ( "toggleOn" ) ;
player _build . damageMultiplier -= value ;
2021-01-18 07:43:57 +00:00
if ( key === "warscream" ) { player _build . defenseMultiplier -= . 20 }
2021-01-15 18:20:17 +00:00
}
}
}
2021-01-18 14:18:14 +00:00
if ( recalcStats ) {
calculateBuildStats ( ) ;
}
2021-01-12 07:11:20 +00:00
}
2021-01-09 08:52:58 +00:00
2021-01-12 21:07:03 +00:00
/ * U p d a t e s a l l p o w d e r s p e c i a l b o o s t s
* /
2021-01-18 14:18:14 +00:00
function updatePowderSpecials ( buttonId , recalcStats ) {
2021-01-14 03:17:01 +00:00
//console.log(player_build.statMap);
2021-01-15 18:20:17 +00:00
2021-01-12 21:07:03 +00:00
let name = ( buttonId ) . split ( "-" ) [ 0 ] ;
2021-01-13 19:55:13 +00:00
let power = ( buttonId ) . split ( "-" ) [ 1 ] ; // [1, 5]
2021-01-12 21:07:03 +00:00
let specialNames = [ "Quake" , "Chain Lightning" , "Curse" , "Courage" , "Air Prison" ] ;
let powderSpecials = [ ] ; // [ [special, power], [special, power]]
2021-01-13 19:55:13 +00:00
2021-01-13 08:30:55 +00:00
if ( name !== "skip" ) {
let elem = document . getElementById ( buttonId ) ;
2021-01-13 19:55:13 +00:00
if ( elem . classList . contains ( "toggleOn" ) ) { //toggle the pressed button off
2021-01-13 08:30:55 +00:00
elem . classList . remove ( "toggleOn" ) ;
2021-01-13 19:55:13 +00:00
let special = powderSpecialStats [ specialNames . indexOf ( name . replace ( "_" , " " ) ) ] ;
if ( special . weaponSpecialEffects . has ( "Damage Boost" ) ) {
name = name . replace ( "_" , " " ) ;
2021-01-14 03:17:01 +00:00
if ( name === "Courage" || name === "Curse" ) { //courage and curse are universal damage boost
player _build . externalStats . set ( "sdPct" , player _build . externalStats . get ( "sdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
player _build . externalStats . set ( "mdPct" , player _build . externalStats . get ( "mdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
2021-01-14 06:58:32 +00:00
player _build . externalStats . set ( "poisonPct" , player _build . externalStats . get ( "poisonPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
2021-01-14 03:17:01 +00:00
//poison?
2021-01-13 19:55:13 +00:00
} else if ( name === "Air Prison" ) {
2021-01-14 03:17:01 +00:00
player _build . externalStats . set ( "aDamPct" , player _build . externalStats . get ( "aDamPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
player _build . externalStats . get ( "damageBonus" ) [ 4 ] -= special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ;
2021-01-13 19:55:13 +00:00
}
2021-01-13 08:30:55 +00:00
}
2021-01-13 19:55:13 +00:00
} else {
for ( let i = 1 ; i < 6 ; i ++ ) { //toggle all pressed buttons of the same powder special off
//name is same, power is i
if ( document . getElementById ( name . replace ( " " , "_" ) + "-" + i ) . classList . contains ( "toggleOn" ) ) {
document . getElementById ( name . replace ( " " , "_" ) + "-" + i ) . classList . remove ( "toggleOn" ) ;
let special = powderSpecialStats [ specialNames . indexOf ( name . replace ( "_" , " " ) ) ] ;
if ( special . weaponSpecialEffects . has ( "Damage Boost" ) ) {
name = name . replace ( "_" , " " ) ; //might be redundant
2021-01-14 03:17:01 +00:00
if ( name === "Courage" || name === "Curse" ) { //courage is universal damage boost
//player_build.damageMultiplier -= special.weaponSpecialEffects.get("Damage Boost")[i-1]/100;
player _build . externalStats . set ( "sdPct" , player _build . externalStats . get ( "sdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
player _build . externalStats . set ( "mdPct" , player _build . externalStats . get ( "mdPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
2021-01-14 06:58:32 +00:00
player _build . externalStats . set ( "poisonPct" , player _build . externalStats . get ( "poisonPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
2021-01-13 19:55:13 +00:00
} else if ( name === "Air Prison" ) {
2021-01-14 03:17:01 +00:00
player _build . externalStats . set ( "aDamPct" , player _build . externalStats . get ( "aDamPct" ) - special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ) ;
player _build . externalStats . get ( "damageBonus" ) [ 4 ] -= special . weaponSpecialEffects . get ( "Damage Boost" ) [ i - 1 ] ;
2021-01-13 19:55:13 +00:00
}
}
}
}
//toggle the pressed button on
elem . classList . add ( "toggleOn" ) ;
2021-01-12 21:07:03 +00:00
}
}
2021-01-13 08:30:55 +00:00
2021-01-12 21:07:03 +00:00
for ( const sName of specialNames ) {
for ( let i = 1 ; i < 6 ; i ++ ) {
if ( document . getElementById ( sName . replace ( " " , "_" ) + "-" + i ) . classList . contains ( "toggleOn" ) ) {
let powderSpecial = powderSpecialStats [ specialNames . indexOf ( sName . replace ( "_" , " " ) ) ] ;
powderSpecials . push ( [ powderSpecial , i ] ) ;
break ;
}
}
}
2021-01-14 03:17:01 +00:00
2021-01-13 19:55:13 +00:00
if ( name !== "skip" ) {
let elem = document . getElementById ( buttonId ) ;
if ( elem . classList . contains ( "toggleOn" ) ) {
let special = powderSpecialStats [ specialNames . indexOf ( name . replace ( "_" , " " ) ) ] ;
if ( special [ "weaponSpecialEffects" ] . has ( "Damage Boost" ) ) {
let name = special [ "weaponSpecialName" ] ;
2021-01-14 03:17:01 +00:00
if ( name === "Courage" || name === "Curse" ) { //courage and curse are is universal damage boost
player _build . externalStats . set ( "sdPct" , player _build . externalStats . get ( "sdPct" ) + special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
player _build . externalStats . set ( "mdPct" , player _build . externalStats . get ( "mdPct" ) + special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
2021-01-14 06:58:32 +00:00
player _build . externalStats . set ( "poisonPct" , player _build . externalStats . get ( "poisonPct" ) + special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
2021-01-13 19:55:13 +00:00
} else if ( name === "Air Prison" ) {
2021-01-14 03:17:01 +00:00
player _build . externalStats . set ( "aDamPct" , player _build . externalStats . get ( "aDamPct" ) + special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ) ;
player _build . externalStats . get ( "damageBonus" ) [ 4 ] += special . weaponSpecialEffects . get ( "Damage Boost" ) [ power - 1 ] ;
2021-01-13 19:55:13 +00:00
}
}
}
}
2021-01-18 14:18:14 +00:00
if ( recalcStats ) {
calculateBuildStats ( ) ;
}
2021-01-14 03:17:01 +00:00
displayPowderSpecials ( document . getElementById ( "powder-special-stats" ) , powderSpecials , player _build ) ;
2021-01-12 21:07:03 +00:00
}
2021-01-12 07:11:20 +00:00
/ * C a l c u l a t e s a l l b u i l d s t a t i s t i c s a n d u p d a t e s t h e e n t i r e d i s p l a y .
* /
2021-01-09 08:52:58 +00:00
function calculateBuildStats ( ) {
2021-01-08 05:36:57 +00:00
const assigned = player _build . base _skillpoints ;
const skillpoints = player _build . total _skillpoints ;
2021-01-08 20:14:23 +00:00
let skp _effects = [ "% more damage dealt." , "% chance to crit." , "% spell cost reduction." , "% less damage taken." , "% chance to dodge." ] ;
for ( let i in skp _order ) { //big bren
2021-01-09 11:21:46 +00:00
setText ( skp _order [ i ] + "-skp-assign" , "Manually Assigned: " + assigned [ i ] ) ;
2021-01-08 20:14:23 +00:00
setValue ( skp _order [ i ] + "-skp" , skillpoints [ i ] ) ;
2021-01-11 17:52:21 +00:00
let linebreak = document . createElement ( "br" ) ;
linebreak . classList . add ( "itemp" ) ;
2021-01-11 23:43:04 +00:00
document . getElementById ( skp _order [ i ] + "-skp-label" ) ;
2021-01-08 20:21:31 +00:00
setText ( skp _order [ i ] + "-skp-pct" , ( skillPointsToPercentage ( skillpoints [ i ] ) * 100 ) . toFixed ( 1 ) . concat ( skp _effects [ i ] ) ) ;
2021-01-11 17:52:21 +00:00
if ( assigned [ i ] > 100 ) {
let skp _warning = document . createElement ( "p" ) ;
skp _warning . classList . add ( "warning" ) ;
skp _warning . textContent += "WARNING: Cannot assign " + assigned [ i ] + " skillpoints in " + [ "Strength" , "Dexterity" , "Intelligence" , "Defense" , "Agility" ] [ i ] + " manually." ;
document . getElementById ( skp _order [ i ] + "-skp-pct" ) . appendChild ( skp _warning ) ;
}
2021-01-08 20:14:23 +00:00
}
2021-01-09 08:52:58 +00:00
2021-01-11 00:08:14 +00:00
let summarybox = document . getElementById ( "summary-box" ) ;
summarybox . textContent = "" ;
2021-01-14 03:17:01 +00:00
let skpRow = document . createElement ( "p" ) ;
//skpRow.classList.add("left");
let td = document . createElement ( "p" ) ;
//td.classList.add("left");
2021-01-20 12:10:25 +00:00
/ * l e t s k p S u m m a r y = d o c u m e n t . c r e a t e E l e m e n t ( " b " ) ;
2021-01-14 03:17:01 +00:00
skpSummary . textContent = "Assigned " + player _build . assigned _skillpoints + " skillpoints. Total: (" ;
//skpSummary.classList.add("itemp");
td . appendChild ( skpSummary ) ;
2021-01-11 02:58:39 +00:00
for ( let i = 0 ; i < skp _order . length ; i ++ ) {
2021-01-14 03:17:01 +00:00
let skp = document . createElement ( "b" ) ;
let boost = document . createElement ( "b" ) ;
2021-01-11 02:58:39 +00:00
skp . classList . add ( damageClasses [ i + 1 ] ) ;
boost . textContent = player _build . total _skillpoints [ i ] ;
2021-01-14 03:17:01 +00:00
if ( i < 4 ) {
boost . classList . add ( "space" ) ;
2021-01-11 02:58:39 +00:00
}
2021-01-14 03:17:01 +00:00
td . appendChild ( skp ) ;
td . appendChild ( boost ) ;
2021-01-11 02:58:39 +00:00
}
2021-01-11 17:52:21 +00:00
2021-01-14 03:17:01 +00:00
let skpEnd = document . createElement ( "b" ) ;
2021-01-11 02:58:39 +00:00
skpEnd . textContent = ")" ;
2021-01-14 03:17:01 +00:00
td . appendChild ( skpEnd ) ;
2021-01-20 12:10:25 +00:00
skpRow . append ( td ) ; * /
2021-01-11 02:58:39 +00:00
2021-01-14 03:17:01 +00:00
let remainingSkp = document . createElement ( "p" ) ;
remainingSkp . classList . add ( "center" ) ;
2021-01-11 17:52:21 +00:00
let remainingSkpTitle = document . createElement ( "b" ) ;
2021-01-20 12:10:25 +00:00
remainingSkpTitle . textContent = "Assigned " + player _build . assigned _skillpoints + " skillpoints. Remaining skillpoints: " ;
2021-01-11 17:52:21 +00:00
let remainingSkpContent = document . createElement ( "b" ) ;
2021-01-15 23:34:21 +00:00
//remainingSkpContent.textContent = "" + (levelToSkillPoints(player_build.level) - player_build.assigned_skillpoints < 0 ? "< 0" : levelToSkillPoints(player_build.level) - player_build.assigned_skillpoints);
remainingSkpContent . textContent = "" + ( levelToSkillPoints ( player _build . level ) - player _build . assigned _skillpoints ) ;
2021-01-11 17:52:21 +00:00
remainingSkpContent . classList . add ( levelToSkillPoints ( player _build . level ) - player _build . assigned _skillpoints < 0 ? "negative" : "positive" ) ;
remainingSkp . appendChild ( remainingSkpTitle ) ;
remainingSkp . appendChild ( remainingSkpContent ) ;
2021-01-11 02:58:39 +00:00
summarybox . append ( skpRow ) ;
2021-01-14 03:17:01 +00:00
summarybox . append ( remainingSkp ) ;
2021-01-08 20:14:23 +00:00
if ( player _build . assigned _skillpoints > levelToSkillPoints ( player _build . level ) ) {
2021-01-11 00:08:14 +00:00
let skpWarning = document . createElement ( "p" ) ;
2021-01-11 17:52:21 +00:00
//skpWarning.classList.add("itemp");
skpWarning . classList . add ( "warning" ) ;
2021-01-11 00:08:14 +00:00
skpWarning . classList . add ( "itemp" ) ;
skpWarning . textContent = "WARNING: Too many skillpoints need to be assigned!" ;
let skpCount = document . createElement ( "p" ) ;
skpCount . classList . add ( "itemp" ) ;
2021-01-11 17:52:21 +00:00
skpCount . textContent = "For level " + ( player _build . level > 101 ? "101+" : player _build . level ) + ", there are only " + levelToSkillPoints ( player _build . level ) + " skill points available." ;
2021-01-11 00:08:14 +00:00
summarybox . append ( skpWarning ) ;
summarybox . append ( skpCount ) ;
}
2021-01-11 17:52:21 +00:00
let lvlWarning ;
for ( const item of player _build . items ) {
if ( player _build . level < item . get ( "lvl" ) ) {
if ( ! lvlWarning ) {
lvlWarning = document . createElement ( "p" ) ;
lvlWarning . classList . add ( "itemp" ) ;
lvlWarning . classList . add ( "warning" ) ;
lvlWarning . textContent = "WARNING: A level 50 player cannot use some piece(s) of this build."
}
let baditem = document . createElement ( "p" ) ;
baditem . classList . add ( "nocolor" ) ;
baditem . classList . add ( "itemp" ) ;
baditem . textContent = item . get ( "name" ) + " requires level " + item . get ( "lvl" ) + " to use." ;
lvlWarning . appendChild ( baditem ) ;
2021-01-11 00:08:14 +00:00
}
2021-01-08 20:14:23 +00:00
}
2021-01-11 17:52:21 +00:00
if ( lvlWarning ) {
summarybox . append ( lvlWarning ) ;
}
2021-01-07 08:34:31 +00:00
2021-01-09 03:53:57 +00:00
for ( let i in player _build . items ) {
displayExpandedItem ( player _build . items [ i ] , buildFields [ i ] ) ;
}
2021-01-08 20:17:37 +00:00
2021-01-15 18:20:17 +00:00
displayBuildStats ( "build-overall-stats" , player _build ) ;
displaySetBonuses ( "set-info" , player _build ) ;
displayNextCosts ( "int-info" , player _build ) ;
2021-01-09 12:47:25 +00:00
2021-01-08 02:34:07 +00:00
let meleeStats = player _build . getMeleeStats ( ) ;
2021-01-10 21:01:59 +00:00
displayMeleeDamage ( document . getElementById ( "build-melee-stats" ) , document . getElementById ( "build-melee-statsAvg" ) , meleeStats ) ;
2021-01-10 10:02:23 +00:00
2021-01-11 22:25:55 +00:00
displayDefenseStats ( document . getElementById ( "build-defense-stats" ) , player _build ) ;
2021-01-09 23:30:05 +00:00
2021-01-11 07:05:23 +00:00
displayPoisonDamage ( document . getElementById ( "build-poison-stats" ) , player _build ) ;
2021-01-09 08:52:58 +00:00
let spells = spell _table [ player _build . weapon . get ( "type" ) ] ;
for ( let i = 0 ; i < 4 ; ++ i ) {
let parent _elem = document . getElementById ( "spell" + i + "-info" ) ;
2021-01-10 21:01:59 +00:00
let overallparent _elem = document . getElementById ( "spell" + i + "-infoAvg" ) ;
displaySpellDamage ( parent _elem , overallparent _elem , player _build , spells [ i ] , i + 1 ) ;
2021-01-09 08:52:58 +00:00
}
2021-01-07 10:23:54 +00:00
location . hash = encodeBuild ( ) ;
2021-01-19 11:56:09 +00:00
clear _highlights ( ) ;
2021-01-07 08:11:54 +00:00
}
2021-01-08 03:15:02 +00:00
2021-01-11 11:08:10 +00:00
function copyBuild ( ) {
2021-01-11 12:09:58 +00:00
if ( player _build ) {
copyTextToClipboard ( url _base + location . hash ) ;
document . getElementById ( "copy-button" ) . textContent = "Copied!" ;
}
}
function shareBuild ( ) {
if ( player _build ) {
let text = url _base + location . hash + "\n" +
"WynnBuilder build:\n" +
2021-01-11 21:34:59 +00:00
"> " + player _build . helmet . get ( "displayName" ) + "\n" +
"> " + player _build . chestplate . get ( "displayName" ) + "\n" +
"> " + player _build . leggings . get ( "displayName" ) + "\n" +
"> " + player _build . boots . get ( "displayName" ) + "\n" +
"> " + player _build . ring1 . get ( "displayName" ) + "\n" +
"> " + player _build . ring2 . get ( "displayName" ) + "\n" +
"> " + player _build . bracelet . get ( "displayName" ) + "\n" +
"> " + player _build . necklace . get ( "displayName" ) + "\n" +
"> " + player _build . weapon . get ( "displayName" ) + " [" + player _build . weapon . get ( "powders" ) . map ( x => powderNames . get ( x ) ) . join ( "" ) + "]" ;
2021-01-11 12:09:58 +00:00
copyTextToClipboard ( text ) ;
document . getElementById ( "share-button" ) . textContent = "Copied!" ;
}
2021-01-11 11:08:10 +00:00
}
2021-01-06 20:54:15 +00:00
function resetFields ( ) {
2021-01-09 03:53:57 +00:00
for ( let i in powderInputs ) {
setValue ( powderInputs [ i ] , "" ) ;
}
2021-01-09 08:52:58 +00:00
for ( let i in equipmentInputs ) {
2021-01-09 03:53:57 +00:00
setValue ( equipmentInputs [ i ] , "" ) ;
}
2021-01-07 10:23:54 +00:00
setValue ( "str-skp" , "0" ) ;
setValue ( "dex-skp" , "0" ) ;
setValue ( "int-skp" , "0" ) ;
setValue ( "def-skp" , "0" ) ;
setValue ( "agi-skp" , "0" ) ;
2021-01-11 07:05:23 +00:00
setValue ( "level-choice" , "" ) ;
2021-01-08 01:16:06 +00:00
location . hash = "" ;
2021-01-14 03:17:01 +00:00
calculateBuild ( ) ;
2021-01-06 22:46:00 +00:00
}
2021-01-18 14:18:14 +00:00
function toggleID ( ) {
let button = document . getElementById ( "show-id-button" ) ;
let targetDiv = document . getElementById ( "id-edit" ) ;
if ( button . classList . contains ( "toggleOn" ) ) { //toggle the pressed button off
targetDiv . style . display = "none" ;
button . classList . remove ( "toggleOn" ) ;
}
else {
targetDiv . style . display = "block" ;
button . classList . add ( "toggleOn" ) ;
}
}
2021-01-07 00:08:19 +00:00
load _init ( init ) ;
2021-01-08 01:16:06 +00:00