25 lines
724 B
TypeScript
25 lines
724 B
TypeScript
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||
|
//
|
||
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
|
import { DS4Actor } from "./actor/actor";
|
||
|
|
||
|
declare global {
|
||
|
interface DocumentClassConfig {
|
||
|
ActiveEffect: typeof DS4ActiveEffect;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export class DS4ActiveEffect extends ActiveEffect {
|
||
|
/** @override */
|
||
|
apply(actor: DS4Actor, change: foundry.data.ActiveEffectData["changes"][number]): unknown {
|
||
|
change.value = Roll.replaceFormulaData(change.value, actor.data);
|
||
|
try {
|
||
|
change.value = Roll.safeEval(change.value).toString();
|
||
|
} catch (e) {
|
||
|
// this is a valid case, e.g., if the effect change simply is a string
|
||
|
}
|
||
|
return super.apply(actor, change);
|
||
|
}
|
||
|
}
|