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:
parent
56a5d06f16
commit
05cd02b694
@ -399,7 +399,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
content: 'Remise à neuf de ' + this.name
|
||||
});
|
||||
await this.supprimerBlessures(it => true);
|
||||
await this.removeEffects(e => e.flags.core.statusId !== STATUSES.StatusDemiReve);
|
||||
await this.removeEffects(e => e.id != STATUSES.StatusDemiReve);
|
||||
const updates = {
|
||||
'system.sante.endurance.value': this.system.sante.endurance.max,
|
||||
'system.sante.vie.value': this.system.sante.vie.max,
|
||||
@ -2923,9 +2923,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isEffectAllowed(statusId) {
|
||||
return true
|
||||
}
|
||||
isEffectAllowed(effectId) { return true }
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async onPreUpdateItem(item, change, options, id) {
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SYSTEM_RDD } from "../constants.js";
|
||||
|
||||
export const STATUSES = {
|
||||
StatusStunned : 'stun',
|
||||
StatusStunned: 'stun',
|
||||
StatusBleeding: 'bleeding',
|
||||
StatusProne: 'prone',
|
||||
StatusGrappling: 'grappling',
|
||||
@ -29,13 +29,16 @@ const rddStatusEffects = [
|
||||
];
|
||||
const demiReveStatusEffect = rddStatusEffects.find(it => it.id == STATUSES.StatusDemiReve);
|
||||
|
||||
const statusDemiSurprise = [STATUSES.StatusStunned, STATUSES.StatusProne, STATUSES.StatusRestrained];
|
||||
const statusSurpriseTotale = [STATUSES.StatusUnconscious, STATUSES.StatusBlind, STATUSES.StatusComma];
|
||||
const statusDemiSurprise = new Set([STATUSES.StatusStunned, STATUSES.StatusProne, STATUSES.StatusRestrained])
|
||||
const statusSurpriseTotale = new Set([STATUSES.StatusUnconscious, STATUSES.StatusBlind, STATUSES.StatusComma])
|
||||
|
||||
export class StatusEffects extends FormApplication {
|
||||
static onReady() {
|
||||
const rddStatusIds = rddStatusEffects.map(it => it.id);
|
||||
rddStatusEffects.forEach(it => it.flags = { core: { statusId: it.id } });
|
||||
const rddEffectIds = rddStatusEffects.map(it => it.id);
|
||||
rddStatusEffects.forEach(it => {
|
||||
it.statuses = new Set()
|
||||
it.statuses.add(it.id)
|
||||
})
|
||||
const defaultStatusEffectIds = CONFIG.statusEffects.map(it => it.id);
|
||||
game.settings.register(SYSTEM_RDD, "use-status-effects", {
|
||||
name: "use-status-effects",
|
||||
@ -54,37 +57,47 @@ export class StatusEffects extends FormApplication {
|
||||
restricted: true
|
||||
});
|
||||
|
||||
CONFIG.RDD.allEffects = rddStatusEffects.concat(CONFIG.statusEffects.filter(it => !rddStatusIds.includes(it.id)));
|
||||
CONFIG.RDD.allEffects = rddStatusEffects.concat(CONFIG.statusEffects.filter(it => !rddEffectIds.includes(it.id)));
|
||||
|
||||
StatusEffects._setUseStatusEffects(StatusEffects._getUseStatusEffects());
|
||||
console.log('statusEffects', CONFIG.statusEffects);
|
||||
}
|
||||
|
||||
static valeurSurprise(effect, isCombat) {
|
||||
// const id = StatusEffects.statusId(effect);
|
||||
if (statusSurpriseTotale.includes(effect.flags?.core?.statusId)) {
|
||||
if (statusSurpriseTotale.intersects(effect.statuses)) {
|
||||
return 2;
|
||||
}
|
||||
return statusDemiSurprise.includes(effect.flags?.core?.statusId) || (isCombat && effect.flags?.core?.statusId == STATUSES.StatusDemiReve) ? 1 : 0;
|
||||
if (statusDemiSurprise.intersects(effect.statuses)) {
|
||||
return 1
|
||||
}
|
||||
if (isCombat && effect.statuses.includes(STATUSES.StatusDemiReve)) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
static _getUseStatusEffects() {
|
||||
return game.settings.get(SYSTEM_RDD, "use-status-effects")?.split(',') ?? [];
|
||||
}
|
||||
|
||||
static _setUseStatusEffects(statusIds) {
|
||||
static _setUseStatusEffects(effectIds) {
|
||||
if (game.user.isGM) {
|
||||
game.settings.set(SYSTEM_RDD, "use-status-effects", statusIds.join());
|
||||
game.settings.set(SYSTEM_RDD, "use-status-effects", effectIds.join());
|
||||
}
|
||||
|
||||
for (let effect of CONFIG.RDD.allEffects) {
|
||||
effect.active = effect.rdd || statusIds.includes(effect.flags?.core?.statusId);
|
||||
effect.active = effect.rdd || effectIds.includes(effect.id);
|
||||
}
|
||||
CONFIG.statusEffects = CONFIG.RDD.allEffects.filter(it => it.active);
|
||||
}
|
||||
|
||||
static status(statusId) {
|
||||
return rddStatusEffects.find(it => it.flags?.core?.statusId == statusId);
|
||||
static prepareActiveEffect(effectId) {
|
||||
let status = rddStatusEffects.find(it => it.id == effectId)
|
||||
if (status) {
|
||||
status = duplicate(status)
|
||||
status.statuses = [effectId]
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static demiReve() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div>
|
||||
{{#if effects}}
|
||||
{{#each effects as |effect key|}}
|
||||
<span class="active-effect" data-effect="{{effect.flags.core.statusId}}">
|
||||
<span class="active-effect" data-effect="{{effect.id}}">
|
||||
<img class="button-effect-img {{#if @root.options.isGM}}delete-active-effect{{/if}}" src="{{effect.icon}}" data-tooltip="{{localize effect.name}}" width="24" height="24" />
|
||||
</span>
|
||||
{{/each}}
|
||||
|
Loading…
Reference in New Issue
Block a user