Fix: deprecation effects flags.core.statusId

Remplacement de la logique basée sur les flags par le set de "statuses"
This commit is contained in:
2023-12-08 23:50:16 +01:00
parent 56a5d06f16
commit 05cd02b694
6 changed files with 48 additions and 37 deletions

View File

@ -180,32 +180,32 @@ export class RdDBaseActorReve extends RdDBaseActor {
}
/* -------------------------------------------- */
isEffectAllowed(statusId) { return true }
isEffectAllowed(effectId) { return true }
getEffects(filter = e => true) {
return this.getEmbeddedCollection("ActiveEffect").filter(filter);
}
getEffect(statusId) {
return this.getEmbeddedCollection("ActiveEffect").find(it => it.flags?.core?.statusId == statusId);
getEffect(effectId) {
return this.getEmbeddedCollection("ActiveEffect").find(it => it.statuses?.has(effectId));
}
async setEffect(statusId, status) {
if (this.isEffectAllowed(statusId)) {
const effect = this.getEffect(statusId);
async setEffect(effectId, status) {
if (this.isEffectAllowed(effectId)) {
const effect = this.getEffect(effectId);
if (!status && effect) {
await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]);
}
if (status && !effect) {
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.status(statusId)]);
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.prepareActiveEffect(effectId)]);
}
}
}
async removeEffect(statusId) {
const effect = this.getEffect(statusId);
async removeEffect(id) {
const effect = this.getEmbeddedCollection("ActiveEffect").find(it => it.id == id);
if (effect) {
await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]);
await this.deleteEmbeddedDocuments('ActiveEffect', [id]);
}
}

View File

@ -33,8 +33,8 @@ export class RdDCreature extends RdDBaseActorSang {
}
}
isEffectAllowed(statusId) {
return [STATUSES.StatusComma].includes(statusId);
isEffectAllowed(effectId) {
return [STATUSES.StatusComma].includes(effectId);
}
isEntiteAccordee(attacker) {

View File

@ -70,8 +70,8 @@ export class RdDEntite extends RdDBaseActorReve {
await RdDEncaisser.encaisser(this)
}
isEffectAllowed(statusId) {
return [STATUSES.StatusComma].includes(statusId);
isEffectAllowed(effectId) {
return [STATUSES.StatusComma].includes(effectId);
}
async onAppliquerJetEncaissement(encaissement, attacker) {