From bb8b56f5347f06d4d68d71776fcd8b074eb2d303 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 20 May 2021 21:36:20 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Limiter=20les=20lancers=20de=20d=C3=A9s=20d?= =?UTF-8?q?e=20nombre=20astraux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-calendrier.js | 34 +++++++++++++++++++--------------- module/rdd-dice.js | 4 ++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 5b14b3ab..d695bd98 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -73,7 +73,7 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ _loadListNombreAstral() { const listeNombreAstraux = game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral"); - return Object.values(listeNombreAstraux); + return listeNombreAstraux ?? []; } /* -------------------------------------------- */ @@ -130,7 +130,7 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ async ajouterNombreAstral(index) { - const nombreAstral = await RdDDice.rollTotal("1dh"); + const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: true, rollMode: "selfroll" }); return { nombreAstral: nombreAstral, valeursFausses: [], @@ -163,21 +163,25 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ async rebuildListeNombreAstral() { - let jourCourant = this.getCurrentDayIndex(); - let jourFin = jourCourant + 12; - let newList = []; - for (let i=0; i<12; i++) { - newList.push(await this.ajouterNombreAstral(jourCourant + i)); - } - if (this.listeNombreAstral) { + if (game.user.isGM) { + let jourCourant = this.getCurrentDayIndex(); + let jourFin = jourCourant + 12; + + let newList = []; for (const na of this.listeNombreAstral) { - if (na && na.index >= jourCourant && na.index < jourFin) { - newList[na.index - jourCourant] = na; + let index = na?.index; + if (index && index >= jourCourant && index < jourFin) { + newList[index - jourCourant] = na; } } + for (let i = 0; i < 12; i++) { + if (newList[i] == undefined) { + newList[i] = await this.ajouterNombreAstral(jourCourant + i); + } + } + this.listeNombreAstral = newList; + game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral); } - this.listeNombreAstral = newList; - game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral); } /* -------------------------------------------- */ async onCalendarButton(ev) { @@ -233,7 +237,7 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ async positionnerHeure(indexHeure) { - if (indexHeure <= this.calendrier.heureRdD){ + if (indexHeure <= this.calendrier.heureRdD) { await this.incrementerJour(); } this.calendrier.heureRdD = indexHeure; @@ -288,7 +292,7 @@ export class RdDCalendrier extends Application { request.isValid = true; if (!request.rolled.isSuccess) { request.isValid = false; - nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral); + nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral, { showDice: true, rollMode: "selfroll" }); // 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 }); diff --git a/module/rdd-dice.js b/module/rdd-dice.js index 4063d8db..ce129a6a 100644 --- a/module/rdd-dice.js +++ b/module/rdd-dice.js @@ -124,13 +124,13 @@ export class RdDDice { CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure; } - static async roll(formula, options = { showDice: false }) { + static async roll(formula, options = { showDice: false, rollMode: undefined}) { const roll = new Roll(formula); await roll.evaluate({ async: true }); if (options.showDice) { roll.showDice = options.showDice; } - await RdDDice.show(roll, game.settings.get("core", "rollMode")); + await RdDDice.show(roll, options.rollMode ?? game.settings.get("core", "rollMode")); return roll; } From fd964690e07d5db5b7e5925e006612064db01d93 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 20 May 2021 21:53:54 +0200 Subject: [PATCH 2/2] Achat fonctionne quel que soit l'Item --- module/actor.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/module/actor.js b/module/actor.js index e3c3a5c4..181b1830 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3454,13 +3454,11 @@ export class RdDActor extends Actor { } if (acheteur) { - // TODO: achat depuis un compendium - const itemData = Misc.data(vendeur?.getObjet(itemId) ?? game.items.get(itemId)); const achat = { - type: itemData.type, - img: itemData.img, - name: itemData.name, - data: itemData.data + type: venteData.item.type, + img: venteData.item.img, + name: venteData.item.name, + data: venteData.item.data } achat.data.quantite = venteData.quantiteTotal; await acheteur.createEmbeddedDocuments("Item", [achat]);