Merge pull request 'Drop sur un objet met dans le conteneur parent' (#558) from VincentVk/foundryvtt-reve-de-dragon:v1.5 into v1.5
Reviewed-on: #558
This commit is contained in:
commit
2391fbc4bc
@ -1217,21 +1217,39 @@ export class RdDActor extends Actor {
|
||||
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
||||
const dest = this.getObjet(destId);
|
||||
const src = this.getObjet(srcId);
|
||||
// changer de conteneur
|
||||
if (this.conteneurPeutContenir(dest, item)) {
|
||||
await this.enleverDeConteneur(item, src, params.onEnleverConteneur);
|
||||
await this.ajouterDansConteneur(item, dest, params.onAjouterDansConteneur);
|
||||
}
|
||||
else if (dest?.isEquipementSimilaire(item)) {
|
||||
if (dest?.isEquipementSimilaire(item)) {
|
||||
await this.regrouperEquipementsSimilaires(item, dest);
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const cible = this.getContenantOrParent(dest);
|
||||
// changer de conteneur
|
||||
if (cible == undefined) {
|
||||
await this.enleverDeConteneur(item, src, params.onEnleverConteneur);
|
||||
}
|
||||
else if (this.conteneurPeutContenir(cible, item)) {
|
||||
await this.enleverDeConteneur(item, src, params.onEnleverConteneur);
|
||||
await this.ajouterDansConteneur(item, cible, params.onAjouterDansConteneur);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.computeEncombrementTotalEtMalusArmure();
|
||||
return result;
|
||||
}
|
||||
|
||||
getContenantOrParent(dest) {
|
||||
if (!dest || dest.isConteneur()) {
|
||||
return dest;
|
||||
}
|
||||
return this.getContenant(dest);
|
||||
}
|
||||
|
||||
getContenant(item) {
|
||||
return this.items.find(it => it.isConteneur() && Misc.templateData(it).contenu.includes(item.id));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
conteneurPeutContenir(dest, item) {
|
||||
if (!dest) {
|
||||
|
Loading…
Reference in New Issue
Block a user