mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-08 06:56:12 +01:00
Added daggerheart durations and auto expiration of them
This commit is contained in:
parent
115a31423e
commit
0ba17117ea
14 changed files with 183 additions and 42 deletions
|
|
@ -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,28 @@ export function 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 refreshIsAllowed(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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue