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: public/foundryvtt-reve-de-dragon#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
|
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
||||||
const dest = this.getObjet(destId);
|
const dest = this.getObjet(destId);
|
||||||
const src = this.getObjet(srcId);
|
const src = this.getObjet(srcId);
|
||||||
// changer de conteneur
|
if (dest?.isEquipementSimilaire(item)) {
|
||||||
if (this.conteneurPeutContenir(dest, item)) {
|
|
||||||
await this.enleverDeConteneur(item, src, params.onEnleverConteneur);
|
|
||||||
await this.ajouterDansConteneur(item, dest, params.onAjouterDansConteneur);
|
|
||||||
}
|
|
||||||
else if (dest?.isEquipementSimilaire(item)) {
|
|
||||||
await this.regrouperEquipementsSimilaires(item, dest);
|
await this.regrouperEquipementsSimilaires(item, dest);
|
||||||
result = false;
|
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();
|
await this.computeEncombrementTotalEtMalusArmure();
|
||||||
return result;
|
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) {
|
conteneurPeutContenir(dest, item) {
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
|
Loading…
Reference in New Issue
Block a user