2021-01-07 00:36:11 +00:00
/ *
* TESTING SECTION
* /
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
/ *
* END testing section
* /
2021-01-07 00:04:16 +00:00
2021-01-11 12:47:17 +00:00
const BUILD _VERSION = "6.3" ;
2021-01-07 10:30:23 +00:00
2021-01-11 11:08:10 +00:00
document . getElementById ( "header" ) . textContent = "WynnBuilder version " + BUILD _VERSION + " (db version " + DB _VERSION + ")" ;
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-09 08:52:58 +00:00
let skp _order = [ "str" , "dex" , "int" , "def" , "agi" ] ;
2021-01-10 10:02:23 +00:00
let skp _elements = [ "e" , "t" , "w" , "f" , "a" ] ;
2021-01-11 08:10:33 +00:00
let elementIcons = [ "\u2724" , "\u2726" , "\u2749" , "\u2739" , "\u274b" ] ;
2021-01-09 08:52:58 +00:00
let skpReqs = skp _order . map ( x => x + "Req" ) ;
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 powderIDs = new Map ( ) ;
let powderNames = new Map ( ) ;
let _powderID = 0 ;
2021-01-10 10:02:23 +00:00
for ( const x of skp _elements ) {
2021-01-08 20:17:37 +00:00
for ( let i = 1 ; i <= 6 ; ++ i ) {
// Support both upper and lowercase, I guess.
powderIDs . set ( x . toUpperCase ( ) + i , _powderID ) ;
powderIDs . set ( x + i , _powderID ) ;
powderNames . set ( _powderID , x + i ) ;
_powderID ++ ;
}
}
let powderInputs = [
"helmet-powder" ,
"chestplate-powder" ,
"leggings-powder" ,
"boots-powder" ,
"weapon-powder" ,
] ;
// Ordering: [dmgMin, dmgMax, convert, defPlus, defMinus (+6 mod 5)]
2021-01-09 00:56:07 +00:00
class Powder {
constructor ( min , max , convert , defPlus , defMinus ) {
this . min = min ;
this . max = max ;
this . convert = convert ;
this . defPlus = defPlus ;
this . defMinus = defMinus ;
}
}
2021-01-10 03:49:32 +00:00
function _p ( a , b , c , d , e ) { return new Powder ( a , b , c , d , e ) ; } //bruh moment
2021-01-09 00:56:07 +00:00
2021-01-08 20:17:37 +00:00
let powderStats = [
2021-01-09 00:56:07 +00:00
_p ( 3 , 6 , 17 , 2 , 1 ) , _p ( 6 , 9 , 21 , 4 , 2 ) , _p ( 8 , 14 , 25 , 8 , 3 ) , _p ( 11 , 16 , 31 , 14 , 5 ) , _p ( 15 , 18 , 38 , 22 , 9 ) , _p ( 18 , 22 , 46 , 30 , 13 ) ,
_p ( 1 , 8 , 9 , 3 , 1 ) , _p ( 1 , 13 , 11 , 5 , 1 ) , _p ( 2 , 18 , 14 , 9 , 2 ) , _p ( 3 , 24 , 17 , 14 , 4 ) , _p ( 3 , 32 , 22 , 20 , 7 ) , _p ( 5 , 40 , 28 , 28 , 10 ) ,
_p ( 3 , 4 , 13 , 3 , 1 ) , _p ( 4 , 7 , 15 , 6 , 1 ) , _p ( 6 , 10 , 17 , 11 , 2 ) , _p ( 8 , 12 , 21 , 18 , 4 ) , _p ( 11 , 14 , 26 , 28 , 7 ) , _p ( 13 , 17 , 32 , 40 , 10 ) ,
_p ( 2 , 5 , 14 , 3 , 1 ) , _p ( 4 , 8 , 16 , 5 , 2 ) , _p ( 6 , 10 , 19 , 9 , 3 ) , _p ( 9 , 13 , 24 , 16 , 5 ) , _p ( 12 , 16 , 30 , 25 , 9 ) , _p ( 15 , 19 , 37 , 36 , 13 ) ,
_p ( 2 , 6 , 11 , 3 , 1 ) , _p ( 4 , 9 , 14 , 6 , 2 ) , _p ( 7 , 10 , 17 , 10 , 3 ) , _p ( 9 , 13 , 22 , 16 , 5 ) , _p ( 13 , 18 , 28 , 24 , 9 ) , _p ( 16 , 18 , 35 , 34 , 13 )
2021-01-08 20:17:37 +00:00
] ;
2021-01-11 06:49:52 +00:00
//Ordering: [weapon special name, weapon special effects, armor special name, armor special effects]
class PowderSpecial {
constructor ( wSpName , wSpEff , aSpName , aSpEff , cap ) {
this . weaponSpecialName = wSpName ;
this . weaponSpecialEffects = wSpEff ;
this . armorSpecialName = aSpName ;
this . armorSpecialEffects = aSpEff ;
this . cap = cap ;
}
}
function _ps ( a , b , c , d , e ) { return new PowderSpecial ( a , b , c , d , e ) ; } //bruh moment
let powderSpecialStats = [
2021-01-11 07:40:49 +00:00
_ps ( "Quake" , new Map ( [ [ "Radius" , [ 5 , 5.5 , 6 , 6.5 , 7 ] ] , [ "Damage" , [ 155 , 220 , 285 , 350 , 415 ] ] ] ) , "Rage" , new Map ( [ [ "Damage" , [ 0.3 , 0.4 , 0.5 , 0.7 , 1.0 ] ] , [ "Description" , "% " + "\u2764" + " Missing" ] ] ) , 400 ) , //e
2021-01-11 06:49:52 +00:00
_ps ( "Chain Lightning" , new Map ( [ [ "Chains" , [ 5 , 6 , 7 , 8 , 9 ] ] , [ "Damage" , [ 80 , 120 , 160 , 200 , 240 ] ] ] ) , "Kill Streak" , new Map ( [ [ "Damage" , [ 3 , 4.5 , 6 , 7.5 , 9 ] ] , [ "Duration" , [ 5 , 5 , 5 , 5 , 5 ] ] , [ "Description" , "Mob Killed" ] ] ) , 200 ) , //t
_ps ( "Curse" , new Map ( [ [ "Duration" , [ 7 , 7.5 , 8 , 8.5 , 9 ] ] , [ "Damage" , [ 90 , 120 , 150 , 180 , 210 ] ] ] ) , "Concentration" , new Map ( [ [ "Damage" , [ 1 , 2 , 3 , 4 , 5 ] ] , [ "Duration" , [ 1 , 1 , 1 , 1 , 1 ] ] , [ "Description" , "Mana Used" ] ] ) , 150 ) , //w
_ps ( "Courage" , new Map ( [ [ "Duration" , [ 6 , 6.5 , 7 , 7.5 , 8 ] ] , [ "Damage" , [ 75 , 87.5 , 100 , 112.5 , 125 ] ] , [ "Damage Boost" , [ 70 , 90 , 110 , 130 , 150 ] ] ] ) , "Endurance" , new Map ( [ [ "Damage" , [ 2 , 3 , 4 , 5 , 6 ] ] , [ "Duration" , [ 8 , 8 , 8 , 8 , 8 ] ] , [ "Description" , "Hit Taken" ] ] ) , 200 ) , //f
_ps ( "Air Prison" , new Map ( [ [ "Duration" , [ 3 , 3.5 , 4 , 4.5 , 5 ] ] , [ "Damage Boost" , [ 400 , 450 , 500 , 550 , 600 ] ] , [ "Knockback" , [ 8 , 12 , 16 , 20 , 24 ] ] ] ) , "Dodge" , new Map ( [ [ "Damage" , [ 2 , 3 , 4 , 5 , 6 ] ] , [ "Duration" , [ 2 , 3 , 4 , 5 , 6 ] ] , [ "Description" , "Near Mobs" ] ] ) , 150 ) //a
] ;
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" ;
}
else {
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 ) ;
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-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
}
}
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 ) ;
console . log ( 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 ) {
save _skp = ( typeof save _skp !== 'undefined' ) ? save _skp : false ;
2021-01-06 23:31:35 +00:00
/ * 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
* /
2021-01-09 03:53:57 +00:00
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 ;
2021-01-06 23:31:35 +00:00
}
2021-01-08 20:17:37 +00:00
let powderings = [ ] ;
for ( const i in powderInputs ) {
// read in two characters at a time.
// TODO: make this more robust.
let input = getValue ( powderInputs [ i ] ) ;
let powdering = [ ] ;
while ( input ) {
let first = input . slice ( 0 , 2 ) ;
powdering . push ( powderIDs . get ( first ) ) ;
input = input . slice ( 2 ) ;
}
powderings . push ( powdering ) ;
}
2021-01-11 00:08:14 +00:00
//level setting
let level = document . getElementById ( "level-choice" ) . value ;
if ( level === "" ) {
level = 106 ;
}
document . getElementById ( "level-choice" ) . value = level ;
2021-01-09 03:53:57 +00:00
console . log ( equipment ) ;
2021-01-11 00:08:14 +00:00
player _build = new Build ( level , equipment , powderings ) ;
2021-01-06 22:46:00 +00:00
console . log ( player _build . toString ( ) ) ;
2021-01-10 10:02:23 +00:00
displayEquipOrder ( document . getElementById ( "build-order" ) , player _build . equip _order ) ;
2021-01-07 06:41:41 +00:00
2021-01-10 10:02:23 +00:00
2021-01-09 11:21:46 +00:00
const assigned = player _build . base _skillpoints ;
const skillpoints = player _build . total _skillpoints ;
2021-01-11 17:52:21 +00:00
2021-01-09 08:52:58 +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 ;
}
2021-01-07 08:17:53 +00:00
2021-01-09 08:52:58 +00:00
calculateBuildStats ( ) ;
}
function updateStats ( ) {
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 ) {
let manual _assigned = getValue ( skp _order [ i ] + "-skp" ) ;
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 ( ) ;
}
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" ) ;
document . getElementById ( skp _order [ i ] + "-skp-label" ) . append ( document . createElement ( "br" ) ) ;
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-11 02:58:39 +00:00
let skpRow = document . createElement ( "tr" ) ;
let skpSummary = document . createElement ( "td" ) ;
2021-01-11 17:52:21 +00:00
skpSummary . textContent = "Summary: Assigned " + player _build . assigned _skillpoints + " skillpoints. Total: (" ;
2021-01-11 00:08:14 +00:00
skpSummary . classList . add ( "itemp" ) ;
2021-01-11 02:58:39 +00:00
skpRow . appendChild ( skpSummary ) ;
for ( let i = 0 ; i < skp _order . length ; i ++ ) {
let skp = document . createElement ( "td" ) ;
let boost = document . createElement ( "td" ) ;
let separator = document . createElement ( "td" ) ;
skp . classList . add ( "itemp" ) ;
skp . classList . add ( "nopadding" ) ;
skp . classList . add ( damageClasses [ i + 1 ] ) ;
boost . classList . add ( "itemp" ) ;
boost . classList . add ( "nopadding" ) ;
boost . textContent = player _build . total _skillpoints [ i ] ;
skpRow . appendChild ( skp ) ;
skpRow . appendChild ( document . createElement ( "br" ) ) ;
skpRow . appendChild ( boost ) ;
if ( i < 4 ) {
skpRow . appendChild ( separator ) ;
}
}
2021-01-11 17:52:21 +00:00
2021-01-11 02:58:39 +00:00
let skpEnd = document . createElement ( "td" ) ;
skpEnd . textContent = ")" ;
skpEnd . classList . add ( "itemp" ) ;
skpRow . append ( skpEnd ) ;
2021-01-11 17:52:21 +00:00
let remainingRow = document . createElement ( "tr" ) ;
remainingRow . classList . add ( "itemp" ) ;
let remainingSkp = document . createElement ( "td" ) ;
remainingSkp . classList . add ( "left" ) ;
let remainingSkpTitle = document . createElement ( "b" ) ;
remainingSkpTitle . textContent = "Remaining skillpoints: " ;
let remainingSkpContent = document . createElement ( "b" ) ;
remainingSkpContent . textContent = "" + ( levelToSkillPoints ( player _build . level ) - player _build . assigned _skillpoints < 0 ? "< 0" : levelToSkillPoints ( player _build . level ) - player _build . assigned _skillpoints ) ;
remainingSkpContent . classList . add ( levelToSkillPoints ( player _build . level ) - player _build . assigned _skillpoints < 0 ? "negative" : "positive" ) ;
remainingSkp . appendChild ( remainingSkpTitle ) ;
remainingSkp . appendChild ( remainingSkpContent ) ;
remainingRow . appendChild ( remainingSkp ) ;
2021-01-11 02:58:39 +00:00
summarybox . append ( skpRow ) ;
2021-01-11 17:52:21 +00:00
summarybox . append ( remainingRow ) ;
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-09 12:47:25 +00:00
displayBuildStats ( player _build , "build-overall-stats" ) ;
2021-01-10 04:50:07 +00:00
displaySetBonuses ( player _build , "set-info" ) ;
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
let defenseStats = player _build . getDefenseStats ( ) ;
displayDefenseStats ( document . getElementById ( "build-defense-stats" ) , defenseStats ) ;
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-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" +
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" ) ;
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-06 22:46:00 +00:00
}
2021-01-07 00:08:19 +00:00
load _init ( init ) ;
2021-01-08 01:16:06 +00:00