ds4/src/module/active-effect.ts

32 lines
895 B
TypeScript
Raw Normal View History

// 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);
}
/**
* A public wrapper for {@link ActiveEffect#_getSourceName}.
*/
async getSourceName(): Promise<string> {
return this._getSourceName();
}
}