diff --git a/module/actor.js b/module/actor.js index 94369442..64ac12be 100644 --- a/module/actor.js +++ b/module/actor.js @@ -382,7 +382,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async verifierPotionsEnchantees() { - let potionsEnchantees = this.filterItemsData(it => it.type == 'potion' && it.data.magique); + let potionsEnchantees = this.filterItemsData(it => it.type == 'potion' && it.data.categorie.toLowerCase().includes('enchant') ); for (let potion of potionsEnchantees) { if (!potion.prpermanent) { console.log(potion); diff --git a/module/rdd-astrologie-editeur.js b/module/rdd-astrologie-editeur.js index 75913483..65ea242d 100644 --- a/module/rdd-astrologie-editeur.js +++ b/module/rdd-astrologie-editeur.js @@ -25,7 +25,7 @@ /* -------------------------------------------- */ async resetNombreAstraux() { game.system.rdd.calendrier.resetNombreAstral(); - await game.system.rdd.calendrier.rebuildListeNombreAstral(); + await game.system.rdd.calendrier.rebuildListeNombreAstral( 'reset' ); game.system.rdd.calendrier.showAstrologieEditor(); } diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 79188dc4..26d7715c 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -139,8 +139,8 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async ajouterNombreAstral(index) { - const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: true, rollMode: "selfroll" }); + async ajouterNombreAstral(index, showdice = true) { + const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: showdice, rollMode: "selfroll" }); const dateFuture = this.getDateFromIndex(index); ChatMessage.create({ whisper: ChatMessage.getWhisperRecipients("GM"), @@ -175,19 +175,15 @@ export class RdDCalendrier extends Application { 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 liste = this.listeNombreAstral || []; let astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate); + return astralData?.nombreAstral; } /* -------------------------------------------- */ - async rebuildListeNombreAstral() { + async rebuildListeNombreAstral( raison = 'incjour') { if (game.user.isGM) { let jourCourant = this.getCurrentDayIndex(); @@ -198,14 +194,15 @@ export class RdDCalendrier extends Application { if ( na ) { newList[i] = duplicate(na); } else { - newList[i] = await this.ajouterNombreAstral(dayIndex); + newList[i] = await this.ajouterNombreAstral(dayIndex, raison == 'incjour' ); } } console.log("SAVE list", newList, jourCourant); - this.listeNombreAstral = newList; game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral); + this.listeNombreAstral = newList; } } + /* -------------------------------------------- */ async onCalendarButton(ev) { ev.preventDefault(); @@ -427,7 +424,7 @@ export class RdDCalendrier extends Application { this.calendrier.heureRdD = heuresList.findIndex(heure => heure === calendrierData.heureKey);; // Index dans heuresList game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier)); - await this.rebuildListeNombreAstral(); + await this.rebuildListeNombreAstral( 'reset' ); game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_sync_time", diff --git a/system.json b/system.json index fac3fbae..182896ca 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.4.29", + "version": "1.4.30", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "0.8.99",