#125 : Gestion des equipements groupés

This commit is contained in:
sladecraven 2021-01-08 18:58:37 +01:00
parent a432ed6d32
commit 4dbab303f3
4 changed files with 58 additions and 22 deletions

View File

@ -62,11 +62,6 @@ export class RdDActorCreatureSheet extends RdDActorSheet {
return data;
}
/* -------------------------------------------- */
prepareCreatureData( ) {
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {

View File

@ -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 = "<p>Etes vous certain de vouloir supprimer cet objet ?";
let buttons = { delete: {
icon: '<i class="fas fa-check"></i>',
label: "Supprimer l'objet",
callback: () => {
console.log("Delete : ", itemId);
this.actor.deleteOwnedItem( itemId );
li.slideUp(200, () => this.render(false));
}
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Annuler"
}
}
if ( objet.data.type == 'conteneur' && objet.data.data.contenu.length > 0) {
msgTxt += "<br>Cet objet est aussi un conteneur avec du contenu : choisissez l'option de suppression";
buttons['deleteall'] = {
icon: '<i class="fas fa-check"></i>',
label: "Supprimer le conteneur et tout son contenu",
callback: () => {
console.log("Delete : ", itemId);
this.actor.deleteAllConteneur( itemId );
li.slideUp(200, () => this.render(false));
}
}
}
msgTxt += "</p>";
let d = new Dialog({
title: "Confirmer la suppression",
content: "<p>Etes vous certain de vouloir supprimer cet objet ?</p>",
buttons: {
delete: {
icon: '<i class="fas fa-check"></i>',
label: "Supprimer",
callback: () => {
console.log("Delete : ", itemId);
this.actor.deleteOwnedItem( itemId );
li.slideUp(200, () => this.render(false));
}
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Annuler"
}
},
default: "cancel",
content: msgTxt,
buttons: buttons,
default: "cancel"
});
d.render(true);
}

View File

@ -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 */

View File

@ -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":"<p>Nie jusqu'&agrave; 2 points d'armure.</p>\n<p>Rechargement 1 round.</p>","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":[]}