From 55007b51fb3ea46110d2d3cf0c3d5f8dc607fd72 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 8 Jan 2021 11:56:10 +0100 Subject: [PATCH] #123 : Nettoyage des conteneurs --- module/actor-sheet.js | 3 +++ module/actor.js | 14 ++++++++++++++ system.json | 2 +- templates/actor-sheet.html | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 0c360dd6..f4d18ef6 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -256,6 +256,9 @@ export class RdDActorSheet extends ActorSheet { html.find('#creer-un-objet').click(ev => { this.selectObjetType(); }); + html.find('#nettoyer-conteneurs').click(ev => { + this.actor.nettoyerConteneurs(); + }); // Blessure control html.find('.blessure-control').click(ev => { diff --git a/module/actor.js b/module/actor.js index c48afb97..51ae8055 100644 --- a/module/actor.js +++ b/module/actor.js @@ -732,6 +732,20 @@ export class RdDActor extends Actor { } } + /* -------------------------------------------- */ + /** Fonction de remise à plat de l'équipement (ie vide les champs 'contenu') */ + async nettoyerConteneurs( ) { + let conteneurList = this.items.filter( conteneur => conteneur.type == 'conteneur'); + let conteneurFixedList = []; + for (let conteneur of conteneurList) { + if ( conteneur.data.data.contenu.length > 0 ) { + conteneurFixedList.push( { _id: conteneur._id, 'data.contenu': [] }); + } + } + if ( conteneurFixedList.length > 0) + await this.updateOwnedItem( conteneurFixedList ) ; + } + /* -------------------------------------------- */ detectSurEncombrement( ) { let diffEnc = Number(this.encTotal) - Number(this.data.data.attributs.encombrement.value); diff --git a/system.json b/system.json index fd11f313..ffb26714 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.2.7", + "version": "1.2.8", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.8", "templateVersion": 80, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 3d1ee424..3961d651 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -677,6 +677,9 @@ Encombrement total/max : {{numberFormat data.encTotal decimals=1}} / {{data.attributs.encombrement.value}} {{data.surEncombrementMessage}} - Créer un objet + {{#if data.isGM}} + - Vider tout les conteneurs + {{/if}}