From aa97f16f3aaff1d178e8f52353f5eabea4ec3e01 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Tue, 8 Dec 2020 23:12:43 +0100 Subject: [PATCH] =?UTF-8?q?Meilleure=20gestion=20des=20doublons/valeur=20?= =?UTF-8?q?=C3=A0=200=20des=20bonus=20de=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/item-sort.js | 8 ++++++-- module/rdd-calendrier.js | 37 +++++++++++++++++++++++++++++++++---- module/rdd-main.js | 7 +++++++ system.json | 4 ++-- template.json | 6 +++++- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/module/item-sort.js b/module/item-sort.js index c7fae266..a8f03581 100644 --- a/module/item-sort.js +++ b/module/item-sort.js @@ -65,12 +65,16 @@ export class RdDItemSort extends Item { static buildBonusCaseStringFromFormData( formData ) { if ( formData.bonusValue ) { let list = []; + let caseCheck = {}; for(let i=0; i 0 && caseCheck[caseTMR] == undefined ) { + caseCheck[caseTMR] = bonus; + list.push( caseTMR+":"+bonus ); + } } } formData.bonusValue = undefined; diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 07a259f3..c1df9436 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -22,6 +22,7 @@ const saisonsDef = { "printemps": { label: "Printemps"}, "hiver": { label: "Hiver"} }; const RDD_JOUR_PAR_MOIS = 28; +const MAX_NOMBRE_ASTRAL = 30; /* -------------------------------------------- */ export class RdDCalendrier extends Application { @@ -50,10 +51,37 @@ export class RdDCalendrier extends Application { game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos ); } } + // nombre astral + if ( game.user.isGM) { + this.listeNombreAstral = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral")); + if ( this.listeNombreAstral == undefined ) { + let start = this.getCurrentDayIndex(); + let dayList = {} + for(let index=start; index<=start+MAX_NOMBRE_ASTRAL; index++) { // Construction des nombres astraux pour les prochains jours + dayList[index] = this.ajouterNombreAstral(); + } + this.listeNombreAstral = dayList; + game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral ); + } + } console.log(this.calendrier, this.calendrierPos); } + + /* -------------------------------------------- */ + ajouterNombreAstral(index) { + return { + nombreAstral: new Roll("1d12").roll().total, + valeursFausses: [], + index: index + } + } -/* -------------------------------------------- */ + /* -------------------------------------------- */ + getCurrentDayIndex( ) { + return (this.calendrier.moisRdD * 28) + this.calendrier.jour; + } + + /* -------------------------------------------- */ static get defaultOptions() { const options = super.defaultOptions; options.template = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html"; @@ -83,15 +111,16 @@ export class RdDCalendrier extends Application { if ( this.calendrier.jour <= 0) this.calendrier.jour = 1; this.calendrier.moisRdD += 1; + // Ajouter un nouveau nombre astral + let index = this.getCurrentDayIndex(); + this.listeNombreAstral[index] = this.ajouterNombreAstral(); } game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier) ); // Notification aux joueurs game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_sync_time", data: duplicate(this.calendrier) - } ); - - //console.log(this.calendrier, heure, minute); + } ); } /* -------------------------------------------- */ diff --git a/module/rdd-main.js b/module/rdd-main.js index 1996179e..cd171d48 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -129,6 +129,13 @@ Hooks.once("init", async function() { type: Object }); /* -------------------------------------------- */ + game.settings.register("foundryvtt-reve-de-dragon", "liste-nombre-astral", { + name: "liste-nombre-astral", + scope: "world", + config: false, + type: Object + }); + /* -------------------------------------------- */ game.settings.register("foundryvtt-reve-de-dragon", "calendrier-pos", { name: "calendrierPos", scope: "world", diff --git a/system.json b/system.json index 555b554a..15bef857 100644 --- a/system.json +++ b/system.json @@ -2,10 +2,10 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.1.2", + "version": "1.1.3", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.8", - "templateVersion": 58, + "templateVersion": 60, "author": "LeRatierBretonnien", "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ], "styles": ["styles/simple.css"], diff --git a/template.json b/template.json index 06589c9e..35a0573e 100644 --- a/template.json +++ b/template.json @@ -685,11 +685,15 @@ "aspect":"", "description": "" }, + "nombreastral": { + "value": 0, + "jourindex": 1 + }, "monnaie": { "quantite": "", "valeur_deniers":0, "encombrement":0, "description": "" } -} + } }