Fix: création calendrier en double #485
@ -72,7 +72,7 @@ export class RdDCalendrier extends Application {
|
||||
// nombre astral
|
||||
if (game.user.isGM) {
|
||||
this.listeNombreAstral = this._loadListNombreAstral();
|
||||
await this.rebuildListeNombreAstral(); // Ensure always up-to-date
|
||||
await this.rebuildListeNombreAstral('hidden'); // Ensure always up-to-date
|
||||
}
|
||||
console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral);
|
||||
}
|
||||
@ -136,13 +136,15 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async ajouterNombreAstral(index) {
|
||||
async ajouterNombreAstral(index, mode ='display') {
|
||||
const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: true, rollMode: "selfroll" });
|
||||
const dateFuture = this.getDateFromIndex(index);
|
||||
if (mode =='display'){
|
||||
ChatMessage.create({
|
||||
whisper: ChatMessage.getWhisperRecipients("GM"),
|
||||
content: `Le chiffre astrologique du ${dateFuture} sera le ${nombreAstral}`
|
||||
});
|
||||
}
|
||||
return {
|
||||
nombreAstral: nombreAstral,
|
||||
valeursFausses: [],
|
||||
@ -182,7 +184,7 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rebuildListeNombreAstral() {
|
||||
async rebuildListeNombreAstral(display = 'display') {
|
||||
if (game.user.isGM) {
|
||||
let jourCourant = this.getCurrentDayIndex();
|
||||
let jourFin = jourCourant + 12;
|
||||
@ -196,13 +198,14 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
for (let i = 0; i < 12; i++) {
|
||||
if (newList[i] == undefined) {
|
||||
newList[i] = await this.ajouterNombreAstral(jourCourant + i);
|
||||
newList[i] = await this.ajouterNombreAstral(jourCourant + i, display);
|
||||
}
|
||||
}
|
||||
this.listeNombreAstral = newList;
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async onCalendarButton(ev) {
|
||||
ev.preventDefault();
|
||||
@ -214,7 +217,7 @@ export class RdDCalendrier extends Application {
|
||||
else if (calendarSet) {
|
||||
this.positionnerHeure(Number(calendarSet.value));
|
||||
}
|
||||
await this.updateDisplay();
|
||||
this.updateDisplay();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -226,7 +229,7 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
if (this.calendrier.heureRdD > 11) {
|
||||
this.calendrier.heureRdD -= 12;
|
||||
await this.incrementerJour();
|
||||
this.incrementerJour();
|
||||
}
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
|
||||
// Notification aux joueurs
|
||||
@ -266,26 +269,25 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
fillCalendrierData(formData = {}) {
|
||||
fillCalendrierData() {
|
||||
let moisKey = heuresList[this.calendrier.moisRdD];
|
||||
let heureKey = heuresList[this.calendrier.heureRdD];
|
||||
|
||||
const mois = heuresDef[moisKey];
|
||||
const heure = heuresDef[heureKey];
|
||||
|
||||
//console.log(moisKey, heureKey);
|
||||
formData.heureKey = heureKey;
|
||||
formData.moisKey = moisKey;
|
||||
formData.jourMois = this.calendrier.jour + 1;
|
||||
formData.nomMois = mois.label; // heures et mois nommés identiques
|
||||
formData.iconMois = dossierIconesHeures + mois.icon;
|
||||
formData.nomHeure = heure.label;
|
||||
formData.iconHeure = dossierIconesHeures + heure.icon;
|
||||
formData.nomSaison = saisonsDef[mois.saison].label;
|
||||
formData.heureRdD = this.calendrier.heureRdD;
|
||||
formData.minutesRelative = this.calendrier.minutesRelative;
|
||||
formData.isGM = game.user.isGM;
|
||||
return formData;
|
||||
return {
|
||||
heureKey: heureKey,
|
||||
moisKey: moisKey,
|
||||
jourMois: this.calendrier.jour + 1,
|
||||
nomMois: mois.label,
|
||||
iconMois: dossierIconesHeures + mois.icon,
|
||||
nomHeure: heure.label,
|
||||
iconHeure: dossierIconesHeures + heure.icon,
|
||||
nomSaison: saisonsDef[mois.saison].label,
|
||||
heureRdD: this.calendrier.heureRdD,
|
||||
minutesRelative: this.calendrier.minutesRelative,
|
||||
isGM: game.user.isGM
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -371,10 +373,7 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getData() {
|
||||
let formData = super.getData();
|
||||
|
||||
this.fillCalendrierData(formData);
|
||||
|
||||
let formData = this.fillCalendrierData();
|
||||
this.setPos(this.calendrierPos);
|
||||
return formData;
|
||||
}
|
||||
@ -441,7 +440,7 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showCalendarEditor() {
|
||||
let calendrierData = duplicate(this.fillCalendrierData());
|
||||
let calendrierData = this.fillCalendrierData();
|
||||
if (this.editeur == undefined) {
|
||||
calendrierData.jourMoisOptions = Array(28).fill().map((item, index) => 1 + index);
|
||||
calendrierData.heuresOptions = [0, 1];
|
||||
@ -455,7 +454,7 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showAstrologieEditor() {
|
||||
let calendrierData = duplicate(this.fillCalendrierData());
|
||||
let calendrierData = this.fillCalendrierData();
|
||||
let astrologieArray = [];
|
||||
for (let astralData of this.listeNombreAstral) {
|
||||
astralData.humanDate = this.getDateFromIndex(astralData.index);
|
||||
@ -481,7 +480,7 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
|
||||
|
||||
await this.updateDisplay();
|
||||
this.updateDisplay();
|
||||
|
||||
html.find('.calendar-btn').click(ev => this.onCalendarButton(ev));
|
||||
|
||||
|
@ -210,21 +210,21 @@ function messageDeBienvenue() {
|
||||
/* -------------------------------------------- */
|
||||
/* Foundry VTT Initialization */
|
||||
/* -------------------------------------------- */
|
||||
Hooks.once("ready", function () {
|
||||
Hooks.once("ready", async () => {
|
||||
|
||||
StatusEffects.onReady();
|
||||
RdDHerbes.initializeHerbes();
|
||||
RdDDice.onReady();
|
||||
/* -------------------------------------------- */
|
||||
/* Affiche/Init le calendrier */
|
||||
let calendrier = new RdDCalendrier();
|
||||
calendrier.initCalendrier();
|
||||
let templatePath = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html";
|
||||
let templateData = {};
|
||||
|
||||
game.system.rdd.calendrier = new RdDCalendrier();
|
||||
await game.system.rdd.calendrier.initCalendrier();
|
||||
renderTemplate(templatePath, templateData).then(html => {
|
||||
calendrier.render(true);
|
||||
game.system.rdd.calendrier.render(true);
|
||||
});
|
||||
game.system.rdd.calendrier = calendrier; // Reference;
|
||||
|
||||
// Avertissement si joueur sans personnage
|
||||
if (!game.user.isGM && game.user.character == undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user