[V14] 1604 - ActiveEffect Durations (#1634)

* Added daggerheart durations and auto expiration of them

* Added duration to all tier1 adversaries

* Finished all adversaries and environments

* Remaining compendiums updated

* Improved styling of duration in tooltips

* .
This commit is contained in:
WBHarry 2026-02-17 18:57:03 +01:00 committed by GitHub
parent e2eb31c12e
commit 4aab5d315a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
120 changed files with 2514 additions and 1256 deletions

View file

@ -473,6 +473,8 @@ export async function waitForDiceSoNice(message) {
}
export function refreshIsAllowed(allowedTypes, typeToCheck) {
if (!allowedTypes) return true;
switch (typeToCheck) {
case CONFIG.DH.GENERAL.refreshTypes.scene.id:
case CONFIG.DH.GENERAL.refreshTypes.session.id:
@ -489,6 +491,34 @@ export function refreshIsAllowed(allowedTypes, typeToCheck) {
}
}
function expireActiveEffectIsAllowed(allowedTypes, typeToCheck) {
if (typeToCheck === CONFIG.DH.GENERAL.activeEffectDurations.act.id) return true;
return refreshIsAllowed(allowedTypes, typeToCheck);
}
export function expireActiveEffects(actor, allowedTypes = null) {
const shouldExpireEffects = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.Automation
).autoExpireActiveEffects;
if (!shouldExpireEffects) return;
const effectsToExpire = actor
.getActiveEffects()
.filter(effect => {
if (!effect.system?.duration.type) return false;
const { temporary, custom } = CONFIG.DH.GENERAL.activeEffectDurations;
if ([temporary.id, custom.id].includes(effect.system.duration.type)) return false;
return expireActiveEffectIsAllowed(allowedTypes, effect.system.duration.type);
})
.map(x => x.id);
actor.deleteEmbeddedDocuments('ActiveEffect', effectsToExpire);
}
export async function getCritDamageBonus(formula) {
const critRoll = new Roll(formula);
return critRoll.dice.reduce((acc, dice) => acc + dice.faces * dice.number, 0);
@ -503,6 +533,8 @@ export function htmlToText(html) {
export function getIconVisibleActiveEffects(effects) {
return effects.filter(effect => {
if (!(effect instanceof game.system.api.documents.DhActiveEffect)) return true;
const alwaysShown = effect.showIcon === CONST.ACTIVE_EFFECT_SHOW_ICON.ALWAYS;
const conditionalShown = effect.showIcon === CONST.ACTIVE_EFFECT_SHOW_ICON.CONDITIONAL && !effect.transfer; // TODO: system specific logic