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

@ -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);
}