2022-07-29 17:37:09 +00:00
/ * *
* File containing utility functions that are useful for the builder page .
* /
2021-01-19 17:32:27 +00:00
/ * T u r n s t h e i n p u t a m o u n t o f s k i l l p o i n t s i n t o a f l o a t p r e c i s i o n p e r c e n t a g e .
* @ param skp - the integer skillpoint count to be converted
* /
function skillPointsToPercentage ( skp ) {
2021-06-27 18:38:46 +00:00
if ( skp <= 0 ) {
2021-01-19 17:32:27 +00:00
return 0.0 ;
2021-06-27 18:38:46 +00:00
} else if ( skp >= 150 ) {
skp = 150 ;
}
const r = 0.9908 ;
2022-08-15 02:55:02 +00:00
return ( r / ( 1 - r ) * ( 1 - Math . pow ( r , skp ) ) ) / 100.0 ;
2021-06-27 18:38:46 +00:00
//return (-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771);
2021-01-19 17:32:27 +00:00
//return(-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771).toFixed(3);
2021-02-12 17:00:06 +00:00
//return Math.min(Math.max(0.00,(-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771)),.808);
2021-05-06 18:37:34 +00:00
//return clamp((-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771), 0.00, 0.808);
2021-01-19 17:32:27 +00:00
}
2022-07-06 03:40:32 +00:00
// WYNN2: Skillpoint max scaling. Intel is cost reduction
2022-07-07 22:33:00 +00:00
const skillpoint _final _mult = [ 1 , 1 , 0.5 / skillPointsToPercentage ( 150 ) , 0.867 , 0.951 ] ;
// intel water%
2022-07-06 03:40:32 +00:00
const skillpoint _damage _mult = [ 1 , 1 , 1 , 0.867 , 0.951 ] ;
2021-01-19 17:32:27 +00:00
/ * T u r n s t h e i n p u t a m o u n t o f l e v e l s i n t o s k i l l p o i n t s a v a i l a b l e .
*
2021-02-20 05:22:19 +00:00
* @ param level - the integer level count to be converted
2021-01-19 17:32:27 +00:00
* /
function levelToSkillPoints ( level ) {
if ( level < 1 ) {
return 0 ;
} else if ( level >= 101 ) {
return 200 ;
} else {
return ( level - 1 ) * 2 ;
}
}
/ * T u r n s t h e i n p u t a m o u n t o f l e v e l s i n t o b a s e H P .
* @ param level - the integer level count to be converted
* /
function levelToHPBase ( level ) {
if ( level < 1 ) { //bad level
return this . levelToHPBase ( 1 ) ;
} else if ( level > 106 ) { //also bad level
return this . levelToHPBase ( 106 ) ;
} else { //good level
return 5 * level + 5 ;
}
2021-05-06 18:37:34 +00:00
}
2021-06-20 02:32:19 +00:00
2021-07-27 10:04:12 +00:00
const skp _order = [ "str" , "dex" , "int" , "def" , "agi" ] ;
const skill = [ "Strength" , "Dexterity" , "Intelligence" , "Defense" , "Agility" ] ;
const skp _elements = [ "e" , "t" , "w" , "f" , "a" ] ;
const damageClasses = [ "Neutral" , "Earth" , "Thunder" , "Water" , "Fire" , "Air" ] ;
2021-06-20 02:32:19 +00:00
// Set up item lists for quick access later.
2021-07-27 10:04:12 +00:00
const armorTypes = [ "helmet" , "chestplate" , "leggings" , "boots" ] ;
const accessoryTypes = [ "ring" , "bracelet" , "necklace" ] ;
const weaponTypes = [ "wand" , "spear" , "bow" , "dagger" , "relik" ] ;
const consumableTypes = [ "potion" , "scroll" , "food" ] ;
2022-06-19 20:59:16 +00:00
const tome _types = [ 'weaponTome' , 'armorTome' , 'guildTome' ] ;
2021-06-20 02:32:19 +00:00
const attackSpeeds = [ "SUPER_SLOW" , "VERY_SLOW" , "SLOW" , "NORMAL" , "FAST" , "VERY_FAST" , "SUPER_FAST" ] ;
const baseDamageMultiplier = [ 0.51 , 0.83 , 1.5 , 2.05 , 2.5 , 3.1 , 4.3 ] ;
//0.51, 0.82, 1.50, 2.05, 2.50, 3.11, 4.27
const classes = [ "Warrior" , "Assassin" , "Mage" , "Archer" , "Shaman" ] ;
2022-06-16 00:07:54 +00:00
const wep _to _class = new Map ( [ [ "dagger" , "Assassin" ] , [ "spear" , "Warrior" ] , [ "wand" , "Mage" ] , [ "bow" , "Archer" ] , [ "relik" , "Shaman" ] ] )
2021-06-20 02:32:19 +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
2022-06-26 07:08:02 +00:00
const all _types = armorTypes . concat ( accessoryTypes ) . concat ( weaponTypes ) . concat ( consumableTypes ) . concat ( tome _types ) . map ( x => x . substring ( 0 , 1 ) . toUpperCase ( ) + x . substring ( 1 ) ) ;
2022-01-05 19:44:59 +00:00
//weaponTypes.push("sword");
//console.log(types)
2022-08-03 07:28:54 +00:00
let item _types = armorTypes . concat ( accessoryTypes ) . concat ( weaponTypes ) . concat ( tome _types ) ;
2021-06-20 02:32:19 +00:00
let elementIcons = [ "\u2724" , "\u2726" , "\u2749" , "\u2739" , "\u274b" ] ;
let skpReqs = skp _order . map ( x => x + "Req" ) ;
2022-06-24 10:35:03 +00:00
let item _fields = [ "name" , "displayName" , "lore" , "color" , "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" , "rSdRaw" , "sprint" , "sprintReg" , "jh" , "lq" , "gXp" , "gSpd" , "id" , "majorIds" , "damMobs" , "defMobs" ,
// wynn2 damages.
2022-07-08 05:28:46 +00:00
"eMdPct" , "eMdRaw" , "eSdPct" , "eSdRaw" , /*"eDamPct,"*/ "eDamRaw" , "eDamAddMin" , "eDamAddMax" ,
"tMdPct" , "tMdRaw" , "tSdPct" , "tSdRaw" , /*"tDamPct,"*/ "tDamRaw" , "tDamAddMin" , "tDamAddMax" ,
"wMdPct" , "wMdRaw" , "wSdPct" , "wSdRaw" , /*"wDamPct,"*/ "wDamRaw" , "wDamAddMin" , "wDamAddMax" ,
"fMdPct" , "fMdRaw" , "fSdPct" , "fSdRaw" , /*"fDamPct,"*/ "fDamRaw" , "fDamAddMin" , "fDamAddMax" ,
"aMdPct" , "aMdRaw" , "aSdPct" , "aSdRaw" , /*"aDamPct,"*/ "aDamRaw" , "aDamAddMin" , "aDamAddMax" ,
2022-06-24 10:35:03 +00:00
"nMdPct" , "nMdRaw" , "nSdPct" , "nSdRaw" , "nDamPct" , "nDamRaw" , "nDamAddMin" , "nDamAddMax" , // neutral which is now an element
/*"mdPct","mdRaw","sdPct","sdRaw",*/ "damPct" , "damRaw" , "damAddMin" , "damAddMax" , // These are the old ids. Become proportional.
2022-06-30 15:58:26 +00:00
"rMdPct" , "rMdRaw" , "rSdPct" , /*"rSdRaw",*/ "rDamPct" , "rDamRaw" , "rDamAddMin" , "rDamAddMax" , // rainbow (the "element" of all minus neutral). rSdRaw is rainraw
2022-08-13 04:39:24 +00:00
"critDamPct" ,
"spPct1Final" , "spPct2Final" , "spPct3Final" , "spPct4Final"
2022-06-24 10:35:03 +00:00
] ;
2022-07-08 05:28:46 +00:00
// Extra fake IDs (reserved for use in spell damage calculation) : damMult, defMult, poisonPct, activeMajorIDs
2021-07-19 21:04:56 +00:00
let str _item _fields = [ "name" , "displayName" , "lore" , "color" , "tier" , "set" , "type" , "material" , "drop" , "quest" , "restrict" , "category" , "atkSpd" ]
2021-06-20 02:32:19 +00:00
//File reading for ID translations for JSON purposes
let reversetranslations = new Map ( ) ;
2023-03-25 15:35:09 +00:00
let _translations _list = [ [ "name" , "name" ] , [ "displayName" , "displayName" ] , [ "tier" , "tier" ] , [ "set" , "set" ] , [ "sockets" , "slots" ] , [ "type" , "type" ] , [ "armorColor" , "color" ] , [ "addedLore" , "lore" ] , [ "dropType" , "drop" ] , [ "quest" , "quest" ] , [ "restrictions" , "restrict" ] , [ "damage" , "nDam" ] , [ "fireDamage" , "fDam" ] , [ "waterDamage" , "wDam" ] , [ "airDamage" , "aDam" ] , [ "thunderDamage" , "tDam" ] , [ "earthDamage" , "eDam" ] , [ "attackSpeed" , "atkSpd" ] , [ "health" , "hp" ] , [ "fireDefense" , "fDef" ] , [ "waterDefense" , "wDef" ] , [ "airDefense" , "aDef" ] , [ "thunderDefense" , "tDef" ] , [ "earthDefense" , "eDef" ] , [ "level" , "lvl" ] , [ "classRequirement" , "classReq" ] , [ "strength" , "strReq" ] , [ "dexterity" , "dexReq" ] , [ "intelligence" , "intReq" ] , [ "agility" , "agiReq" ] , [ "defense" , "defReq" ] , [ "healthRegen" , "hprPct" ] , [ "manaRegen" , "mr" ] , [ "spellDamageBonus" , "sdPct" ] , [ "spellElementalDamageBonus" , "rSdPct" ] , [ "spellNeutralDamageBonus" , "nSdPct" ] , [ "spellFireDamageBonus" , "fSdPct" ] , [ "spellWaterDamageBonus" , "wSdPct" ] , [ "spellAirDamageBonus" , "aSdPct" ] , [ "spellThunderDamageBonus" , "tSdPct" ] , [ "spellEarthDamageBonus" , "eSdPct" ] , [ "mainAttackDamageBonus" , "mdPct" ] , [ "mainAttackElementalDamageBonus" , "rMdPct" ] , [ "mainAttackNeutralDamageBonus" , "nMdPct" ] , [ "mainAttackFireDamageBonus" , "fMdPct" ] , [ "mainAttackWaterDamageBonus" , "wMdPct" ] , [ "mainAttackAirDamageBonus" , "aMdPct" ] , [ "mainAttackThunderDamageBonus" , "tMdPct" ] , [ "mainAttackEarthDamageBonus" , "eMdPct" ] , [ "lifeSteal" , "ls" ] , [ "manaSteal" , "ms" ] , [ "xpBonus" , "xpb" ] , [ "lootBonus" , "lb" ] , [ "reflection" , "ref" ] , [ "strengthPoints" , "str" ] , [ "dexterityPoints" , "dex" ] , [ "intelligencePoints" , "int" ] , [ "agilityPoints" , "agi" ] , [ "defensePoints" , "def" ] , [ "thorns" , "thorns" ] , [ "exploding" , "expd" ] , [ "speed" , "spd" ] , [ "attackSpeedBonus" , "atkTier" ] , [ "poison" , "poison" ] , [ "healthBonus" , "hpBonus" ] , [ "soulPoints" , "spRegen" ] , [ "emeraldStealing" , "eSteal" ] , [ "healthRegenRaw" , "hprRaw" ] , [ "spellDamageBonusRaw" , "sdRaw" ] , [ "spellElementalDamageBonusRaw" , "rSdRaw" ] , [ "spellNeutralDamageBonusRaw" , "nSdRaw" ] , [ "spellFireDamageBonusRaw" , "fSdRaw" ] , [ "spellWaterDamageBonusRaw" , "wSdRaw" ] , [ "spellAirDamageBonusRaw" , "aSdRaw" ] , [ "spellThunderDamageBonusRaw" , "tSdRaw" ] , [ "spellEarthDamageBonusRaw" , "eSdRaw" ] , [ "mainAttackDamageBonusRaw" , "mdRaw" ] , [ "mainAttackElementalDamageBonusRaw" , "rMdRaw" ] , [ "mainAttackNeutralDamageBonusRaw" , "nMdRaw" ] , [ "mainAttackFireDamageBonusRaw" , "fMdRaw" ] , [ "mainAttackWaterDamageBonusRaw" , "wMdRaw" ] , [ "mainAttackAirDamageBonusRaw" , "aMdRaw" ] , [ "mainAttackThunderDamageBonusRaw" , "tMdRaw" ] , [ "mainAttackEarthDamageBonusRaw" , "eMdRaw" ] , [ "fireDamageBonus" , "fDamPct" ] , [ "waterDamageBonus" , "wDamPct" ] , [ "airDamageBonus" , "aDamPct" ] , [ "thunderDamageBonus" , "tDamPct" ] , [ "earthDamageBonus" , "eDamPct" ] , [ "bonusFireDefense" , "fDefPct" ] , [ "bonusWaterDefense" , "wDefPct" ] , [ "bonusAirDefense" , "aDefPct" ] , [ "bonusThunderDefense" , "tDefPct" ] , [ "bonusEarthDefense" , "eDefPct" ] , [ "accessoryType" , "type" ] , [ "identified" , "fixID" ] , [ "skin" , "skin" ] , [ "category" , "category" ] , [ "spellCostPct1" , "spPct1" ] , [ "spellCostRaw1" , "spRaw1" ] , [ "spellCostPct2" , "spPct2" ] , [ "spellCostRaw2" , "spRaw2" ] , [ "spellCostPct3" , "spPct3" ] , [ "spellCostRaw3" , "spRaw3" ] , [ "spellCostPct4" , "spPct4" ] , [ "spellCostRaw4" , "spRaw4" ] , [ "sprint" , "sprint" ] , [ "sprintRegen" , "sprintReg" ] , [ "jumpHeight" , "jh" ] , [ "lootQuality" , "lq" ] , [ "gatherXpBonus" , "gXp" ] , [ "gatherSpeed" , "gSpd" ] ] ;
let translations = new Map ( _translations _list ) ;
2022-09-22 23:50:29 +00:00
2022-06-26 11:08:54 +00:00
//does not include damMobs (wep tomes) and defMobs (armor tomes)
2023-03-25 15:35:09 +00:00
for ( const [ k , v ] of _translations _list ) {
if ( reversetranslations . has ( v ) ) { continue ; }
2021-06-20 02:32:19 +00:00
reversetranslations . set ( v , k ) ;
}
2022-05-22 07:14:20 +00:00
let nonRolledIDs = [
"name" ,
"lore" ,
"displayName" ,
"tier" ,
"set" ,
"slots" ,
"type" ,
"material" ,
"drop" ,
"quest" ,
"restrict" ,
"nDam" , "fDam" , "wDam" , "aDam" , "tDam" , "eDam" ,
"atkSpd" ,
"hp" ,
"fDef" , "wDef" , "aDef" , "tDef" , "eDef" ,
"lvl" ,
"classReq" ,
"strReq" , "dexReq" , "intReq" , "defReq" , "agiReq" ,
"str" , "dex" , "int" , "agi" , "def" ,
"fixID" ,
"category" ,
"id" ,
"skillpoints" ,
"reqs" ,
"nDam_" , "fDam_" , "wDam_" , "aDam_" , "tDam_" , "eDam_" ,
2022-06-24 10:35:03 +00:00
"majorIds" ,
2022-06-26 11:08:54 +00:00
"damMobs" ,
2022-08-13 04:39:24 +00:00
"defMobs"
2022-06-24 10:35:03 +00:00
] ;
2022-05-22 07:14:20 +00:00
let rolledIDs = [
"hprPct" ,
"mr" ,
"sdPct" ,
"mdPct" ,
"ls" ,
"ms" ,
"xpb" ,
"lb" ,
"ref" ,
"thorns" ,
"expd" ,
"spd" ,
"atkTier" ,
"poison" ,
"hpBonus" ,
"spRegen" ,
"eSteal" ,
"hprRaw" ,
"sdRaw" ,
"mdRaw" ,
"fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" ,
"fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" ,
"spPct1" , "spRaw1" ,
"spPct2" , "spRaw2" ,
"spPct3" , "spRaw3" ,
"spPct4" , "spRaw4" ,
2022-08-09 19:50:07 +00:00
"rSdRaw" ,
2022-05-22 07:14:20 +00:00
"sprint" ,
"sprintReg" ,
"jh" ,
"lq" ,
"gXp" ,
2022-06-24 10:35:03 +00:00
"gSpd" ,
// wynn2 damages.
2022-07-08 05:28:46 +00:00
"eMdPct" , "eMdRaw" , "eSdPct" , "eSdRaw" , /*"eDamPct,"*/ "eDamRaw" , "eDamAddMin" , "eDamAddMax" ,
"tMdPct" , "tMdRaw" , "tSdPct" , "tSdRaw" , /*"tDamPct,"*/ "tDamRaw" , "tDamAddMin" , "tDamAddMax" ,
"wMdPct" , "wMdRaw" , "wSdPct" , "wSdRaw" , /*"wDamPct,"*/ "wDamRaw" , "wDamAddMin" , "wDamAddMax" ,
"fMdPct" , "fMdRaw" , "fSdPct" , "fSdRaw" , /*"fDamPct,"*/ "fDamRaw" , "fDamAddMin" , "fDamAddMax" ,
"aMdPct" , "aMdRaw" , "aSdPct" , "aSdRaw" , /*"aDamPct,"*/ "aDamRaw" , "aDamAddMin" , "aDamAddMax" ,
2022-06-24 10:35:03 +00:00
"nMdPct" , "nMdRaw" , "nSdPct" , "nSdRaw" , "nDamPct" , "nDamRaw" , "nDamAddMin" , "nDamAddMax" , // neutral which is now an element
/*"mdPct","mdRaw","sdPct","sdRaw",*/ "damPct" , "damRaw" , "damAddMin" , "damAddMax" , // These are the old ids. Become proportional.
2022-08-13 04:39:24 +00:00
"rMdPct" , "rMdRaw" , "rSdPct" , /*"rSdRaw",*/ "rDamPct" , "rDamRaw" , "rDamAddMin" , "rDamAddMax" , // rainbow (the "element" of all minus neutral). rSdRaw is rainraw
"spPct1Final" , "spPct2Final" , "spPct3Final" , "spPct4Final"
2022-05-22 07:14:20 +00:00
] ;
2022-05-22 07:57:47 +00:00
let reversedIDs = [ "spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" ] ;
2022-05-22 07:14:20 +00:00
2023-01-31 02:55:25 +00:00
let ingFields = [ "fDefPct" , "wDefPct" , "aDefPct" , "tDefPct" , "eDefPct" , "hprPct" , "mr" , "sdPct" , "mdPct" , "ls" , "ms" , "xpb" , "lb" , "lq" , "ref" , "str" , "dex" , "int" , "agi" , "def" , "thorns" , "expd" , "spd" , "atkTier" , "poison" , "hpBonus" , "spRegen" , "eSteal" , "hprRaw" , "sdRaw" , "mdRaw" , "fDamPct" , "wDamPct" , "aDamPct" , "tDamPct" , "eDamPct" , "spPct1" , "spRaw1" , "spPct2" , "spRaw2" , "spPct3" , "spRaw3" , "spPct4" , "spRaw4" , "jh" , "sprint" , "sprintReg" , "gXp" , "gSpd" ] ;
2022-05-22 07:14:20 +00:00
/ * *
* Take an item with id list and turn it into a set of minrolls and maxrolls .
* /
function expandItem ( item ) {
let minRolls = new Map ( ) ;
let maxRolls = new Map ( ) ;
let expandedItem = new Map ( ) ;
if ( item . fixID ) { //The item has fixed IDs.
expandedItem . set ( "fixID" , true ) ;
for ( const id of rolledIDs ) { //all rolled IDs are numerical
let val = ( item [ id ] || 0 ) ;
minRolls . set ( id , val ) ;
maxRolls . set ( id , val ) ;
}
} else { //The item does not have fixed IDs.
for ( const id of rolledIDs ) {
let val = ( item [ id ] || 0 ) ;
if ( val > 0 ) { // positive rolled IDs
if ( reversedIDs . includes ( id ) ) {
2022-11-15 21:11:38 +00:00
maxRolls . set ( id , idRound ( val * 0.7 ) ) ;
2022-05-22 07:14:20 +00:00
minRolls . set ( id , idRound ( val * 1.3 ) ) ;
} else {
maxRolls . set ( id , idRound ( val * 1.3 ) ) ;
minRolls . set ( id , idRound ( val * 0.3 ) ) ;
}
} else if ( val < 0 ) { //negative rolled IDs
if ( reversedIDs . includes ( id ) ) {
maxRolls . set ( id , idRound ( val * 1.3 ) ) ;
2022-11-15 21:11:38 +00:00
minRolls . set ( id , idRound ( val * 0.3 ) ) ;
2022-05-22 07:14:20 +00:00
}
else {
maxRolls . set ( id , idRound ( val * 0.7 ) ) ;
minRolls . set ( id , idRound ( val * 1.3 ) ) ;
}
}
else { // if val == 0
// NOTE: DO NOT remove this case! idRound behavior does not round to 0!
maxRolls . set ( id , 0 ) ;
minRolls . set ( id , 0 ) ;
}
}
}
for ( const id of nonRolledIDs ) {
expandedItem . set ( id , item [ id ] ) ;
}
expandedItem . set ( "minRolls" , minRolls ) ;
expandedItem . set ( "maxRolls" , maxRolls ) ;
return expandedItem ;
}
class Item {
2022-07-29 05:48:01 +00:00
constructor ( item _obj = null ) {
if ( item _obj ) { this . statMap = expandItem ( item _obj ) ; }
else { this . statMap = new Map ( ) ; }
}
copy ( ) {
const ret = new Item ( ) ;
ret . statMap = new Map ( this . statMap ) ;
return ret ;
2022-05-22 07:14:20 +00:00
}
}
2022-06-19 18:02:28 +00:00
/ * T a k e s i n a n i n g r e d i e n t o b j e c t a n d r e t u r n s a n e q u i v a l e n t M a p ( ) .
* /
function expandIngredient ( ing ) {
let expandedIng = new Map ( ) ;
let mapIds = [ 'consumableIDs' , 'itemIDs' , 'posMods' ] ;
for ( const id of mapIds ) {
let idMap = new Map ( ) ;
for ( const key of Object . keys ( ing [ id ] ) ) {
idMap . set ( key , ing [ id ] [ key ] ) ;
}
expandedIng . set ( id , idMap ) ;
}
let normIds = [ 'lvl' , 'name' , 'displayName' , 'tier' , 'skills' , 'id' ] ;
for ( const id of normIds ) {
expandedIng . set ( id , ing [ id ] ) ;
}
if ( ing [ 'isPowder' ] ) {
expandedIng . set ( "isPowder" , ing [ 'isPowder' ] ) ;
expandedIng . set ( "pid" , ing [ 'pid' ] ) ;
}
//now the actually hard one
let idMap = new Map ( ) ;
idMap . set ( "minRolls" , new Map ( ) ) ;
idMap . set ( "maxRolls" , new Map ( ) ) ;
for ( const field of ingFields ) {
let val = ( ing [ 'ids' ] [ field ] || 0 ) ;
idMap . get ( "minRolls" ) . set ( field , val [ 'minimum' ] ) ;
idMap . get ( "maxRolls" ) . set ( field , val [ 'maximum' ] ) ;
}
expandedIng . set ( "ids" , idMap ) ;
return expandedIng ;
}
/ * T a k e s i n a r e c i p e o b j e c t a n d r e t u r n s a n e q u i v a l e n t M a p ( ) .
* /
function expandRecipe ( recipe ) {
let expandedRecipe = new Map ( ) ;
let normIDs = [ "name" , "skill" , "type" , "id" ] ;
for ( const id of normIDs ) {
expandedRecipe . set ( id , recipe [ id ] ) ;
}
let rangeIDs = [ "durability" , "lvl" , "healthOrDamage" , "duration" , "basicDuration" ] ;
for ( const id of rangeIDs ) {
if ( recipe [ id ] ) {
expandedRecipe . set ( id , [ recipe [ id ] [ 'minimum' ] , recipe [ id ] [ 'maximum' ] ] ) ;
} else {
expandedRecipe . set ( id , [ 0 , 0 ] ) ;
}
}
expandedRecipe . set ( "materials" , [ new Map ( [ [ "item" , recipe [ 'materials' ] [ 0 ] [ 'item' ] ] , [ "amount" , recipe [ 'materials' ] [ 0 ] [ 'amount' ] ] ] ) , new Map ( [ [ "item" , recipe [ 'materials' ] [ 1 ] [ 'item' ] ] , [ "amount" , recipe [ 'materials' ] [ 1 ] [ 'amount' ] ] ] ) ] ) ;
return expandedRecipe ;
}
/ * A n i n d e p e n d e n t h e l p e r f u n c t i o n t h a t r o u n d s a r o l l e d I D t o t h e n e a r e s t i n t e g e r O R b r i n g s t h e r o l l a w a y f r o m 0 .
* @ param id
* /
function idRound ( id ) {
rounded = Math . round ( id ) ;
if ( rounded == 0 ) {
2023-02-17 11:40:23 +00:00
return Math . sign ( id ) ; //this is a hack, will need changing along w/ rest of ID system if anything changes
2022-06-19 18:02:28 +00:00
} else {
return rounded ;
}
}
2022-07-08 02:44:57 +00:00
/ * *
* stupid stupid multiplicative stats
* /
function merge _stat ( stats , name , value ) {
2022-07-08 05:28:46 +00:00
const start = name . slice ( 0 , 7 ) ;
if ( start === 'damMult' || start === 'defMult' ) {
if ( ! stats . has ( start ) ) {
stats . set ( start , new Map ( ) ) ;
}
const map = stats . get ( start ) ;
if ( value instanceof Map ) {
for ( const [ k , v ] of value . entries ( ) ) {
merge _stat ( map , k , v ) ;
}
return ;
2022-07-08 02:44:57 +00:00
}
2022-07-08 05:28:46 +00:00
merge _stat ( map , name . slice ( 8 ) , value ) ;
return ;
}
if ( stats . has ( name ) ) {
stats . set ( name , stats . get ( name ) + value ) ;
2022-07-08 02:44:57 +00:00
}
else { stats . set ( name , value ) ; }
}