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 (uniqDef.levelreq > 0) affixReqLevel = Math.max(affixReqLevel, uniqDef.levelreq)
|
||||||
if (item.rolledProps && item.rolledProps.length > 0) {
|
if (item.rolledProps && item.rolledProps.length > 0) {
|
||||||
rawProps.push(...item.rolledProps)
|
rawProps.push(...item.rolledProps)
|
||||||
} else {
|
} else if (Array.isArray(uniqDef.props)) {
|
||||||
for (const prop of uniqDef.props) {
|
for (const prop of uniqDef.props) {
|
||||||
if (prop.code) {
|
if (prop.code) {
|
||||||
rawProps.push({
|
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 (setDef.levelreq > 0) affixReqLevel = Math.max(affixReqLevel, setDef.levelreq)
|
||||||
if (item.rolledProps && item.rolledProps.length > 0) {
|
if (item.rolledProps && item.rolledProps.length > 0) {
|
||||||
rawProps.push(...item.rolledProps)
|
rawProps.push(...item.rolledProps)
|
||||||
} else {
|
} else if (Array.isArray(setDef.props)) {
|
||||||
for (const prop of setDef.props) {
|
for (const prop of setDef.props) {
|
||||||
if (prop.code) {
|
if (prop.code) {
|
||||||
rawProps.push({
|
rawProps.push({
|
||||||
|
|
@ -2094,7 +2094,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
||||||
title = enName
|
title = enName
|
||||||
subTitle = baseNameEn
|
subTitle = baseNameEn
|
||||||
}
|
}
|
||||||
if (rareDef && rareDef.affixes) {
|
if (rareDef && Array.isArray(rareDef.affixes)) {
|
||||||
for (const aff of rareDef.affixes) {
|
for (const aff of rareDef.affixes) {
|
||||||
const effReq = getAffixEffectiveLevelReq(aff, itemClass)
|
const effReq = getAffixEffectiveLevelReq(aff, itemClass)
|
||||||
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
||||||
|
|
@ -2111,8 +2111,9 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
||||||
value: p.value,
|
value: p.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (rareDef && rareDef.affixes) {
|
} else if (rareDef && Array.isArray(rareDef.affixes)) {
|
||||||
for (const aff of rareDef.affixes) {
|
for (const aff of rareDef.affixes) {
|
||||||
|
if (Array.isArray(aff.mods)) {
|
||||||
for (const mod of aff.mods) {
|
for (const mod of aff.mods) {
|
||||||
const keepRange = NON_RANDOM_RANGE_CODES.has(mod.code.toLowerCase()) || (mod.min === 0 && mod.max === 0)
|
const keepRange = NON_RANDOM_RANGE_CODES.has(mod.code.toLowerCase()) || (mod.min === 0 && mod.max === 0)
|
||||||
rawProps.push({
|
rawProps.push({
|
||||||
|
|
@ -2125,6 +2126,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (quality === 'magic') {
|
} else if (quality === 'magic') {
|
||||||
qualityColor = '#4880ff'
|
qualityColor = '#4880ff'
|
||||||
const magicDef = item.rolledMagicAffixes as GeneratedAffixes | undefined
|
const magicDef = item.rolledMagicAffixes as GeneratedAffixes | undefined
|
||||||
|
|
@ -2157,7 +2159,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
||||||
const effReq = getAffixEffectiveLevelReq(magicDef.suffix, itemClass)
|
const effReq = getAffixEffectiveLevelReq(magicDef.suffix, itemClass)
|
||||||
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
||||||
}
|
}
|
||||||
if (magicDef.affixes) {
|
if (Array.isArray(magicDef.affixes)) {
|
||||||
for (const aff of magicDef.affixes) {
|
for (const aff of magicDef.affixes) {
|
||||||
const effReq = getAffixEffectiveLevelReq(aff, itemClass)
|
const effReq = getAffixEffectiveLevelReq(aff, itemClass)
|
||||||
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
if (effReq > 0) affixReqLevel = Math.max(affixReqLevel, effReq)
|
||||||
|
|
@ -2176,7 +2178,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (magicDef) {
|
} else if (magicDef) {
|
||||||
if (magicDef.prefix) {
|
if (magicDef.prefix && Array.isArray(magicDef.prefix.mods)) {
|
||||||
for (const m of 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)
|
const keepRange = NON_RANDOM_RANGE_CODES.has(m.code.toLowerCase()) || (m.min === 0 && m.max === 0)
|
||||||
rawProps.push({
|
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) {
|
for (const m of magicDef.suffix.mods) {
|
||||||
const keepRange = NON_RANDOM_RANGE_CODES.has(m.code.toLowerCase()) || (m.min === 0 && m.max === 0)
|
const keepRange = NON_RANDOM_RANGE_CODES.has(m.code.toLowerCase()) || (m.min === 0 && m.max === 0)
|
||||||
rawProps.push({
|
rawProps.push({
|
||||||
|
|
@ -2288,7 +2290,7 @@ export function formatItemTooltip(item: Item, locale: TooltipLocale = getTooltip
|
||||||
}
|
}
|
||||||
if (item.rolledProps && item.rolledProps.length > 0) {
|
if (item.rolledProps && item.rolledProps.length > 0) {
|
||||||
rawProps.push(...item.rolledProps)
|
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) {
|
for (const prop of (item as any).runeword.props) {
|
||||||
if (prop.code) {
|
if (prop.code) {
|
||||||
rawProps.push({
|
rawProps.push({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue