Merge branch 'automated-exhausted-condition' into 'dev'

Automated exhausted condition

See merge request teaml5r/l5r5e!44
This commit is contained in:
Vlyan
2025-09-05 08:34:20 +00:00
committed by GitLab
3 changed files with 21 additions and 1 deletions

View File

@@ -188,6 +188,21 @@ export class ActorL5r5e extends Actor {
return this._updateActorFromAdvancement(item, false);
}
/**
* @type {import("./types").Condition}
*
* Remove conditions by known string ids
* @param conditions {Set<Condition>}
* @returns {Promise<void>}
*/
async removeConditions(conditions) {
const effectsToRemove = this.statuses.intersection(conditions);
const idsToRemove = this.effects.contents
.filter(effect => effect.statuses.isSubsetOf(effectsToRemove))
.map(effect => effect.id);
await this.deleteEmbeddedDocuments("ActiveEffect", idsToRemove);
}
/**
* Alter Actor skill/ring from a advancement
* @param {Item} item

View File

@@ -205,6 +205,7 @@ export class GmToolbox extends HandlebarsApplicationMixin(ApplicationV2) {
}
},
});
await actor.removeConditions(new Set(["exhausted"]));
}
GmToolbox.#uiNotification(allActors, "sleep");
@@ -216,7 +217,8 @@ export class GmToolbox extends HandlebarsApplicationMixin(ApplicationV2) {
static async #onSceneEnd(event) {
const allActors = event.button !== 0;
for await (const actor of game.actors.contents) {
if (!GmToolbox.#updatableCharacter(allActors, actor)) {
if (!GmToolbox.#updatableCharacter(allActors, actor)
|| actor.statuses.has("exhausted")) {
continue;
}

3
system/scripts/types.js Normal file
View File

@@ -0,0 +1,3 @@
/**
* @typedef {"afflicted" | "bleeding" | "burning" | "compromised" | "dazed" | "disoriented" | "dying" | "enraged" | "exhausted" | "immobilized" | "incapacitated" | "intoxicated" | "prone" | "silenced" | "unconscious" | "lightlyWoundedFire" | "lightlyWoundedWater" | "lightlyWoundedAir" | "lightlyWoundedEarth" | "lightlyWoundedVoid" | "severelyWoundedFire" | "severelyWoundedWater" | "severelyWoundedAir" | "severelyWoundedEarth" | "severelyWoundedVoid"} Condition
*/