Fix: quantité d'achat depuis commerce illimité

Lors d'un achat depuis un commerce illimité, la quantité du commerce
(non visible) était utilisée au lieux de la quantité réellement achetée
This commit was merged in pull request #827.
This commit is contained in:
2026-08-07 15:25:35 +02:00
parent d590dfce7f
commit 1238460cc8
+10 -7
View File
@@ -223,13 +223,13 @@ export class RdDBaseActor extends Actor {
_onUpdate(changed, options, userId) {
super._onUpdate(changed, options, userId)
if (userId == game.user.id){
if (userId == game.user.id) {
this.delayedRenderSheet('_onUpdate', changed, options)
}
}
async delayedRenderSheet(caller, data, options) {
this.refreshDelayCounter = (this.refreshDelayCounter ?? 0)+1
this.refreshDelayCounter = (this.refreshDelayCounter ?? 0) + 1
if (this.refreshDelayCounter == 1) {
this.renderAfterDelay(this.refreshDelayCounter)
}
@@ -628,17 +628,20 @@ export class RdDBaseActor extends Actor {
return
}
const isItemEmpilable = "quantite" in item.system;
const baseItem = {
id: undefined,
type: item.type,
img: item.img,
name: item.name,
system: foundry.utils.mergeObject(item.system, { quantite: isItemEmpilable ? quantite : undefined }, { inplace: false })
system: foundry.utils.duplicate(item.system)
}
const createItemArray = "quantite" in item.system
? (it, qt) => { it.system.quantite = qt; return [it] }
: (it, qt) => Array.from({ length: qt }, (_, i) => it)
const newItems = isItemEmpilable ? [baseItem] : Array.from({ length: quantite }, (_, i) => baseItem);
const items = await this.createEmbeddedDocuments("Item", newItems);
return newItems.length > 0 ? items[0].id : undefined;
const newItems = createItemArray(baseItem, quantite)
const items = await this.createEmbeddedDocuments("Item", newItems)
return items.length > 0 ? items[0].id : undefined;
}
/* -------------------------------------------- */