2021-07-13 02:03:10 +02:00
|
|
|
// 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);
|
|
|
|
}
|
2021-07-20 02:35:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A public wrapper for {@link ActiveEffect#_getSourceName}.
|
|
|
|
*/
|
|
|
|
async getSourceName(): Promise<string> {
|
|
|
|
return this._getSourceName();
|
|
|
|
}
|
2021-07-13 02:03:10 +02:00
|
|
|
}
|