diff --git a/module/actor-sheet.js b/module/actor-sheet.js index eb2c0bdd..15d2eb2f 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -124,6 +124,7 @@ export class RdDActorSheet extends ActorSheet { RdDUtility.filterItemsPerTypeForSheet(data); data.data.sortReserve = data.data.reve.reserve.list; + data.data.rencontres = duplicate(data.data.reve.rencontre.list); data.data.caseSpeciales = data.itemsByType['casetmr']; RdDUtility.buildArbreDeConteneur(this, data); data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; @@ -189,18 +190,23 @@ export class RdDActorSheet extends ActorSheet { // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; - // Update Inventory Item html.find('.item-edit').click(ev => { const li = $(ev.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("item-id")); item.sheet.render(true); }); + // Update Inventory Item + html.find('.rencontre-delete').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + const rencontreKey = li.data("item-id"); + this.actor.deleteTMRRencontre(rencontreKey); + }); // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); RdDUtility.confirmerSuppression(this, li); - }); + }); html.find('.subacteur-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); RdDUtility.confirmerSuppressionSubacteur(this, li); diff --git a/module/actor.js b/module/actor.js index 29799b07..4b7499c4 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1189,6 +1189,17 @@ export class RdDActor extends Actor { } } + /* -------------------------------------------- */ + async deleteTMRRencontre(rencontreKey) { + let list = duplicate(this.data.data.reve.rencontre.list); + let newList = []; + for (let i = 0; i < list.length; i++) { + if ( i != rencontreKey) + newList.push( list[i]); + } + await this.update({ "data.reve.rencontre.list": newList }); + } + /* -------------------------------------------- */ async updateCoordTMR(coord) { let tmrPos = duplicate(this.data.data.reve.tmrpos); diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index d0f7c47b..705317b6 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -79,7 +79,8 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - getDateFromIndex( index ) { + getDateFromIndex( index = undefined ) { + if ( !index) index = this.getCurrentDayIndex(); let month = Math.floor(index / 28); let day = (index - (month*28)) + 1; return day+" "+heuresList[month]; diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index 298a12a5..924b020a 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -321,6 +321,8 @@ export class RdDTMRDialog extends Dialog { isMauvaise ? await TMRRencontres.getMauvaiseRencontre() : await TMRRencontres.getRencontreAleatoire(tmr.type); rencontre.coord = tmr.coord; + rencontre.date = game.system.rdd.calendrier.getDateFromIndex(); + rencontre.heure = game.system.rdd.calendrier.getCurrentHeure(); return rencontre; } diff --git a/system.json b/system.json index fed85608..e0db5a9b 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.3.17", + "version": "1.3.18", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index fddb959a..169ba52e 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -546,6 +546,7 @@