forked from public/foundryvtt-reve-de-dragon
Nouvelle fenêtre de jets de dés
This commit is contained in:
@@ -1,43 +1,47 @@
|
||||
import { SYSTEM_RDD } from "../constants.js";
|
||||
|
||||
export const STATUSES = {
|
||||
StatusStunned: 'stun',
|
||||
StatusBleeding: 'bleeding',
|
||||
StatusProne: 'prone',
|
||||
StatusGrappling: 'grappling',
|
||||
StatusGrappled: 'grappled',
|
||||
StatusRestrained: 'restrain',
|
||||
StatusStunned: 'stun',
|
||||
StatusProne: 'prone',
|
||||
StatusUnconscious: 'unconscious',
|
||||
StatusBlind: 'blind',
|
||||
StatusComma: 'comma',
|
||||
StatusBleeding: 'bleeding',
|
||||
StatusDead: 'dead',
|
||||
StatusDemiReve: 'demi-reve',
|
||||
}
|
||||
|
||||
const demiReveStatusEffect = { rdd: true, id: STATUSES.StatusDemiReve, name: 'EFFECT.StatusDemiReve', img: 'systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg' };
|
||||
const rddStatusEffects = [
|
||||
{ rdd: true, id: STATUSES.StatusStunned, name: 'EFFECT.StatusStunned', img: 'icons/svg/stoned.svg', "duration.rounds": 1 },
|
||||
{ rdd: true, id: STATUSES.StatusBleeding, name: 'EFFECT.StatusBleeding', img: 'icons/svg/blood.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusProne, name: 'EFFECT.StatusProne', img: 'icons/svg/falling.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusGrappling, tint: '#33cc33', name: 'EFFECT.StatusGrappling', img: 'systems/foundryvtt-reve-de-dragon/icons/empoignade.webp' },
|
||||
{ rdd: true, id: STATUSES.StatusGrappled, tint: '#ff9900', name: 'EFFECT.StatusGrappled', img: 'systems/foundryvtt-reve-de-dragon/icons/empoignade.webp' },
|
||||
{ rdd: true, id: STATUSES.StatusRestrained, name: 'EFFECT.StatusRestrained', img: 'icons/svg/net.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusUnconscious, name: 'EFFECT.StatusUnconscious', img: 'icons/svg/unconscious.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusBlind, name: 'EFFECT.StatusBlind', img: 'icons/svg/blind.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusComma, name: 'EFFECT.StatusComma', img: 'icons/svg/skull.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusDead, name: 'EFFECT.StatusDead', img: 'icons/svg/skull.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusDemiReve, name: 'EFFECT.StatusDemiReve', img: 'systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg' }
|
||||
{ rdd: true, id: STATUSES.StatusGrappling, tint: '#33cc33', name: 'EFFECT.StatusGrappling', img: 'systems/foundryvtt-reve-de-dragon/icons/empoignade.webp' },
|
||||
{ rdd: true, id: STATUSES.StatusGrappled, tint: '#ff9900', name: 'EFFECT.StatusGrappled', img: 'systems/foundryvtt-reve-de-dragon/icons/empoignade.webp' },
|
||||
|
||||
{ rdd: true, id: STATUSES.StatusRestrained, name: 'EFFECT.StatusRestrained', img: 'icons/svg/net.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusStunned, name: 'EFFECT.StatusStunned', img: 'icons/svg/stoned.svg', "duration.rounds": 1 },
|
||||
{ rdd: true, id: STATUSES.StatusProne, name: 'EFFECT.StatusProne', img: 'icons/svg/falling.svg' },
|
||||
|
||||
{ rdd: true, id: STATUSES.StatusUnconscious, name: 'EFFECT.StatusUnconscious', img: 'icons/svg/unconscious.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusBlind, name: 'EFFECT.StatusBlind', img: 'icons/svg/blind.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusComma, name: 'EFFECT.StatusComma', img: 'icons/svg/skull.svg' },
|
||||
|
||||
{ rdd: true, id: STATUSES.StatusBleeding, name: 'EFFECT.StatusBleeding', img: 'icons/svg/blood.svg' },
|
||||
{ rdd: true, id: STATUSES.StatusDead, name: 'EFFECT.StatusDead', img: 'icons/svg/skull.svg' },
|
||||
demiReveStatusEffect
|
||||
];
|
||||
const demiReveStatusEffect = rddStatusEffects.find(it => it.id == STATUSES.StatusDemiReve);
|
||||
|
||||
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 rddEffectIds = rddStatusEffects.map(it => it.id);
|
||||
rddStatusEffects.forEach(it => {
|
||||
it.statuses = new Set()
|
||||
it.statuses.add(it.id)
|
||||
it.statuses = new Set([it.id])
|
||||
})
|
||||
const defaultStatusEffectIds = CONFIG.statusEffects.map(it => it.id);
|
||||
game.settings.register(SYSTEM_RDD, "use-status-effects", {
|
||||
@@ -63,19 +67,31 @@ export class StatusEffects extends FormApplication {
|
||||
console.log('statusEffects', CONFIG.statusEffects);
|
||||
}
|
||||
|
||||
static valeurSurprise(effect, isCombat) {
|
||||
static niveauSurprise(effect, isCombat) {
|
||||
if (statusSurpriseTotale.intersects(effect.statuses)) {
|
||||
return 2
|
||||
}
|
||||
if (statusDemiSurprise.intersects(effect.statuses)) {
|
||||
return 1
|
||||
}
|
||||
if (isCombat && effect.statuses.find(e => e == STATUSES.StatusDemiReve)) {
|
||||
if (isCombat && StatusEffects.isDemiReve(effect)) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
static typeSurprise(niveauSurprise) {
|
||||
switch (niveauSurprise) {
|
||||
case 0: return ''
|
||||
case 1: return 'demi'
|
||||
default: return 'totale'
|
||||
}
|
||||
}
|
||||
|
||||
static isDemiReve(effect) {
|
||||
return effect.statuses.has(STATUSES.StatusDemiReve)
|
||||
}
|
||||
|
||||
static _getUseStatusEffects() {
|
||||
return game.settings.get(SYSTEM_RDD, "use-status-effects")?.split(',') ?? [];
|
||||
}
|
||||
@@ -92,10 +108,10 @@ export class StatusEffects extends FormApplication {
|
||||
}
|
||||
|
||||
static prepareActiveEffect(effectId) {
|
||||
let status = rddStatusEffects.find(it => it.id == effectId)
|
||||
const status = rddStatusEffects.find(it => it.id == effectId)
|
||||
if (status) {
|
||||
status = foundry.utils.duplicate(status)
|
||||
status.statuses = [effectId]
|
||||
status.statuses = new Set([effectId])
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
Reference in New Issue
Block a user