#151 : permission de supprimer une rencontre depuis la fiche de PJ

This commit is contained in:
sladecraven 2021-02-08 14:15:18 +01:00
parent 43218dd282
commit 54a937c620
6 changed files with 39 additions and 4 deletions

View File

@ -124,6 +124,7 @@ export class RdDActorSheet extends ActorSheet {
RdDUtility.filterItemsPerTypeForSheet(data); RdDUtility.filterItemsPerTypeForSheet(data);
data.data.sortReserve = data.data.reve.reserve.list; data.data.sortReserve = data.data.reve.reserve.list;
data.data.rencontres = duplicate(data.data.reve.rencontre.list);
data.data.caseSpeciales = data.itemsByType['casetmr']; data.data.caseSpeciales = data.itemsByType['casetmr'];
RdDUtility.buildArbreDeConteneur(this, data); RdDUtility.buildArbreDeConteneur(this, data);
data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : "";
@ -189,12 +190,17 @@ export class RdDActorSheet extends ActorSheet {
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
// Update Inventory Item
html.find('.item-edit').click(ev => { html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
const item = this.actor.getOwnedItem(li.data("item-id")); const item = this.actor.getOwnedItem(li.data("item-id"));
item.sheet.render(true); 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 // Delete Inventory Item
html.find('.item-delete').click(ev => { html.find('.item-delete').click(ev => {

View File

@ -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) { async updateCoordTMR(coord) {
let tmrPos = duplicate(this.data.data.reve.tmrpos); let tmrPos = duplicate(this.data.data.reve.tmrpos);

View File

@ -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 month = Math.floor(index / 28);
let day = (index - (month*28)) + 1; let day = (index - (month*28)) + 1;
return day+" "+heuresList[month]; return day+" "+heuresList[month];

View File

@ -321,6 +321,8 @@ export class RdDTMRDialog extends Dialog {
isMauvaise ? await TMRRencontres.getMauvaiseRencontre() isMauvaise ? await TMRRencontres.getMauvaiseRencontre()
: await TMRRencontres.getRencontreAleatoire(tmr.type); : await TMRRencontres.getRencontreAleatoire(tmr.type);
rencontre.coord = tmr.coord; rencontre.coord = tmr.coord;
rencontre.date = game.system.rdd.calendrier.getDateFromIndex();
rencontre.heure = game.system.rdd.calendrier.getCurrentHeure();
return rencontre; return rencontre;
} }

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.3.17", "version": "1.3.18",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9", "compatibleCoreVersion": "0.7.9",

View File

@ -546,6 +546,7 @@
</li> </li>
</ul> </ul>
<hr> <hr>
{{!-- Liste de blessures --}} {{!-- Liste de blessures --}}
<h3 class="blessures-title">Blessures:</h3> <h3 class="blessures-title">Blessures:</h3>
<div class="flex-group-left flexcol competence-column"> <div class="flex-group-left flexcol competence-column">
@ -824,6 +825,20 @@
{{/each}} {{/each}}
</ul> </ul>
</div> </div>
<hr>
<div>
<h3>Rencontres présentes:</h3>
<ul class="item-list">
{{#each data.rencontres as |rencontre key|}}
<li class="item flexrow" data-item-id="{{key}}" data-attribute="{{key}}">
<span class="case-label"><a data-id="{{key}}">{{rencontre.rencontre.name}} - {{rencontre.coord}} ({{rencontre.rencontre.date}} - {{rencontre.rencontre.heure}})</a></span>
<div class="item-controls">
<a class="item-control rencontre-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</div>
{{!-- Queues, Souffles, Tetes, Ombre --}} {{!-- Queues, Souffles, Tetes, Ombre --}}
<hr> <hr>