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:
@@ -220,16 +220,16 @@ export class RdDBaseActor extends Actor {
|
||||
await this.delayedRenderSheet('_preUpdate', changed, options)
|
||||
return super._preUpdate(changed, options, user)
|
||||
}
|
||||
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user