From 542424c3f8d3ff81f4476780d1c80d4034d4dcbb Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 2 Sep 2021 15:27:01 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Fix:=20jet=20accorder=20entit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/actor.js b/module/actor.js index ec50eab2..5eecede5 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3401,7 +3401,7 @@ export class RdDActor extends Actor { return true; } const tplData = Misc.templateData(this); - let rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(tplData.carac.niveau.value)); + let rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(Misc.templateData(entite).carac.niveau.value)); const rollData = { alias: this.name, rolled: rolled, From c82618e3ab86b633827e60f5c5c9bdf765aac920 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 2 Sep 2021 15:28:14 +0200 Subject: [PATCH 2/5] Typo Message stress --- module/rdd-utility.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 40f64b44..2fec2e3d 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -891,7 +891,7 @@ export class RdDUtility { static distribuerStress(stressValue, raison = 'Inconnu', nomJoueur = undefined) { if (game.user.isGM) { if (stressValue == undefined){ - ui.notifications.warn("Pas de valeuir de stress à distribuer!"); + ui.notifications.warn("Pas de valeur de stress à distribuer!"); return; } if (nomJoueur == undefined) { From 5cecbf3d4de53726699cb26a713bd2a07ea1629e Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 9 Jul 2021 01:01:12 +0200 Subject: [PATCH 3/5] Fix regression calendrier --- module/rdd-calendrier.js | 99 ++++++++++++++++++---------------------- module/rdd-main.js | 1 - 2 files changed, 44 insertions(+), 56 deletions(-) diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index d5c67c3c..75bb47fd 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -45,9 +45,13 @@ export class RdDCalendrier extends Application { return { top: 200, left: 200 }; } - static getDefSigne(moisRdD) { - moisRdD = moisRdD % RDD_MOIS_PAR_AN; - return Object.values(heuresDef).find(h => h.heure == moisRdD); + static getDefSigne(chiffre) { + chiffre = chiffre % RDD_MOIS_PAR_AN; + return Object.values(heuresDef).find(h => h.heure == chiffre); + } + + static getChiffreFromSigne(signe) { + return heuresList.indexOf(signe); } static getCalendrier(index) { @@ -63,55 +67,50 @@ export class RdDCalendrier extends Application { return calendrier; } - /* -------------------------------------------- */ - async initCalendrier() { - // Calendrier - this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier")); - this.calendrier.annee = this.calendrier.annee ?? (this.calendrier.moisRdD == RDD_MOIS_PAR_AN ? 1 : 0); - this.calendrier.moisRdD = (this.calendrier.moisRdD ?? 0) % RDD_MOIS_PAR_AN; - - //console.log("CALENDRIER", this.calendrier); - if (this.calendrier == undefined || this.calendrier.moisRdD == undefined) { - this.calendrier = RdDCalendrier.getCalendrier(0); - if (game.user.isGM) { // Uniquement si GM - game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier); - } - } + constructor() { + super(); // position this.calendrierPos = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier-pos")); if (this.calendrierPos == undefined || this.calendrierPos.top == undefined) { this.calendrierPos = RdDCalendrier.createCalendrierPos(); - if (game.user.isGM) { // Uniquement si GM - game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos); - } + game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos); } + + // Calendrier + this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "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); + } + // nombre astral if (game.user.isGM) { - this.listeNombreAstral = this._loadListNombreAstral(); - await this.rebuildListeNombreAstral(false); // Ensure always up-to-date + this.listeNombreAstral = this.getListeNombreAstral(); + this.rebuildListeNombreAstral(false); // Ensure always up-to-date } console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral); } /* -------------------------------------------- */ - _loadListNombreAstral() { - const listeNombreAstraux = game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral"); - return listeNombreAstraux ?? []; + getListeNombreAstral() { + return game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral") ?? []; } /* -------------------------------------------- */ static get defaultOptions() { - const options = super.defaultOptions; - options.template = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html"; - options.popOut = false; - options.resizable = false; - return options; + return mergeObject(super.defaultOptions, { + template: "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html", + popOut: false, + resizable: false + }); } /* -------------------------------------------- */ getDateFromIndex(index) { const date = RdDCalendrier.getCalendrier(index ?? this.getCurrentDayIndex()); - return (date.jour+1) + ' ' + heuresDef[heuresList[date.moisRdD]].label; + return (date.jour + 1) + ' ' + RdDCalendrier.getDefSigne(date.moisRdD).label; } /* -------------------------------------------- */ @@ -152,7 +151,7 @@ export class RdDCalendrier extends Application { const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: showDice, hideDice: !showDice, rollMode: "selfroll" }); const dateFuture = this.getDateFromIndex(index); if (showDice) { - ChatMessage.create({ + ChatMessage.create({ whisper: ChatMessage.getWhisperRecipients("GM"), content: `Le chiffre astrologique du ${dateFuture} sera le ${nombreAstral}` }); @@ -183,34 +182,23 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ getNombreAstral(indexDate) { - if (this.listeNombreAstral == undefined) { - this.listeNombreAstral = this._loadListNombreAstral() || []; - } - let liste = this.listeNombreAstral; - if ( game.user.isGM ) { - if ( typeof(liste) != 'Array' || liste.length == 0 ) { - this.rebuildListeNombreAstral(); - liste = this.listeNombreAstral; - } - } - let astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate); - + let astralData = this.getListeNombreAstral().find((nombreAstral, i) => nombreAstral.index == indexDate); return astralData?.nombreAstral; } /* -------------------------------------------- */ async rebuildListeNombreAstral(showDice = true) { if (game.user.isGM) { + console.log("rebuildListeNombreAstral", showDice); let jourCourant = this.getCurrentDayIndex(); - let newList = []; for (let i = 0; i < MAX_NOMBRE_ASTRAL; i++) { let dayIndex = jourCourant + i; let na = this.listeNombreAstral.find(n => n.index == dayIndex); if (na) { - newList[i] = duplicate(na); + newList[i] = na; } else { - newList[i] = await this.ajouterNombreAstral(dayIndex, showDice ); + newList[i] = await this.ajouterNombreAstral(dayIndex, showDice); } } //console.log("SAVE list", newList, jourCourant); @@ -242,7 +230,7 @@ export class RdDCalendrier extends Application { } if (this.calendrier.heureRdD >= RDD_HEURES_PAR_JOUR) { this.calendrier.heureRdD -= RDD_HEURES_PAR_JOUR; - this.incrementerJour(); + await this.incrementerJour(); } game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier)); // Notification aux joueurs @@ -253,10 +241,10 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - incrementerJour() { + async incrementerJour() { const index = this.getCurrentDayIndex() + 1; this.calendrier = RdDCalendrier.getCalendrier(index); - this.rebuildListeNombreAstral(); + await this.rebuildListeNombreAstral(); } /* -------------------------------------------- */ @@ -268,7 +256,7 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ async positionnerHeure(indexHeure) { if (indexHeure <= this.calendrier.heureRdD) { - this.incrementerJour(); + await this.incrementerJour(); } this.calendrier.heureRdD = indexHeure; this.calendrier.minutesRelative = 0; @@ -277,13 +265,14 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ fillCalendrierData(formData = {}) { + console.log(this.calendrier); let moisKey = heuresList[this.calendrier.moisRdD]; let heureKey = heuresList[this.calendrier.heureRdD]; + console.log(moisKey, heureKey); const mois = heuresDef[moisKey]; const heure = heuresDef[heureKey]; - //console.log(moisKey, heureKey); formData.heureKey = heureKey; formData.moisKey = moisKey; formData.jourMois = this.calendrier.jour + 1; @@ -436,8 +425,8 @@ export class RdDCalendrier extends Application { async saveEditeur(calendrierData) { this.calendrier.minutesRelative = Number(calendrierData.minutesRelative); this.calendrier.jour = Number(calendrierData.jourMois) - 1; - this.calendrier.moisRdD = RdDCalendrier.getDefSigne(calendrierData.moisKey); - this.calendrier.heureRdD = RdDCalendrier.getDefSigne(calendrierData.heureKey); // Index dans heuresList + 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)); await this.rebuildListeNombreAstral(); @@ -454,7 +443,7 @@ export class RdDCalendrier extends Application { async showCalendarEditor() { let calendrierData = duplicate(this.fillCalendrierData()); if (this.editeur == undefined) { - calendrierData.jourMoisOptions = this.buildJoursMois(); + calendrierData.jourMoisOptions = RdDCalendrier.buildJoursMois(); calendrierData.heuresOptions = [0, 1]; calendrierData.minutesOptions = Array(RDD_MINUTES_PAR_HEURES).fill().map((item, index) => 0 + index); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html', calendrierData); diff --git a/module/rdd-main.js b/module/rdd-main.js index 9cc02aa1..a7dbe5ff 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -221,7 +221,6 @@ Hooks.once("ready", async function () { /* -------------------------------------------- */ /* Affiche/Init le calendrier */ let calendrier = new RdDCalendrier(); - await calendrier.initCalendrier(); let templatePath = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html"; let templateData = {}; renderTemplate(templatePath, templateData).then(html => { From f013a79eecdfb492ef7fee32f65481fdcf67a263 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 3 Sep 2021 22:05:37 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Ne=20pas=20afficher=20l'exp=C3=A9rience=20p?= =?UTF-8?q?our=20les=20jets=20MJ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/actor.js b/module/actor.js index 5eecede5..698fc3ec 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2082,7 +2082,7 @@ export class RdDActor extends Actor { createCallbackExperience() { return { condition: r => r.rolled.isPart && r.finalLevel < 0 && game.settings.get("core", "rollMode") != 'selfroll', - action: r => this.appliquerAjoutExperience(r, game.settings.get("core", "rollMode") != 'blindroll') + action: r => this.appliquerAjoutExperience(r, (game.settings.get("core", "rollMode") != 'blindroll' && !user.isGM)) }; } @@ -2157,7 +2157,7 @@ export class RdDActor extends Actor { let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence); if (xpData && display) { let message = { - whisher: ChatUtility.getWhisperRecipientsAndGMs(this.name), + whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name), content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData) } ChatMessage.create(message); From 2c12fed24f75cff771c0d93657207692258054fb Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 3 Sep 2021 22:24:04 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Fix:=20dommages=20cr=C3=A9atures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les dommages de créatures ne prenaient pas le +dom de la compétence en compte --- module/item-competencecreature.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/item-competencecreature.js b/module/item-competencecreature.js index 3001ee45..d9aaf53b 100644 --- a/module/item-competencecreature.js +++ b/module/item-competencecreature.js @@ -26,7 +26,7 @@ export class RdDItemCompetenceCreature extends Item { competence: itemData.name, resistance: 100, equipe: true, - dommagesReels: arme.data.dommages, + dommagesReels: itemData.data.dommages, penetration: 0, force: 0, rapide: true