fix(tooltip): guard partial unique/set/rare/magic/runeword props arrays in formatItemTooltip (Fixes #504)
This commit is contained in:
parent
a05c97c438
commit
8d455a099e
|
|
@ -2021,7 +2021,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
if (uniqDef.levelreq > 0) affixReqLevel = Math.max(affixReqLevel, uniqDef.levelreq)
|
||||
if (item.rolledProps && item.rolledProps.length > 0) {
|
||||
rawProps.push(...item.rolledProps)
|
||||
} else {
|
||||
} else if (Array.isArray(uniqDef.props)) {
|
||||
for (const prop of uniqDef.props) {
|
||||
if (prop.code) {
|
||||
rawProps.push({
|
||||
|
|
@ -2057,7 +2057,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
if (setDef.levelreq > 0) affixReqLevel = Math.max(affixReqLevel, setDef.levelreq)
|
||||
if (item.rolledProps && item.rolledProps.length > 0) {
|
||||
rawProps.push(...item.rolledProps)
|
||||
} else {
|
||||
} else if (Array.isArray(setDef.props)) {
|
||||
for (const prop of setDef.props) {
|
||||
if (prop.code) {
|
||||
rawProps.push({
|
||||
|
|
@ -2094,7 +2094,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
title = enName
|
||||
subTitle = baseNameEn
|
||||
}
|
||||
if (rareDef && rareDef.affixes) {
|
||||
if (rareDef && Array.isArray(rareDef.affixes)) {
|
||||
for (const aff of rareDef.affixes) {
|
||||
const effReq = getAffixEffectiveLevelReq(aff, itemClass)
|
||||
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
||||
|
|
@ -2111,17 +2111,19 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
value: p.value,
|
||||
})
|
||||
}
|
||||
} else if (rareDef && rareDef.affixes) {
|
||||
} else if (rareDef && Array.isArray(rareDef.affixes)) {
|
||||
for (const aff of rareDef.affixes) {
|
||||
for (const mod of aff.mods) {
|
||||
const keepRange = NON_RANDOM_RANGE_CODES.has(mod.code.toLowerCase()) || (mod.min === 0 && mod.max === 0)
|
||||
rawProps.push({
|
||||
code: mod.code,
|
||||
param: mod.param,
|
||||
min: keepRange ? mod.min : mod.value,
|
||||
max: keepRange ? mod.max : mod.value,
|
||||
value: mod.value,
|
||||
})
|
||||
if (Array.isArray(aff.mods)) {
|
||||
for (const mod of aff.mods) {
|
||||
const keepRange = NON_RANDOM_RANGE_CODES.has(mod.code.toLowerCase()) || (mod.min === 0 && mod.max === 0)
|
||||
rawProps.push({
|
||||
code: mod.code,
|
||||
param: mod.param,
|
||||
min: keepRange ? mod.min : mod.value,
|
||||
max: keepRange ? mod.max : mod.value,
|
||||
value: mod.value,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2157,7 +2159,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
const effReq = getAffixEffectiveLevelReq(magicDef.suffix, itemClass)
|
||||
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
||||
}
|
||||
if (magicDef.affixes) {
|
||||
if (Array.isArray(magicDef.affixes)) {
|
||||
for (const aff of magicDef.affixes) {
|
||||
const effReq = getAffixEffectiveLevelReq(aff, itemClass)
|
||||
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
||||
|
|
@ -2176,7 +2178,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
})
|
||||
}
|
||||
} else if (magicDef) {
|
||||
if (magicDef.prefix) {
|
||||
if (magicDef.prefix && Array.isArray(magicDef.prefix.mods)) {
|
||||
for (const m of magicDef.prefix.mods) {
|
||||
const keepRange = NON_RANDOM_RANGE_CODES.has(m.code.toLowerCase()) || (m.min === 0 && m.max === 0)
|
||||
rawProps.push({
|
||||
|
|
@ -2188,7 +2190,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
})
|
||||
}
|
||||
}
|
||||
if (magicDef.suffix) {
|
||||
if (magicDef.suffix && Array.isArray(magicDef.suffix.mods)) {
|
||||
for (const m of magicDef.suffix.mods) {
|
||||
const keepRange = NON_RANDOM_RANGE_CODES.has(m.code.toLowerCase()) || (m.min === 0 && m.max === 0)
|
||||
rawProps.push({
|
||||
|
|
@ -2288,7 +2290,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
|||
}
|
||||
if (item.rolledProps && item.rolledProps.length > 0) {
|
||||
rawProps.push(...item.rolledProps)
|
||||
} else if ((item as any).runeword?.props) {
|
||||
} else if (Array.isArray((item as any).runeword?.props)) {
|
||||
for (const prop of (item as any).runeword.props) {
|
||||
if (prop.code) {
|
||||
rawProps.push({
|
||||
|
|
|
|||
Loading…
Reference in New Issue