Modif sur gestion equipement

This commit is contained in:
sladecraven 2020-11-28 09:59:30 +01:00
parent 11e8a64824
commit 5cc7a17512
4 changed files with 12 additions and 9 deletions

View File

@ -125,7 +125,7 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDrop(event) { async _onDrop(event) {
RdDUtility.processItemDropEvent(this, event); await RdDUtility.processItemDropEvent(this, event);
super._onDrop(event); super._onDrop(event);
} }

View File

@ -670,13 +670,15 @@ export class RdDActor extends Actor {
if ( !conteneurId ) return; // pas de conteneur (porté sur soi) if ( !conteneurId ) return; // pas de conteneur (porté sur soi)
let conteneur = this.items.find( conteneur => conteneurId == conteneur._id); // recup conteneur let conteneur = this.items.find( conteneur => conteneurId == conteneur._id); // recup conteneur
if ( conteneur ) { // Si présent if ( conteneur ) { // Si présent
let data2use = duplicate(conteneur.data);
//console.log("Suppression du conteneur1", conteneurId, itemId, conteneur.data.data.contenu); //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); 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 } ); //let newContenu = conteneur.data.data.contenu.filter( function(value, index, arr) { return value != itemId } );
//console.log("Suppression du conteneur2", conteneurId, itemId, newContenu); //console.log("Suppression du conteneur2", conteneurId, itemId, newContenu);
//let update = {_id: conteneurId, "data.contenu": 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) if ( !conteneurId ) return; // pas de conteneur (porté sur soi)
let conteneur = this.items.find( conteneur => conteneurId == conteneur._id); let conteneur = this.items.find( conteneur => conteneurId == conteneur._id);
if ( conteneur && conteneur.type == 'conteneur' ) { if ( conteneur && conteneur.type == 'conteneur' ) {
conteneur.data.data.contenu.push( itemId ); let data2use = duplicate(conteneur.data);
await this.updateEmbeddedEntity("OwnedItem", conteneur.data ); data2use.data.contenu.push( itemId );
await this.updateEmbeddedEntity("OwnedItem", data2use );
} }
} }

View File

@ -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 dragData = JSON.parse(event.dataTransfer.getData("text/plain"));
let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
if ( dropID ) { // Dropped over an item !!! if ( dropID ) { // Dropped over an item !!!
let objetId = dragData.id || dragData.data._id; let objetId = dragData.id || dragData.data._id;
if ( actorSheet.objetVersConteneur[objetId] != dropID ) { if ( actorSheet.objetVersConteneur[objetId] != dropID ) {
if ( actorSheet.actor.testConteneurCapacite(objetId, dropID) ) { if ( actorSheet.actor.testConteneurCapacite(objetId, dropID) ) {
actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]); await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]);
actorSheet.actor.ajouterAConteneur(objetId, dropID); await actorSheet.actor.ajouterAConteneur(objetId, dropID);
} else { } else {
ui.notifications.info("Capacité d'encombrement insuffisante dans le conteneur !"); ui.notifications.info("Capacité d'encombrement insuffisante dans le conteneur !");
} }

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": "0.9.93", "version": "0.9.94",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6", "compatibleCoreVersion": "0.7.6",
"templateVersion": 51, "templateVersion": 51,