This commit is contained in:
WBHarry 2025-07-27 21:07:10 +02:00
parent f5a4d8cf94
commit 5d6fac39fe
2 changed files with 16 additions and 4 deletions

View file

@ -35,7 +35,13 @@ export default class FormulaField extends foundry.data.fields.StringField {
/** @inheritDoc */
_validateType(value) {
const roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, '1'));
/* A bit suss, but seems to work */
let roll = null;
try {
roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, '1'));
} catch (_) {
roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, 'd6'));
}
roll.evaluateSync({ strict: false });
if (this.options.deterministic && !roll.isDeterministic)
throw new Error(`must not contain dice terms: ${value}`);