Corrections des TMRs et des Statuis #554
@ -15,7 +15,7 @@ import { DialogSplitItem } from "./dialog-split-item.js";
|
|||||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||||
import { DialogRepos } from "./dialog-repos.js";
|
import { DialogRepos } from "./dialog-repos.js";
|
||||||
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
||||||
import { TMRUtility } from "./tmr-utility.js";
|
import { STATUSES } from "./status-effects.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
export class RdDActorSheet extends ActorSheet {
|
export class RdDActorSheet extends ActorSheet {
|
||||||
@ -100,7 +100,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
formData.difficultesLibres = CONFIG.RDD.difficultesLibres;
|
formData.difficultesLibres = CONFIG.RDD.difficultesLibres;
|
||||||
|
|
||||||
formData.hautreve = {
|
formData.hautreve = {
|
||||||
isDemiReve: this.actor.getEffectByLabel("Demi-rêve"),
|
isDemiReve: this.actor.getEffect(STATUSES.StatusDemiReve),
|
||||||
rencontres: duplicate(formData.system.reve.rencontre.list),
|
rencontres: duplicate(formData.system.reve.rencontre.list),
|
||||||
casesTmr: formData.itemsByType.casetmr,
|
casesTmr: formData.itemsByType.casetmr,
|
||||||
cacheTMR: this.actor.isTMRCache()
|
cacheTMR: this.actor.isTMRCache()
|
||||||
@ -361,11 +361,15 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
await DialogRepos.create(this.actor);
|
await DialogRepos.create(this.actor);
|
||||||
});
|
});
|
||||||
html.find('.delete-active-effect').click(async event => {
|
html.find('.delete-active-effect').click(async event => {
|
||||||
let id = $(event.currentTarget).parents(".active-effect").data('id');
|
if (game.user.isGM) {
|
||||||
this.actor.enleverActiveEffectById(id);
|
let effect = $(event.currentTarget).parents(".active-effect").data('effect');
|
||||||
|
this.actor.removeEffect(effect);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
html.find('.enlever-tous-effets').click(async event => {
|
html.find('.enlever-tous-effets').click(async event => {
|
||||||
this.actor.enleverTousLesEffets();
|
if (game.user.isGM) {
|
||||||
|
this.actor.enleverTousLesEffets();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
html.find('.conteneur-name a').click(async event => {
|
html.find('.conteneur-name a').click(async event => {
|
||||||
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
|
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
|
||||||
|
@ -17,7 +17,7 @@ import { RdDAudio } from "./rdd-audio.js";
|
|||||||
import { RdDItemCompetence } from "./item-competence.js";
|
import { RdDItemCompetence } from "./item-competence.js";
|
||||||
import { RdDItemArme } from "./item-arme.js";
|
import { RdDItemArme } from "./item-arme.js";
|
||||||
import { RdDAlchimie } from "./rdd-alchimie.js";
|
import { RdDAlchimie } from "./rdd-alchimie.js";
|
||||||
import { StatusEffects } from "./status-effects.js";
|
import { STATUSES, StatusEffects } from "./status-effects.js";
|
||||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
||||||
import { RdDItemSigneDraconique } from "./item-signedraconique.js";
|
import { RdDItemSigneDraconique } from "./item-signedraconique.js";
|
||||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||||
@ -52,8 +52,6 @@ const POSSESSION_SANS_DRACONIC = {
|
|||||||
export class RdDActor extends Actor {
|
export class RdDActor extends Actor {
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static init() {
|
static init() {
|
||||||
Hooks.on("deleteActiveEffect", (effect, options, userId) => RdDActor.getParentActor(effect)?.onDeleteActiveEffect(effect, options));
|
|
||||||
|
|
||||||
Hooks.on("preUpdateItem", (item, change, options, id) => RdDActor.getParentActor(item)?.onPreUpdateItem(item, change, options, id));
|
Hooks.on("preUpdateItem", (item, change, options, id) => RdDActor.getParentActor(item)?.onPreUpdateItem(item, change, options, id));
|
||||||
Hooks.on("createItem", (item, options, id) => RdDActor.getParentActor(item)?.onCreateItem(item, options, id));
|
Hooks.on("createItem", (item, options, id) => RdDActor.getParentActor(item)?.onCreateItem(item, options, id));
|
||||||
Hooks.on("deleteItem", (item, options, id) => RdDActor.getParentActor(item)?.onDeleteItem(item, options, id));
|
Hooks.on("deleteItem", (item, options, id) => RdDActor.getParentActor(item)?.onDeleteItem(item, options, id));
|
||||||
@ -420,7 +418,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSurprise(isCombat = undefined) {
|
getSurprise(isCombat = undefined) {
|
||||||
let niveauSurprise = this.getActiveEffects()
|
let niveauSurprise = this.getEffects()
|
||||||
.map(effect => StatusEffects.valeurSurprise(effect, isCombat))
|
.map(effect => StatusEffects.valeurSurprise(effect, isCombat))
|
||||||
.reduce(Misc.sum(), 0);
|
.reduce(Misc.sum(), 0);
|
||||||
if (niveauSurprise > 1) {
|
if (niveauSurprise > 1) {
|
||||||
@ -1587,12 +1585,12 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSonne() {
|
getSonne() {
|
||||||
return this.getEffectByLabel("EFFECT.StatusStunned");
|
return this.getEffect(STATUSES.StatusStunned);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async finDeRound(options = { terminer: false }) {
|
async finDeRound(options = { terminer: false }) {
|
||||||
for (let effect of this.getActiveEffects()) {
|
for (let effect of this.getEffects()) {
|
||||||
if (effect.duration.type !== 'none' && (effect.duration.remaining <= 0 || options.terminer)) {
|
if (effect.duration.type !== 'none' && (effect.duration.remaining <= 0 || options.terminer)) {
|
||||||
if (effect.system.origin) {
|
if (effect.system.origin) {
|
||||||
await effect.update({ 'disabled': true });
|
await effect.update({ 'disabled': true });
|
||||||
@ -1621,7 +1619,7 @@ export class RdDActor extends Actor {
|
|||||||
ui.notifications.info("Le personnage est hors combat, il ne reste donc pas sonné");
|
ui.notifications.info("Le personnage est hors combat, il ne reste donc pas sonné");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.setStatusEffect("EFFECT.StatusStunned", sonne);
|
await this.setEffect(STATUSES.StatusStunned, sonne);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -1774,7 +1772,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
await this.update({ "system.sante": sante })
|
await this.update({ "system.sante": sante })
|
||||||
if (this.isDead()) {
|
if (this.isDead()) {
|
||||||
await this.setStatusEffect("EFFECT.StatusComma", true);
|
await this.setEffect(STATUSES.StatusComma, true);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -3158,8 +3156,7 @@ export class RdDActor extends Actor {
|
|||||||
ui.notifications.warn("Vous êtes déja dans les TMR....");
|
ui.notifications.warn("Vous êtes déja dans les TMR....");
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let demiReve = this.getActiveEffects(it => it.label == "Demi-rêve");
|
if (mode != 'visu' && this.getEffect(STATUSES.StatusDemiReve)) {
|
||||||
if (mode != 'visu' && demiReve.length > 0) {
|
|
||||||
ui.notifications.warn("Le joueur ou le MJ est déja dans les Terres Médianes avec ce personnage ! Visualisation uniquement");
|
ui.notifications.warn("Le joueur ou le MJ est déja dans les Terres Médianes avec ce personnage ! Visualisation uniquement");
|
||||||
mode = "visu"; // bascule le mode en visu automatiquement
|
mode = "visu"; // bascule le mode en visu automatiquement
|
||||||
}
|
}
|
||||||
@ -3174,7 +3171,7 @@ export class RdDActor extends Actor {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.setStatusEffect("EFFECT.StatusDemiReve", true);
|
await this.setEffect(STATUSES.StatusDemiReve, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fatigue = this.system.sante.fatigue.value;
|
const fatigue = this.system.sante.fatigue.value;
|
||||||
@ -3464,7 +3461,7 @@ export class RdDActor extends Actor {
|
|||||||
count--;
|
count--;
|
||||||
} else {
|
} else {
|
||||||
// TODO: status effect dead
|
// TODO: status effect dead
|
||||||
this.setStatusEffect("EFFECT.StatusComma", true);
|
this.setEffect(STATUSES.StatusComma, true);
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
content: `<img class="chat-icon" src="icons/svg/skull.svg" alt="charge" />
|
content: `<img class="chat-icon" src="icons/svg/skull.svg" alt="charge" />
|
||||||
<strong>${this.name} vient de succomber à une seconde blessure critique ! Que les Dragons gardent son Archétype en paix !</strong>`
|
<strong>${this.name} vient de succomber à une seconde blessure critique ! Que les Dragons gardent son Archétype en paix !</strong>`
|
||||||
@ -4099,61 +4096,44 @@ export class RdDActor extends Actor {
|
|||||||
async onUpdateActor(update, options, actorId) {
|
async onUpdateActor(update, options, actorId) {
|
||||||
const updatedEndurance = update?.system?.sante?.endurance
|
const updatedEndurance = update?.system?.sante?.endurance
|
||||||
if (updatedEndurance && options.diff) {
|
if (updatedEndurance && options.diff) {
|
||||||
await this.setStatusEffect("EFFECT.StatusUnconscious", updatedEndurance.value == 0)
|
await this.setEffect(STATUSES.StatusUnconscious, updatedEndurance.value == 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async onDeleteActiveEffect(effect, options) {
|
getEffects() {
|
||||||
switch (effect.label) {
|
return this.getEmbeddedCollection("ActiveEffect");
|
||||||
case 'EFFECT.StatusStunned':
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getActiveEffects(matching = it => true) {
|
getEffect(statusId) {
|
||||||
return Array.from(this.getEmbeddedCollection("ActiveEffect").values()).filter(it => matching(it));
|
return this.getEmbeddedCollection("ActiveEffect").find(it => it.flags?.core?.statusId == statusId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getEffectByLabel(label) {
|
async setEffect(statusId, status) {
|
||||||
return this.getActiveEffects().find(it => it.system?.label == label);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
getEffectById(id) {
|
|
||||||
return this.getActiveEffects().find(it => it.id == id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async setStatusEffect(label, status, updates = {}) {
|
|
||||||
if (this.isEntite() || this.type == 'vehicule') {
|
if (this.isEntite() || this.type == 'vehicule') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("setStatusEffect", label, status, updates)
|
console.log("setEffect", statusId, status)
|
||||||
const existing = this.getEffectByLabel(label);
|
await this.removeEffect(statusId);
|
||||||
if (existing) {
|
const effect = StatusEffects.status(statusId);
|
||||||
existing.delete();
|
if (effect) {
|
||||||
}
|
await this.createEmbeddedDocuments("ActiveEffect", [effect]);
|
||||||
if (status) {
|
|
||||||
const statusEffect = mergeObject(duplicate(StatusEffects.status(label)), updates);
|
|
||||||
await this.createEmbeddedDocuments("ActiveEffect", [statusEffect]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enleverActiveEffectById(id) {
|
async removeEffect(statusId) {
|
||||||
if (game.user.isGM) {
|
const effect = this.getEffect(statusId);
|
||||||
const existing = this.getEffectById(id);
|
if (effect) {
|
||||||
if (existing) {
|
await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]);
|
||||||
existing.delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
enleverTousLesEffets() {
|
enleverTousLesEffets() {
|
||||||
if (game.user.isGM) {
|
if (game.user.isGM) {
|
||||||
this.deleteEmbeddedDocuments('ActiveEffect', this.getActiveEffects().map(it => it.id));
|
this.deleteEmbeddedDocuments('ActiveEffect', this.getEffects().map(it => it.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
|||||||
import { RdDRoll } from "./rdd-roll.js";
|
import { RdDRoll } from "./rdd-roll.js";
|
||||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||||
|
import { STATUSES } from "./status-effects.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
const premierRoundInit = [
|
const premierRoundInit = [
|
||||||
@ -1185,7 +1186,7 @@ export class RdDCombat {
|
|||||||
defenderRoll.show.recul = 'encaisse';
|
defenderRoll.show.recul = 'encaisse';
|
||||||
} else if (rollRecul.rolled.isETotal || this._isReculCauseChute(impact)) {
|
} else if (rollRecul.rolled.isETotal || this._isReculCauseChute(impact)) {
|
||||||
defenderRoll.show.recul = 'chute';
|
defenderRoll.show.recul = 'chute';
|
||||||
await this.defender.setStatusEffect("EFFECT.StatusProne", true);
|
await this.defender.setEffect(STATUSES.StatusProne, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
defenderRoll.show.recul = 'recul';
|
defenderRoll.show.recul = 'recul';
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { SYSTEM_SOCKET_ID } from "./constants.js";
|
|
||||||
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
import { TMRUtility } from "./tmr-utility.js";
|
import { TMRUtility } from "./tmr-utility.js";
|
||||||
@ -16,6 +15,7 @@ import { Misc } from "./misc.js";
|
|||||||
import { HtmlUtility } from "./html-utility.js";
|
import { HtmlUtility } from "./html-utility.js";
|
||||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||||
import { RdDDice } from "./rdd-dice.js";
|
import { RdDDice } from "./rdd-dice.js";
|
||||||
|
import { STATUSES } from "./status-effects.js";
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
export class RdDTMRDialog extends Dialog {
|
export class RdDTMRDialog extends Dialog {
|
||||||
@ -277,15 +277,16 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
close() {
|
async close() {
|
||||||
if ( this.actor.tmrApp ) {
|
if (this.actor.tmrApp) {
|
||||||
this.actor.tmrApp = undefined; // Cleanup reference
|
this.actor.tmrApp = undefined; // Cleanup reference
|
||||||
if ( !this.viewOnly ) {
|
if (!this.viewOnly) {
|
||||||
this.actor.setStatusEffect("EFFECT.StatusDemiReve", false);
|
await this.actor.setEffect(STATUSES.StatusDemiReve, false)
|
||||||
this._tellToGM(this.actor.name + " a quitté les terres médianes");
|
this._tellToGM(this.actor.name + " a quitté les terres médianes");
|
||||||
}
|
}
|
||||||
this.actor.santeIncDec("fatigue", this.cumulFatigue).then(super.close()); // moving 1 cell costs 1 fatigue
|
await this.actor.santeIncDec("fatigue", this.cumulFatigue)
|
||||||
}
|
}
|
||||||
|
await super.close(); // moving 1 cell costs 1 fatigue
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -1,26 +1,41 @@
|
|||||||
import { SYSTEM_RDD } from "./constants.js";
|
import { SYSTEM_RDD } from "./constants.js";
|
||||||
|
|
||||||
const rddStatusEffects = [
|
export const STATUSES = {
|
||||||
{ rdd: true, id: 'stun', label: 'EFFECT.StatusStunned', icon: 'icons/svg/stoned.svg', "duration.rounds": 1 },
|
StatusStunned : 'stun',
|
||||||
{ rdd: true, id: 'bleeding', label: 'EFFECT.StatusBleeding', icon: 'icons/svg/blood.svg' },
|
StatusBleeding: 'bleeding',
|
||||||
{ rdd: true, id: 'prone', label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.svg' },
|
StatusProne: 'prone',
|
||||||
{ rdd: true, id: 'grappling', tint: '#33cc33', label: 'EFFECT.StatusGrappling', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },
|
StatusGrappling: 'grappling',
|
||||||
{ rdd: true, id: 'grappled', tint: '#ff9900', label: 'EFFECT.StatusGrappled', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },
|
StatusGrappled: 'grappled',
|
||||||
{ rdd: true, id: 'restrain', label: 'EFFECT.StatusRestrained', icon: 'icons/svg/net.svg' },
|
StatusRestrained: 'restrain',
|
||||||
{ rdd: true, id: 'unconscious', label: 'EFFECT.StatusUnconscious', icon: 'icons/svg/unconscious.svg' },
|
StatusUnconscious: 'unconscious',
|
||||||
{ rdd: true, id: 'blind', label: 'EFFECT.StatusBlind', icon: 'icons/svg/blind.svg' },
|
StatusBlind: 'blind',
|
||||||
{ rdd: true, id: 'comma', label: 'EFFECT.StatusComma', icon: 'icons/svg/skull.svg' },
|
StatusComma: 'comma',
|
||||||
{ rdd: true, id: 'dead', label: 'EFFECT.StatusDead', icon: 'icons/svg/skull.svg' },
|
StatusDead: 'dead',
|
||||||
{ rdd: true, id: 'demi-reve', label: 'EFFECT.StatusDemiReve', icon: 'systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg' }
|
StatusDemiReve: 'demi-reve',
|
||||||
];
|
}
|
||||||
const demiReveStatusEffect = rddStatusEffects.find(it => it.label == 'EFFECT.StatusDemiReve');
|
|
||||||
|
|
||||||
const statusDemiSurprise = new Set(['EFFECT.StatusStunned', 'EFFECT.StatusProne', 'EFFECT.StatusRestrain']);
|
const rddStatusEffects = [
|
||||||
const statusSurpriseTotale = new Set(['EFFECT.StatusUnconscious', 'EFFECT.StatusBlind', 'EFFECT.StatusComma']);
|
{ rdd: true, id: STATUSES.StatusStunned, label: 'EFFECT.StatusStunned', icon: 'icons/svg/stoned.svg', "duration.rounds": 1 },
|
||||||
|
{ rdd: true, id: STATUSES.StatusBleeding, label: 'EFFECT.StatusBleeding', icon: 'icons/svg/blood.svg' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusProne, label: 'EFFECT.StatusProne', icon: 'icons/svg/falling.svg' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusGrappling, tint: '#33cc33', label: 'EFFECT.StatusGrappling', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusGrappled, tint: '#ff9900', label: 'EFFECT.StatusGrappled', icon: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusRestrained, label: 'EFFECT.StatusRestrained', icon: 'icons/svg/net.svg' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusUnconscious, label: 'EFFECT.StatusUnconscious', icon: 'icons/svg/unconscious.svg' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusBlind, label: 'EFFECT.StatusBlind', icon: 'icons/svg/blind.svg' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusComma, label: 'EFFECT.StatusComma', icon: 'icons/svg/skull.svg' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusDead, label: 'EFFECT.StatusDead', icon: 'icons/svg/skull.svg' },
|
||||||
|
{ rdd: true, id: STATUSES.StatusDemiReve, label: 'EFFECT.StatusDemiReve', icon: 'systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg' }
|
||||||
|
];
|
||||||
|
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];
|
||||||
|
|
||||||
export class StatusEffects {
|
export class StatusEffects {
|
||||||
static onReady() {
|
static onReady() {
|
||||||
const rddStatusIds = rddStatusEffects.map(it => it.id);
|
const rddStatusIds = rddStatusEffects.map(it => it.id);
|
||||||
|
rddStatusEffects.forEach(it => it.flags = { core: { statusId: it.id } });
|
||||||
const defaultStatusEffectIds = CONFIG.statusEffects.map(it => it.id);
|
const defaultStatusEffectIds = CONFIG.statusEffects.map(it => it.id);
|
||||||
game.settings.register(SYSTEM_RDD, "use-status-effects", {
|
game.settings.register(SYSTEM_RDD, "use-status-effects", {
|
||||||
name: "use-status-effects",
|
name: "use-status-effects",
|
||||||
@ -47,40 +62,36 @@ export class StatusEffects {
|
|||||||
|
|
||||||
static valeurSurprise(effect, isCombat) {
|
static valeurSurprise(effect, isCombat) {
|
||||||
// const id = StatusEffects.statusId(effect);
|
// const id = StatusEffects.statusId(effect);
|
||||||
if (statusSurpriseTotale.has(effect.label)) {
|
if (statusSurpriseTotale.includes(effect.flags?.core?.statusId)) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return statusDemiSurprise.has(effect.label) || (isCombat && effect.label == demiReveStatusEffect.label) ? 1 : 0;
|
return statusDemiSurprise.includes(effect.flags?.core?.statusId) || (isCombat && effect.flags?.core?.statusId == STATUSES.StatusDemiReve) ? 1 : 0;
|
||||||
}
|
|
||||||
|
|
||||||
static setMandatoryRdd() {
|
|
||||||
CONFIG.statusEffects.filter(it => statusDemiSurprise.has(it.id) || statusSurpriseTotale.has(it.id))
|
|
||||||
.forEach(it => it.rdd = true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static _getUseStatusEffects() {
|
static _getUseStatusEffects() {
|
||||||
const setting = game.settings.get(SYSTEM_RDD, "use-status-effects");
|
const setting = game.settings.get(SYSTEM_RDD, "use-status-effects");
|
||||||
return setting ? new Set(setting.split(',')) : new Set();
|
return setting ? setting.split(',') : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static _setUseStatusEffects(useStatusEffects) {
|
static _setUseStatusEffects(statusIds) {
|
||||||
if (game.user.isGM) {
|
if (game.user.isGM) {
|
||||||
game.settings.set(SYSTEM_RDD, "use-status-effects", StatusEffects._toSetting(useStatusEffects));
|
game.settings.set(SYSTEM_RDD, "use-status-effects", StatusEffects._toSetting(statusIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let effect of CONFIG.RDD.allEffects) {
|
for (let effect of CONFIG.RDD.allEffects) {
|
||||||
effect.active = effect.rdd || useStatusEffects.has(effect.id);
|
effect.active = effect.rdd || statusIds.includes(effect.flags?.core?.statusId);
|
||||||
}
|
}
|
||||||
CONFIG.statusEffects = CONFIG.RDD.allEffects.filter(it => it.active);
|
CONFIG.statusEffects = CONFIG.RDD.allEffects.filter(it => it.active);
|
||||||
}
|
}
|
||||||
|
|
||||||
static _toSetting(useStatusEffects) {
|
static _toSetting(statusIds) {
|
||||||
return Array.from(useStatusEffects).join();
|
return statusIds.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
static status(label) {
|
static status(statusId) {
|
||||||
return rddStatusEffects.find(it => it.label == label) ?? { label: label };
|
return rddStatusEffects.find(it => it.flags?.core?.statusId == statusId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static demiReve() {
|
static demiReve() {
|
||||||
return demiReveStatusEffect;
|
return demiReveStatusEffect;
|
||||||
}
|
}
|
||||||
@ -106,8 +117,10 @@ class StatusEffectsSettings extends FormApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getData() {
|
getData() {
|
||||||
|
const used = StatusEffects._getUseStatusEffects();
|
||||||
let formData = super.getData();
|
let formData = super.getData();
|
||||||
formData.effects = CONFIG.RDD.allEffects;
|
formData.effects = duplicate(CONFIG.RDD.allEffects);
|
||||||
|
formData.effects.forEach(it => it.active = used.includes(it.id))
|
||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,10 +131,10 @@ class StatusEffectsSettings extends FormApplication {
|
|||||||
let selected = StatusEffects._getUseStatusEffects();
|
let selected = StatusEffects._getUseStatusEffects();
|
||||||
let isChecked = event.currentTarget.checked;
|
let isChecked = event.currentTarget.checked;
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
selected.add(id);
|
selected.push(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selected.delete(id);
|
selected = selected.filter(it => it != id)
|
||||||
}
|
}
|
||||||
StatusEffects._setUseStatusEffects(selected);
|
StatusEffects._setUseStatusEffects(selected);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{#if calc.surprise}}{{calc.surprise}}! {{/if}}
|
{{#if calc.surprise}}{{calc.surprise}}! {{/if}}
|
||||||
{{#if effects}}
|
{{#if effects}}
|
||||||
{{#each effects as |effect key|}}
|
{{#each effects as |effect key|}}
|
||||||
<span class="active-effect" data-id="{{effect._id}}">
|
<span class="active-effect" data-effect="{{effect.flags.core.statusId}}">
|
||||||
<img class="button-effect-img delete-active-effect" src="{{effect.icon}}" alt="{{localize effect.label}}" width="24" height="24" />
|
<img class="button-effect-img delete-active-effect" src="{{effect.icon}}" alt="{{localize effect.label}}" width="24" height="24" />
|
||||||
</span>
|
</span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<input class="resource-content select-effect" type="checkbox" name="{{effect.id}}" {{#if effect.active}}checked{{/if}}/>
|
<input class="resource-content select-effect" type="checkbox" name="{{effect.id}}" {{#if effect.active}}checked{{/if}}/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<img class="button-effect-img" height="16" width="16" src="{{effect.icon}}" alt="{{ localize effect.label}}" />
|
<img class="button-effect-img" height="16" width="16" src="{{effect.icon}}" alt="{{localize effect.label}}" />
|
||||||
<label>{{localize effect.label}}</label>
|
<label>{{localize effect.label}}</label>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
Loading…
Reference in New Issue
Block a user