Correction achat par lots
Positionnement de la quantité dans ItemData.data.quantite
This commit is contained in:
		| @@ -3600,6 +3600,7 @@ export class RdDActor extends Actor { | ||||
|     const buttonAcheter = html.find(".button-acheter")[0]; | ||||
|     const vente = DialogItemAchat.prepareVenteData(buttonAcheter, achat.vendeurId, vendeur, acheteur); | ||||
|     const itemId = vente.item._id; | ||||
|     const isItemEmpilable = "quantite" in vente.item.data; | ||||
|  | ||||
|     const coutDeniers = Math.floor((achat.prixTotal ?? 0) * 100); | ||||
|     achat.quantiteTotal = (achat.choix.nombreLots ?? 1) * (vente.tailleLot); | ||||
| @@ -3612,7 +3613,7 @@ export class RdDActor extends Actor { | ||||
|     } | ||||
|     const itemVendu = Misc.data(vendeur?.getObjet(itemId)); | ||||
|     if (itemVendu) { | ||||
|       if ("quantite" in itemVendu.data ? itemVendu.data.quantite < achat.quantiteTotal : achat.choix.nombreLots != 1) { | ||||
|       if (isItemEmpilable ? itemVendu.data.quantite < achat.quantiteTotal : achat.choix.nombreLots != 1) { | ||||
|         await acheteur?.ajouterDeniers(coutDeniers); | ||||
|         ChatUtility.notifyUser(achat.userId, 'warn', `Le vendeur n'a plus assez de ${vente.item.name} !`); | ||||
|         return; | ||||
| @@ -3631,10 +3632,9 @@ export class RdDActor extends Actor { | ||||
|         type: vente.item.type, | ||||
|         img: vente.item.img, | ||||
|         name: vente.item.name, | ||||
|         data: vente.item.data, | ||||
|         quantite: "quantite" in vente.item ? achat.quantiteTotal : undefined | ||||
|         data: mergeObject(vente.item.data, {quantite: isItemEmpilable ? achat.quantiteTotal : undefined}), | ||||
|       } | ||||
|       let listeAchat = ("quantite" in vente.item) ? [achatData] : Array.from({length: achat.quantiteTotal}, (_, i) => achatData) | ||||
|       let listeAchat = isItemEmpilable ? [achatData] : Array.from({length: achat.quantiteTotal}, (_, i) => achatData) | ||||
|       let items = await acheteur.createEmbeddedDocuments("Item", listeAchat) | ||||
|       if (achat.choix.consommer && vente.item.type == 'nourritureboisson') { | ||||
|         achat.choix.doses = achat.choix.nombreLots; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user