rework ActiveEffects
This commit is contained in:
@ -1,23 +1,31 @@
|
||||
|
||||
const demiReveStatusEffect = { id: 'demi-reve', rdd: true, label: 'Demi-rêve', icon: 'systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg' };
|
||||
const rddStatusEffects = [
|
||||
{ id: 'sonne', rdd: true, label: 'Sonné', icon: 'icons/svg/stoned.svg' },
|
||||
demiReveStatusEffect
|
||||
{ rdd: true, id: 'stun', label: 'EFFECT.StatusStunned', icon: 'icons/svg/stoned.svg' },
|
||||
{ rdd: true, id: 'bleeding', label: 'EFFECT.StatusBleeding', icon: 'icons/svg/blood.svg' },
|
||||
{ rdd: true, id: 'prone', label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.svg' },
|
||||
{ rdd: true, id: 'grappling', tint: '#33cc33', label: 'EFFECT.StatusGrappling', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },
|
||||
{ rdd: true, id: 'grappled', tint: '#ff9900', label: 'EFFECT.StatusGrappled', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },
|
||||
{ rdd: true, id: 'restrain', label: 'EFFECT.StatusRestrained', icon: 'icons/svg/net.svg' },
|
||||
{ rdd: true, id: 'unconscious', label: 'EFFECT.StatusUnconscious', icon: 'icons/svg/unconscious.svg' },
|
||||
{ rdd: true, id: 'blind', label: 'EFFECT.StatusBlind', icon: 'icons/svg/blind.svg' },
|
||||
{ rdd: true, id: 'comma', label: 'EFFECT.StatusComma', icon: 'icons/svg/skull.svg' },
|
||||
{ rdd: true, id: 'dead', label: 'EFFECT.StatusDead', icon: 'icons/svg/skull.svg' },
|
||||
{ rdd: true, id: 'demi-reve', label: 'EFFECT.StatusDemiReve', icon: 'systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg' }
|
||||
];
|
||||
const statusDemiSurprise = new Set(['sonne', 'prone', 'restrain']);
|
||||
const statusSurpriseTotale = new Set(['unconscious', 'blind', 'dead']);
|
||||
const demiReveStatusEffect = rddStatusEffects.find(it => it.label == 'EFFECT.StatusDemiReve');
|
||||
|
||||
const statusDemiSurprise = new Set(['EFFECT.StatusStunned', 'EFFECT.StatusProne', 'EFFECT.StatusRestrain']);
|
||||
const statusSurpriseTotale = new Set(['EFFECT.StatusUnconscious', 'EFFECT.StatusBlind', 'EFFECT.StatusComma']);
|
||||
|
||||
export class StatusEffects {
|
||||
static onReady() {
|
||||
StatusEffects.setCoreStatusId([demiReveStatusEffect]);
|
||||
StatusEffects.setCoreStatusId(rddStatusEffects);
|
||||
StatusEffects.setMandatoryRdd();
|
||||
const defaultUseStatusEffect = CONFIG.statusEffects.map(it => it.id).join();
|
||||
const rddStatusIds = rddStatusEffects.map(it => it.id);
|
||||
const defaultStatusEffectIds = CONFIG.statusEffects.map(it => it.id);
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "use-status-effects", {
|
||||
name: "use-status-effects",
|
||||
scope: "world",
|
||||
config: false,
|
||||
default: defaultUseStatusEffect,
|
||||
default: defaultStatusEffectIds.join(),
|
||||
type: String
|
||||
});
|
||||
|
||||
@ -29,30 +37,21 @@ export class StatusEffects {
|
||||
type: StatusEffectsSettings,
|
||||
restricted: true
|
||||
});
|
||||
CONFIG.RDD.allEffects = rddStatusEffects.concat(CONFIG.statusEffects);
|
||||
|
||||
|
||||
CONFIG.RDD.allEffects = rddStatusEffects.concat(CONFIG.statusEffects.filter(it => !rddStatusIds.includes(it.id)));
|
||||
|
||||
StatusEffects._setUseStatusEffects(StatusEffects._getUseStatusEffects());
|
||||
console.log('statusEffects', CONFIG.statusEffects);
|
||||
}
|
||||
|
||||
static valeurSurprise(effect, isCombat) {
|
||||
const id = StatusEffects.statusId(effect);
|
||||
if (statusSurpriseTotale.has(id)) {
|
||||
// const id = StatusEffects.statusId(effect);
|
||||
if (statusSurpriseTotale.has(effect.label)) {
|
||||
return 2;
|
||||
}
|
||||
return statusDemiSurprise.has(id) || (isCombat && id == demiReveStatusEffect.id) ? 1 : 0;
|
||||
return statusDemiSurprise.has(effect.label) || (isCombat && effect.label == demiReveStatusEffect.label) ? 1 : 0;
|
||||
}
|
||||
|
||||
static statusId(effectData) {
|
||||
return effectData.flags?.core?.statusId ?? effectData["flags.core.statusId"];
|
||||
}
|
||||
|
||||
static setCoreStatusId(list) {
|
||||
list.forEach(it => {
|
||||
it.flags = { core: { statusId: it.id } };
|
||||
it["flags.core.statusId"] = it.id;
|
||||
});
|
||||
}
|
||||
static setMandatoryRdd() {
|
||||
CONFIG.statusEffects.filter(it => statusDemiSurprise.has(it.id) || statusSurpriseTotale.has(it.id))
|
||||
.forEach(it => it.rdd = true);
|
||||
@ -78,6 +77,9 @@ export class StatusEffects {
|
||||
return Array.from(useStatusEffects).join();
|
||||
}
|
||||
|
||||
static status(label) {
|
||||
return rddStatusEffects.find(it => it.label == label) ?? { label: label };
|
||||
}
|
||||
static demiReve() {
|
||||
return demiReveStatusEffect;
|
||||
}
|
||||
|
Reference in New Issue
Block a user