fix accessing parsed roll info, when it's actually a flag stat

This commit is contained in:
Alexander Drozdov committed 2026-08-26 01:02:49 +03:00
1 parent d4dd07a194
commit bc4e1d0e7a
1 file changed
+4 -4
+4 -4
View File
@@ -72,6 +72,7 @@ export function statSourcesTotal (
return (sources.length === 1)
? (sources[0].contributes)
: (sources.reduce((sum, { contributes }) => {
// NOTE: this also sums up stats that have "flag" semantics
contributes = contributes ?? { value: 1, min: 1, max: 1 }
sum.value = fn(sum.value, contributes.value)
sum.min = fn(sum.min, contributes.min)
@@ -98,15 +99,14 @@ export function translateStatWithRoll (
: matchers.find(m => m.value == null && !m.negate)
}
if (!translation) {
translation =
matchers.find(m => m.value == null) ??
{ string: `BUG_STAT_ID: ${calc.stat.ref}` }
translation = matchers.find(m => m.value == null)
if (!translation) throw new Error('never')
}
}
const dp = (roll)
? calc.stat.dp ||
calc.sources.some(s => s.stat.stat.ref === calc.stat.ref && s.stat.roll!.dp)
calc.sources.some(s => s.stat.stat.ref === calc.stat.ref && s.stat.roll?.dp)
: undefined
return { string: translation.string, negate: translation.negate || false, dp: dp }