Utilisation de constant pour le systeme

This commit is contained in:
Vincent Vandemeulebrouck 2021-11-11 02:43:38 +01:00
parent 79a7ad8b8c
commit 31d1d352f2
9 changed files with 54 additions and 44 deletions

View File

@ -32,6 +32,7 @@ import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js";
import { RollDataAjustements } from "./rolldata-ajustements.js";
import { DialogItemAchat } from "./dialog-item-achat.js";
import { RdDItem } from "./item.js";
import { SYSTEM_RDD } from "./constants.js";
/* -------------------------------------------- */
/**
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
@ -766,13 +767,13 @@ export class RdDActor extends Actor {
const sustNeeded = tplData.attributs.sust.value;
const sustConsomme = tplData.compteurs.sust.value;
const eauConsomme = tplData.compteurs.eau.value;
if (game.settings.get("foundryvtt-reve-de-dragon", "appliquer-famine-soif").includes('famine') && sustConsomme < sustNeeded) {
if (game.settings.get(SYSTEM_RDD, "appliquer-famine-soif").includes('famine') && sustConsomme < sustNeeded) {
const perte = sustConsomme < Math.min(0.5, sustNeeded) ? 3 : (sustConsomme <= (sustNeeded / 2) ? 2 : 1);
message.content += `<br>Vous ne vous êtes sustenté que de ${sustConsomme} pour un appétit de ${sustNeeded}, vous avez faim!
La famine devrait vous faire ${perte} points d'endurance non récupérables, notez le cumul de côté et ajustez l'endurance`;
}
if (game.settings.get("foundryvtt-reve-de-dragon", "appliquer-famine-soif").includes('soif') && eauConsomme < sustNeeded) {
if (game.settings.get(SYSTEM_RDD, "appliquer-famine-soif").includes('soif') && eauConsomme < sustNeeded) {
const perte = eauConsomme < Math.min(0.5, sustNeeded) ? 12 : (eauConsomme <= (sustNeeded / 2) ? 6 : 3);
message.content += `<br>Vous n'avez bu que ${eauConsomme} doses de liquide pour une soif de ${sustNeeded}, vous avez soif!
La soif devrait vous faire ${perte} points d'endurance non récupérables, notez le cumul de côté et ajustez l'endurance`;
@ -3474,7 +3475,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async accorder(entite, when = 'avant-encaissement') {
if (when != game.settings.get("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar")
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
|| !entite.isEntiteCauchemar()
|| entite.isEntiteCauchemarAccordee(this)) {
return true;

View File

@ -7,6 +7,7 @@ import { RdDGemme } from "./rdd-gemme.js";
import { Misc } from "./misc.js";
import { HtmlUtility } from "./html-utility.js";
import { ReglesOptionelles } from "./regles-optionelles.js";
import { SYSTEM_RDD } from "./constants.js";
/**
* Extend the basic ItemSheet with some very simple modifications
@ -17,7 +18,7 @@ export class RdDItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
classes: [SYSTEM_RDD, "sheet", "item"],
template: "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html",
width: 550,
height: 550

View File

@ -1,3 +1,4 @@
import { SYSTEM_RDD } from "./constants.js";
import { RdDItemSigneDraconique } from "./item-signedraconique.js";
import { Misc } from "./misc.js";
import { TMRType, TMRUtility } from "./tmr-utility.js";
@ -11,7 +12,7 @@ export class RdDSigneDraconiqueItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
classes: [SYSTEM_RDD, "sheet", "item"],
template: "systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html",
width: 550,
height: 550

View File

@ -1,3 +1,4 @@
import { SYSTEM_RDD } from "./constants.js";
/* -------------------------------------------- */
const context2file = {
@ -9,7 +10,7 @@ export class RdDAudio {
/* -------------------------------------------- */
static PlayContextAudio(context) {
if (game.settings.get("foundryvtt-reve-de-dragon", "activer-sons-audio") ) {
if (game.settings.get(SYSTEM_RDD, "activer-sons-audio") ) {
let audioData = context2file[context];
if ( audioData ) {
let audioPath = "systems/foundryvtt-reve-de-dragon/sounds/" + audioData.file;

View File

@ -7,6 +7,7 @@ import { RdDUtility } from "./rdd-utility.js";
import { Grammar } from "./grammar.js";
import { RdDDice } from "./rdd-dice.js";
import { Misc } from "./misc.js";
import { SYSTEM_RDD } from "./constants.js";
/* -------------------------------------------- */
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
@ -70,19 +71,19 @@ export class RdDCalendrier extends Application {
constructor() {
super();
// position
this.calendrierPos = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier-pos"));
this.calendrierPos = duplicate(game.settings.get(SYSTEM_RDD, "calendrier-pos"));
if (this.calendrierPos == undefined || this.calendrierPos.top == undefined) {
this.calendrierPos = RdDCalendrier.createCalendrierPos();
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos);
game.settings.set(SYSTEM_RDD, "calendrier-pos", this.calendrierPos);
}
// Calendrier
this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier") ?? RdDCalendrier.getCalendrier(0));
this.calendrier = duplicate(game.settings.get(SYSTEM_RDD, "calendrier") ?? RdDCalendrier.getCalendrier(0));
this.calendrier.annee = this.calendrier.annee ?? Math.floor((this.calendrier.moisRdD ?? 0) / RDD_MOIS_PAR_AN);
this.calendrier.moisRdD = (this.calendrier.moisRdD ?? 0) % RDD_MOIS_PAR_AN;
if (game.user.isGM) { // Uniquement si GM
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier);
game.settings.set(SYSTEM_RDD, "calendrier", this.calendrier);
}
// nombre astral
@ -95,7 +96,7 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */
getListeNombreAstral() {
return game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral") ?? [];
return game.settings.get(SYSTEM_RDD, "liste-nombre-astral") ?? [];
}
/* -------------------------------------------- */
@ -172,7 +173,7 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */
resetNombreAstral() {
this.listeNombreAstral = [];
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_reset_nombre_astral",
@ -203,7 +204,7 @@ export class RdDCalendrier extends Application {
}
//console.log("SAVE list", newList, jourCourant);
this.listeNombreAstral = newList;
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
}
}
@ -255,7 +256,7 @@ export class RdDCalendrier extends Application {
this.checkMaladie("heure");
this.checkMaladie("jour");
}
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
// Notification aux joueurs
game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_sync_time",
@ -283,7 +284,7 @@ export class RdDCalendrier extends Application {
}
this.calendrier.heureRdD = indexHeure;
this.calendrier.minutesRelative = 0;
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
}
/* -------------------------------------------- */
@ -339,7 +340,7 @@ export class RdDCalendrier extends Application {
// Mise à jour des nombres astraux du joueur
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstral });
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
}
request.nbAstral = nbAstral;
if (game.user.isGM) {
@ -472,7 +473,7 @@ export class RdDCalendrier extends Application {
this.calendrier.jour = Number(calendrierData.jourMois) - 1;
this.calendrier.moisRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.moisKey);
this.calendrier.heureRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.heureKey);
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
await this.rebuildListeNombreAstral();
@ -607,7 +608,7 @@ export class RdDCalendrier extends Application {
game.system.rdd.calendrier.calendrierPos.top = yPos;
game.system.rdd.calendrier.calendrierPos.left = xPos;
if (game.user.isGM) {
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
}
}
}
@ -615,7 +616,7 @@ export class RdDCalendrier extends Application {
game.system.rdd.calendrier.calendrierPos.top = 200;
game.system.rdd.calendrier.calendrierPos.left = 200;
if (game.user.isGM) {
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
}
this.setPos(game.system.rdd.calendrier.calendrierPos);
}

View File

@ -1,4 +1,5 @@
import { ChatUtility } from "./chat-utility.js";
import { SYSTEM_RDD } from "./constants.js";
import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
@ -686,7 +687,7 @@ export class RdDCombat {
/* -------------------------------------------- */
removeChatMessageActionsPasseArme(passeArme) {
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) {
if (game.settings.get(SYSTEM_RDD, "supprimer-dialogues-combat-chat")) {
ChatUtility.removeChatMessageContaining(`<div data-passearme="${passeArme}">`);
}
}
@ -1298,7 +1299,7 @@ export class RdDCombat {
/* -------------------------------------------- */
/* retourne true si on peut continuer, false si on ne peut pas continuer */
async accorderEntite(when = 'avant-encaissement') {
if (when != game.settings.get("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar")
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
|| this.defender == undefined
|| !this.defender.isEntiteCauchemar()
|| this.defender.isEntiteCauchemarAccordee(this.attacker)) {

View File

@ -54,7 +54,7 @@ Hooks.once("init", async function () {
}
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar", {
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
name: "Accorder le rêve aux entités",
hint: "A quel moment les personnages doivent accorder leur rêve aux entités de cauchemar",
scope: "world",
@ -69,7 +69,7 @@ Hooks.once("init", async function () {
});
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "calendrier", {
game.settings.register(SYSTEM_RDD, "calendrier", {
name: "calendrier",
scope: "world",
config: false,
@ -96,7 +96,7 @@ Hooks.once("init", async function () {
});
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "calendrier-pos", {
game.settings.register(SYSTEM_RDD, "calendrier-pos", {
name: "calendrierPos",
scope: "client",
config: false,
@ -105,7 +105,7 @@ Hooks.once("init", async function () {
});
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "dice-so-nice", {
game.settings.register(SYSTEM_RDD, "dice-so-nice", {
name: "Montrer les dés pour toutes les jets",
hint: "Utilise Dice So Nice pour tous les jets de dés possibles. Décocher pour limiter à la table de résolution",
scope: "client",
@ -115,7 +115,7 @@ Hooks.once("init", async function () {
});
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat", {
game.settings.register(SYSTEM_RDD, "supprimer-dialogues-combat-chat", {
name: "Supprimer les dialogues de combat",
hint: "Si désactivée, tous les dialogues de combat sont conservés dans la conversation",
scope: "world",
@ -124,7 +124,7 @@ Hooks.once("init", async function () {
type: Boolean
});
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "activer-sons-audio", {
game.settings.register(SYSTEM_RDD, "activer-sons-audio", {
name: "Activer les bruitages intégrés",
hint: "Si activé, certaines actions en jeu déclenchent un son d'ambiance",
scope: "world",
@ -133,7 +133,7 @@ Hooks.once("init", async function () {
type: Boolean
});
/* -------------------------------------------- */
game.settings.register("foundryvtt-reve-de-dragon", "appliquer-famine-soif", {
game.settings.register(SYSTEM_RDD, "appliquer-famine-soif", {
name: "Notifier de la famine et la soif pour",
hint: "Indique si les cas de famine et de soif seront indiqués durant Château Dormant",
scope: "world",
@ -178,19 +178,21 @@ Hooks.once("init", async function () {
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { types: ["personnage"], makeDefault: true });
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorCreatureSheet, { types: ["creature"], makeDefault: true });
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
Actors.registerSheet(SYSTEM_RDD, RdDActorSheet, { types: ["personnage"], makeDefault: true });
Actors.registerSheet(SYSTEM_RDD, RdDActorCreatureSheet, { types: ["creature"], makeDefault: true });
Actors.registerSheet(SYSTEM_RDD, RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("foundryvtt-reve-de-dragon", RdDSigneDraconiqueItemSheet, {
Items.registerSheet(SYSTEM_RDD, RdDSigneDraconiqueItemSheet, {
label: "Signe draconique",
types: ["signedraconique"],
makeDefault: true
});
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, { types: ["arme", "armure", "objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique", "gemme",
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson"], makeDefault: true });
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
types: ["arme", "armure", "objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique", "gemme",
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson"], makeDefault: true
});
CONFIG.Combat.documentClass = RdDCombatManager;
// préparation des différents modules

View File

@ -1,3 +1,4 @@
import { SYSTEM_RDD } from "./constants.js";
import { Misc } from "./misc.js";
const listeReglesOptionelles = [
@ -21,10 +22,10 @@ export class ReglesOptionelles extends FormApplication {
for (const regle of listeReglesOptionelles) {
const name = regle.name;
const id = ReglesOptionelles._getIdRegle(name);
game.settings.register("foundryvtt-reve-de-dragon", id, { name: id, scope: "world", config: false, default: regle.default == undefined ? true : regle.default, type: Boolean });
game.settings.register(SYSTEM_RDD, id, { name: id, scope: "world", config: false, default: regle.default == undefined ? true : regle.default, type: Boolean });
}
game.settings.registerMenu("foundryvtt-reve-de-dragon", "rdd-options-regles", {
game.settings.registerMenu(SYSTEM_RDD, "rdd-options-regles", {
name: "Choisir les règles optionelles",
label: "Choix des règles optionelles",
hint: "Ouvre la fenêtre de sélection des règles optionelles",
@ -70,7 +71,7 @@ export class ReglesOptionelles extends FormApplication {
}
static isUsing(name) {
return game.settings.get("foundryvtt-reve-de-dragon", ReglesOptionelles._getIdRegle(name));
return game.settings.get(SYSTEM_RDD, ReglesOptionelles._getIdRegle(name));
}
activateListeners(html) {
@ -78,7 +79,7 @@ export class ReglesOptionelles extends FormApplication {
if (event.currentTarget.attributes.name) {
let id = event.currentTarget.attributes.name.value;
let isChecked = event.currentTarget.checked;
game.settings.set("foundryvtt-reve-de-dragon", id, isChecked);
game.settings.set(SYSTEM_RDD, id, isChecked);
}
});
}

View File

@ -1,3 +1,4 @@
import { SYSTEM_RDD } from "./constants.js";
const rddStatusEffects = [
{ rdd: true, id: 'stun', label: 'EFFECT.StatusStunned', icon: 'icons/svg/stoned.svg', "duration.rounds": 1 },
@ -21,7 +22,7 @@ export class StatusEffects {
static onReady() {
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", {
game.settings.register(SYSTEM_RDD, "use-status-effects", {
name: "use-status-effects",
scope: "world",
config: false,
@ -29,7 +30,7 @@ export class StatusEffects {
type: String
});
game.settings.registerMenu("foundryvtt-reve-de-dragon", "select-status-effect", {
game.settings.registerMenu(SYSTEM_RDD, "select-status-effect", {
name: "Choisir les effets disponibles",
label: "Choix des effets",
hint: "Ouvre la fenêtre de sélection des effets/status appliqués aux acteurs",
@ -58,13 +59,13 @@ export class StatusEffects {
}
static _getUseStatusEffects() {
const setting = game.settings.get("foundryvtt-reve-de-dragon", "use-status-effects");
const setting = game.settings.get(SYSTEM_RDD, "use-status-effects");
return setting ? new Set(setting.split(',')) : new Set();
}
static _setUseStatusEffects(useStatusEffects) {
if (game.user.isGM) {
game.settings.set("foundryvtt-reve-de-dragon", "use-status-effects", StatusEffects._toSetting(useStatusEffects));
game.settings.set(SYSTEM_RDD, "use-status-effects", StatusEffects._toSetting(useStatusEffects));
}
for (let effect of CONFIG.RDD.allEffects) {