Modif sur gestion equipement
This commit is contained in:
parent
11e8a64824
commit
5cc7a17512
@ -125,7 +125,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDrop(event) {
|
||||
RdDUtility.processItemDropEvent(this, event);
|
||||
await RdDUtility.processItemDropEvent(this, event);
|
||||
super._onDrop(event);
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 !");
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user