mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed so active effects can handle expressions again (#368)
This commit is contained in:
parent
6e87e4dad0
commit
1d75b08087
3 changed files with 19 additions and 18 deletions
|
|
@ -55,10 +55,24 @@ export default class DhActiveEffect extends ActiveEffect {
|
|||
}
|
||||
|
||||
static applyField(model, change, field) {
|
||||
change.value = itemAbleRollParse(change.value, model, change.effect.parent);
|
||||
change.value = this.effectSafeEval(itemAbleRollParse(change.value, model, change.effect.parent));
|
||||
super.applyField(model, change, field);
|
||||
}
|
||||
|
||||
/* Altered Foundry safeEval to allow non-numeric returns */
|
||||
static effectSafeEval(expression) {
|
||||
let result;
|
||||
try {
|
||||
// eslint-disable-next-line no-new-func
|
||||
const evl = new Function('sandbox', `with (sandbox) { return ${expression}}`);
|
||||
result = evl(Roll.MATH_PROXY);
|
||||
} catch (err) {
|
||||
return expression;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async toChat(origin) {
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const systemData = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue