Gestion des signes draconiques #455
@ -37,11 +37,15 @@ import { Monnaie } from "./item-monnaie.js";
|
||||
export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
static init() {
|
||||
Hooks.on("deleteActiveEffect", (actor, effect, options) => actor.onDeleteActiveEffect(effect, options));
|
||||
Hooks.on("createActiveEffect", (actor, effect, options) => actor.onCreateActiveEffect(effect, options));
|
||||
Hooks.on("deleteActiveEffect", (effect, options, userId) => RdDActor.getParentActor(effect)?.onDeleteActiveEffect(effect, options));
|
||||
Hooks.on("createOwnedItem", (actor, item, options, id) => actor.onCreateOwnedItem(item, options, id));
|
||||
Hooks.on("deleteOwnedItem", (actor, item, options, id) => actor.onDeleteOwnedItem(item, options, id));
|
||||
Hooks.on("updateActor", (actor, update, options, actorId) => actor.onUpdateActor(update, options, actorId));
|
||||
Hooks.on("createActiveEffect", (effect, options, userId) => RdDActor.getParentActor(effect)?.onCreateActiveEffect(effect, options));
|
||||
}
|
||||
|
||||
static getParentActor(document){
|
||||
return document?.parent instanceof Actor ? document.parent : undefined
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -3076,11 +3080,12 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setStatusDemiReve(status) {
|
||||
const demiReve = StatusEffects.demiReve();
|
||||
if (status) {
|
||||
await this.addStatusEffect(StatusEffects.demiReve())
|
||||
await this.addStatusEffect(demiReve)
|
||||
}
|
||||
else {
|
||||
this.deleteStatusEffect(StatusEffects.demiReve())
|
||||
this.deleteStatusEffect(demiReve)
|
||||
}
|
||||
}
|
||||
|
||||
@ -3093,8 +3098,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async forceStatusEffectId(statusId, sonne) {
|
||||
if (sonne) {
|
||||
async forceStatusEffectId(statusId, isSet) {
|
||||
if (isSet) {
|
||||
await this.addStatusEffectById(statusId);
|
||||
}
|
||||
else {
|
||||
@ -3104,21 +3109,17 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
deleteStatusEffectById(id) {
|
||||
const effects = Array.from(this.effects?.values())
|
||||
.filter(it => it.data.flags.core?.statusId == id);
|
||||
this._deleteStatusEffects(effects);
|
||||
const ids = Array.from(this.effects?.values())
|
||||
.filter(it => it.data.flags.core?.statusId == id)
|
||||
.map(it => it.id);
|
||||
this.deleteEmbeddedDocuments('ActiveEffect', ids);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
deleteStatusEffect(effect) {
|
||||
const toDelete = Array.from(this.effects?.values())
|
||||
.filter(it => StatusEffects.statusId(it.data) == StatusEffects.statusId(effect));
|
||||
this._deleteStatusEffects(toDelete);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_deleteStatusEffects(effects) {
|
||||
const ids = effects.map(it => it.id);
|
||||
const ids = Array.from(this.effects?.values())
|
||||
.filter(it => StatusEffects.statusId(it.data) == StatusEffects.statusId(effect))
|
||||
.map(it => it.id);
|
||||
this.deleteEmbeddedDocuments('ActiveEffect', ids);
|
||||
}
|
||||
|
||||
@ -3130,9 +3131,9 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addStatusEffect(statusEffect) {
|
||||
this.deleteStatusEffectById(statusEffect.id);
|
||||
const effet = duplicate(statusEffect);
|
||||
effet["flags.core.statusId"] = effet.id;
|
||||
this.deleteStatusEffectById(effet.id);
|
||||
effet.flags.core.statusId = effet.id;
|
||||
await this.createEmbeddedDocuments('ActiveEffect', [effet]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user