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