diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js index 3c9d8843..823c6495 100644 --- a/module/actor-creature-sheet.js +++ b/module/actor-creature-sheet.js @@ -62,11 +62,6 @@ export class RdDActorCreatureSheet extends RdDActorSheet { return data; } - /* -------------------------------------------- */ - prepareCreatureData( ) { - - } - /* -------------------------------------------- */ /** @override */ activateListeners(html) { diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 84a2aaf6..b4a03b81 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -148,25 +148,40 @@ export class RdDActorSheet extends ActorSheet { /* -------------------------------------------- */ async confirmerSuppression(li) { let itemId = li.data("item-id"); + let objet = this.actor.items.find( item => item._id == itemId ); + let msgTxt = "
Etes vous certain de vouloir supprimer cet objet ?";
+ let buttons = { delete: {
+ icon: '',
+ label: "Supprimer l'objet",
+ callback: () => {
+ console.log("Delete : ", itemId);
+ this.actor.deleteOwnedItem( itemId );
+ li.slideUp(200, () => this.render(false));
+ }
+ },
+ cancel: {
+ icon: '',
+ label: "Annuler"
+ }
+ }
+ if ( objet.data.type == 'conteneur' && objet.data.data.contenu.length > 0) {
+ msgTxt += "
Cet objet est aussi un conteneur avec du contenu : choisissez l'option de suppression";
+ buttons['deleteall'] = {
+ icon: '',
+ label: "Supprimer le conteneur et tout son contenu",
+ callback: () => {
+ console.log("Delete : ", itemId);
+ this.actor.deleteAllConteneur( itemId );
+ li.slideUp(200, () => this.render(false));
+ }
+ }
+ }
+ msgTxt += "
Etes vous certain de vouloir supprimer cet objet ?
", - buttons: { - delete: { - icon: '', - label: "Supprimer", - callback: () => { - console.log("Delete : ", itemId); - this.actor.deleteOwnedItem( itemId ); - li.slideUp(200, () => this.render(false)); - } - }, - cancel: { - icon: '', - label: "Annuler" - } - }, - default: "cancel", + content: msgTxt, + buttons: buttons, + default: "cancel" }); d.render(true); } diff --git a/module/actor.js b/module/actor.js index e06a9acc..5e050f90 100644 --- a/module/actor.js +++ b/module/actor.js @@ -706,6 +706,31 @@ export class RdDActor extends Actor { return true; } + /* -------------------------------------------- */ + buildSubConteneurObjetList( conteneurId, deleteList ) { + let conteneur = this.items.find( conteneur => conteneurId == conteneur._id); // recup conteneur + if ( conteneur ) { // Si présent + for ( let subId of conteneur.data.data.contenu ) { + let subObj = this.items.find( subobjet => subId == subobjet._id); // recup conteneur + if ( subObj.type == 'conteneur') { + this.buildSubConteneurObjetList( subId, deleteList ); + } + deleteList.push( subId ); + } + } + deleteList.push( conteneurId ); + } + + /* -------------------------------------------- */ + async deleteAllConteneur( itemId ) { + let list = []; + this.buildSubConteneurObjetList( itemId, list ); + //console.log("List to delete", list); + for( let id of list) { + await this.deleteOwnedItem( id ); + } + } + /* -------------------------------------------- */ /** Supprime un item d'un conteneur, sur la base * de leurs ID */ diff --git a/packs/equipement.db b/packs/equipement.db index bd649d1f..084edeb3 100644 --- a/packs/equipement.db +++ b/packs/equipement.db @@ -200,3 +200,4 @@ {"_id":"zQWlnUsd8bPySujd","name":"Aiguille à coudre","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.01,"equipe":false,"resistance":0,"qualite":0,"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/aiguille.webp","effects":[]} {"_id":"zYI8mDiysWtmsSyy","name":"Carquois","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":2,"encombrement":0.1,"equipe":false,"qualite":0,"cout":0.5},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/carquois.webp","effects":[]} {"_id":"zlDa1vwmls6Uf4pt","name":"Bourse de cuir","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"conteneur","data":{"description":"","capacite":0.5,"encombrement":0.01,"equipe":false,"qualite":0,"contenu":[],"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/bourse.webp","effects":[]} +{"_id":"lOI2HVu3B6EDY4sE","name":"Arbalète","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"arme","data":{"description":"Nie jusqu'à 2 points d'armure.
\nRechargement 1 round.
","quantite":1,"encombrement":3,"equipe":false,"dommages":"3","force":"0","resistance":0,"competence":"Arbalète","cout":30,"portee_courte":15,"portee_moyenne":30,"portee_extreme":70,"penetration":2,"rapide":false,"deuxmains":false,"unemain":false,"categorie_parade":""},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/arbalete.webp","effects":[]}