diff --git a/module/actor-sheet.js b/module/actor-sheet.js index e57c6b2a..bf6a53a0 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -125,7 +125,7 @@ export class RdDActorSheet extends ActorSheet { /* -------------------------------------------- */ async _onDrop(event) { - RdDUtility.processItemDropEvent(this, event); + await RdDUtility.processItemDropEvent(this, event); super._onDrop(event); } diff --git a/module/actor.js b/module/actor.js index de9dc0c8..dd0ed7f9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -670,13 +670,15 @@ export class RdDActor extends Actor { if ( !conteneurId ) return; // pas de conteneur (porté sur soi) let conteneur = this.items.find( conteneur => conteneurId == conteneur._id); // recup conteneur if ( conteneur ) { // Si présent + let data2use = duplicate(conteneur.data); //console.log("Suppression du conteneur1", conteneurId, itemId, conteneur.data.data.contenu); - let contenu = conteneur.data.data.contenu; + let contenu = data2use.data.contenu; contenu.splice(contenu.indexOf('itemId'), 1); + //console.log("REMOVED: ", itemId, contenu ); //let newContenu = conteneur.data.data.contenu.filter( function(value, index, arr) { return value != itemId } ); //console.log("Suppression du conteneur2", conteneurId, itemId, newContenu); //let update = {_id: conteneurId, "data.contenu": newContenu }; - await this.updateEmbeddedEntity("OwnedItem", conteneur.data); + await this.updateEmbeddedEntity("OwnedItem", data2use); } } @@ -687,8 +689,9 @@ export class RdDActor extends Actor { if ( !conteneurId ) return; // pas de conteneur (porté sur soi) let conteneur = this.items.find( conteneur => conteneurId == conteneur._id); if ( conteneur && conteneur.type == 'conteneur' ) { - conteneur.data.data.contenu.push( itemId ); - await this.updateEmbeddedEntity("OwnedItem", conteneur.data ); + let data2use = duplicate(conteneur.data); + data2use.data.contenu.push( itemId ); + await this.updateEmbeddedEntity("OwnedItem", data2use ); } } diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 5a27349e..f7543996 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -188,15 +188,15 @@ export class RdDUtility { } /* -------------------------------------------- */ - static processItemDropEvent( actorSheet, event) { + static async processItemDropEvent( actorSheet, event) { let dragData = JSON.parse(event.dataTransfer.getData("text/plain")); let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop if ( dropID ) { // Dropped over an item !!! let objetId = dragData.id || dragData.data._id; if ( actorSheet.objetVersConteneur[objetId] != dropID ) { if ( actorSheet.actor.testConteneurCapacite(objetId, dropID) ) { - actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]); - actorSheet.actor.ajouterAConteneur(objetId, dropID); + await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]); + await actorSheet.actor.ajouterAConteneur(objetId, dropID); } else { ui.notifications.info("Capacité d'encombrement insuffisante dans le conteneur !"); } diff --git a/system.json b/system.json index 87627b3f..c3988e14 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": "0.9.93", + "version": "0.9.94", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.6", "templateVersion": 51,