2021-03-05 16:28:00 +00:00
2021-03-08 22:50:47 +00:00
const tiers = [ "Normal" , "Unique" , "Rare" , "Legendary" , "Fabled" , "Mythic" , "Set" , "Crafted" ] //I'm not sure why you would make a custom crafted but if you do you should be able to use it w/ the correct powder formula
const types = armorTypes . concat ( accessoryTypes ) . concat ( weaponTypes ) . concat ( consumableTypes ) . map ( x => x . substring ( 0 , 1 ) . toUpperCase ( ) + x . substring ( 1 ) ) ;
const atkSpds = [ "SUPER_SLOW" , "VERY_SLOW" , "SLOW" , "NORMAL" , "FAST" , "VERY_FAST" , "SUPER_FAST" ] ;
const ci _save _order = [ "name" , "lore" , "tier" , "set" , "slots" , "type" , "material" , "drop" , "quest" , "nDam" , "fDam" , "wDam" , "aDam" , "tDam" , "eDam" , "atkSpd" , "hp" , "fDef" , "wDef" , "aDef" , "tDef" , "eDef" , "lvl" , "classReq" , "strReq" , "dexReq" , "intReq" , "defReq" , "agiReq" , "str" , "dex" , "int" , "agi" , "def" , "id" , "skillpoints" , "reqs" , "nDam_" , "fDam_" , "wDam_" , "aDam_" , "tDam_" , "eDam_" , "majorIds" , "hprPct" , "mr" , "sdPct" , "mdPct" , "ls" , "ms" , "xpb" , "lb" , "ref" , "thorns" , "expd" , "spd" , "atkTier" , "poison" , "hpBonus" , "spRegen" , "eSteal" , "hprRaw" , "sdRaw" , "mdRaw" , "fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" , "fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" , "spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" , "rainbowRaw" , "sprint" , "sprintReg" , "jh" , "lq" , "gXp" , "gSpd" ] ;
//omitted restrict - it's always "Custom Item"
//omitted displayName - either it's the same as name (repetitive) or it's "Custom Item"
//omitted category - can always get this from type
//omitted fixId - we will denote this early in the string.
2021-03-05 16:28:00 +00:00
/ * * A n o b j e c t r e p r e s e n t i n g a C u s t o m I t e m . M o s t l y f o r v a n i t y p u r p o s e s .
* @ dep Requires the use of nonRolledIDs and rolledIDs from display . js .
* @ dep Requires the use of attackSpeeds from build . js .
* /
class Custom {
/ * *
* @ description Construct a custom item ( CI ) from a statMap .
* @ param { statMap } : A map with keys from rolledIDs or nonRolledIDs or minRolls / maxRolls and values befitting the keys . minRolls and maxRolls are their own maps and have the same keys , but with minimum and maximum values ( for rolls ) .
*
* /
constructor ( statMap ) {
this . statMap = statMap ;
this . initCustomStats ( ) ;
}
//Applies powders to the CI
applyPowders ( ) {
if ( this . statMap . get ( "category" ) === "armor" ) {
//double apply armor powders
for ( const id of this . statMap . get ( "powders" ) ) {
let powder = powderStats [ id ] ;
let name = powderNames . get ( id ) ;
this . statMap . set ( name . charAt ( 0 ) + "Def" , ( this . statMap . get ( name . charAt ( 0 ) + "Def" ) || 0 ) + 2 * powder [ "defPlus" ] ) ;
this . statMap . set ( skp _elements [ ( skp _elements . indexOf ( name . charAt ( 0 ) ) + 4 ) % 5 ] + "Def" , ( this . statMap . get ( skp _elements [ ( skp _elements . indexOf ( name . charAt ( 0 ) ) + 4 ) % 5 ] + "Def" ) || 0 ) - 2 * powder [ "defMinus" ] ) ;
}
} else if ( this . statMap . get ( "category" ) === "weapon" ) {
//do nothing - weapon powders are handled in displayExpandedItem
}
}
2021-03-08 22:50:47 +00:00
2021-03-05 16:28:00 +00:00
setHash ( hash ) {
this . hash = hash ;
2021-03-08 22:50:47 +00:00
this . statMap . set ( "hash" , hash ) ;
2021-03-05 16:28:00 +00:00
}
updateName ( name ) {
this . name = name ;
2021-03-08 22:50:47 +00:00
this . displayName = name ;
2021-03-05 16:28:00 +00:00
}
/ * G e t a l l s t a t s f o r t h i s C I .
* Stores in this . statMap .
* Follows the expandedItem item structure , similar to a crafted item .
* TODO : Check if this is even useful
* /
initCustomStats ( ) {
2021-03-08 22:50:47 +00:00
//this.setHashVerbose(); //do NOT move sethash from here please
this . statMap . set ( "custom" , true ) ;
2021-03-05 16:28:00 +00:00
if ( this . statMap . get ( "tier" ) === "Crafted" ) {
2021-03-08 22:50:47 +00:00
this . statMap . set ( "crafted" , true ) ;
2021-03-05 16:28:00 +00:00
for ( const e of skp _elements ) {
this . statMap . set ( e + "DamLow" , this . statMap . get ( e + "Dam" ) ) ;
}
this . statMap . set ( "nDamLow" , this . statMap . get ( "nDam" ) ) ;
}
if ( this . statMap . get ( "type" ) ) {
this . statMap . set ( "type" , this . statMap . get ( "type" ) . toLowerCase ( ) ) ;
if ( armorTypes . includes ( this . statMap . get ( "type" ) ) ) {
this . statMap . set ( "category" , "armor" ) ;
} else if ( accessoryTypes . includes ( this . statMap . get ( "type" ) ) ) {
this . statMap . set ( "category" , "accessory" ) ;
} else if ( weaponTypes . includes ( this . statMap . get ( "type" ) ) ) {
this . statMap . set ( "category" , "weapon" ) ;
} else if ( consumableTypes . includes ( this . statMap . get ( "type" ) ) ) {
this . statMap . set ( "category" , "consumable" )
}
}
if ( this . statMap . get ( "category" ) !== "weapon" ) {
this . statMap . set ( "atkSpd" , "" ) ;
}
2021-03-08 22:50:47 +00:00
2021-03-05 16:28:00 +00:00
if ( this . statMap . get ( "name" ) && this . statMap . get ( "name" ) !== "" ) {
this . statMap . set ( "displayName" , this . statMap . get ( "name" ) ) ;
} else {
2021-03-08 22:50:47 +00:00
this . statMap . set ( "displayName" , "Custom Item" ) ;
2021-03-05 16:28:00 +00:00
}
this . statMap . set ( "reqs" , [ this . statMap . get ( "strReq" ) , this . statMap . get ( "dexReq" ) , this . statMap . get ( "intReq" ) , this . statMap . get ( "defReq" ) , this . statMap . get ( "agiReq" ) ] ) ;
this . statMap . set ( "powders" , [ ] ) ;
this . statMap . set ( "restrict" , "Custom Item" )
}
}