Merge pull request 'v10.0.29: Fix empilement' (#566) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10
Reviewed-on: #566
This commit is contained in:
commit
975e525fd5
@ -1187,8 +1187,8 @@ export class RdDActor extends Actor {
|
||||
const src = this.getObjet(srcId);
|
||||
const dest = this.getObjet(destId);
|
||||
const cible = this.getContenantOrParent(dest);
|
||||
const messageEquipementDifferent = item.messageEquipementDifferent(dest);
|
||||
if (dest && !messageEquipementDifferent) {
|
||||
const [empilable, message] = item.isEquipementEmpilable(dest);
|
||||
if (empilable) {
|
||||
await this.regrouperEquipementsSimilaires(item, dest);
|
||||
result = false;
|
||||
}
|
||||
@ -1196,9 +1196,11 @@ export class RdDActor extends Actor {
|
||||
else if (!cible || this.conteneurPeutContenir(cible, item)) {
|
||||
await this.enleverDeConteneur(item, src, params.onEnleverConteneur);
|
||||
await this.ajouterDansConteneur(item, cible, params.onAjouterDansConteneur);
|
||||
}
|
||||
else {
|
||||
ui.notifications.info(messageEquipementDifferent);
|
||||
if (message && !dest.isConteneur()) {
|
||||
ui.notifications.info(cible
|
||||
? `${message}<br>${item.name} a été déplacé dans: ${cible.name}`
|
||||
: `${message}<br>${item.name} a été sorti du conteneur`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,30 +242,32 @@ export class RdDItem extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// détermine si deux équipements sont similaires: de même type, et avec les même champs hormis la quantité
|
||||
messageEquipementDifferent(other) {
|
||||
if (!other || !this.isEquipement()) return undefined;
|
||||
isEquipementEmpilable(other) {
|
||||
if (!other || !this.isEquipement()) {
|
||||
return [false, undefined];
|
||||
}
|
||||
|
||||
let message = undefined;
|
||||
if (this.system.quantite == undefined) {
|
||||
message = `Impossible de regrouper des ${this.type}, ils ne sont pas empilables`;
|
||||
return [false, `Impossible de regrouper des ${this.type}, ils ne sont pas empilables`];
|
||||
}
|
||||
else if (this.type != other.type) {
|
||||
message = `Impossible de regrouper des ${this.type} avec des ${other.type}`;
|
||||
return [false, `Impossible de regrouper des ${this.type} avec des ${other.type}`];
|
||||
}
|
||||
else if (this.name != other.name) {
|
||||
message = `Impossible de regrouper ${this.name} avec ${other.name}`;
|
||||
return [false, `Impossible de regrouper ${this.name} avec ${other.name}`];
|
||||
}
|
||||
else {
|
||||
const differences = Object.entries(this.system)
|
||||
.filter(([key, value]) => !['quantite', 'cout'].includes(key) && value != other.system[key]);
|
||||
.filter(([key, value]) => !['quantite', 'cout', 'encTotal'].includes(key) && value != other.system[key]);
|
||||
if (differences.length > 0) {
|
||||
message = `Impossible de regrouper les ${this.type} ${this.name}: `;
|
||||
let message = `Impossible de regrouper les ${this.type} ${this.name}: `;
|
||||
for (const [key, value] of differences) {
|
||||
message += `<br>${key}: ${value} vs ${other.system[key]}`;
|
||||
}
|
||||
return [false, message];
|
||||
}
|
||||
}
|
||||
return message;
|
||||
return [true, undefined];
|
||||
}
|
||||
|
||||
async proposerVente() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"id": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"version": "10.0.28",
|
||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.28.zip",
|
||||
"version": "10.0.29",
|
||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.29.zip",
|
||||
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
|
||||
"compatibility": {
|
||||
"minimum": "10",
|
||||
|
Loading…
Reference in New Issue
Block a user