Fixes préparatoire à actor échoppe #599
| @@ -3776,7 +3776,7 @@ export class RdDActor extends Actor { | ||||
|     const vente = achat.vente; | ||||
|     const quantite = (achat.choix.nombreLots ?? 1) * (vente.tailleLot); | ||||
|     const itemVendu = vendeur?.getObjet(vente.item._id) ?? (await RdDItem.getCorrespondingItem(vente.item)); | ||||
|     if (!this.verifierQuantite(service, vendeur, itemVendu, quantite)) { | ||||
|     if (!this.verifierQuantite(service, vente.serviceSubItem, vendeur, itemVendu, quantite)) { | ||||
|       ChatUtility.notifyUser(achat.userId, 'warn', `Le vendeur n'a pas assez de ${itemVendu.name} !`); | ||||
|       return | ||||
|     } | ||||
| @@ -3828,8 +3828,8 @@ export class RdDActor extends Actor { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   verifierQuantite(service, vendeur, item, quantiteTotal) { | ||||
|     const disponible = service ? service.getQuantiteDisponible(item, quantiteTotal) : (vendeur ? (item?.getQuantite() ?? 0) : quantiteTotal); | ||||
|   verifierQuantite(service, serviceSubItem, vendeur, item, quantiteTotal) { | ||||
|     const disponible = service ? service.getQuantiteDisponible(serviceSubItem, quantiteTotal) : (vendeur ? (item?.getQuantite() ?? 0) : quantiteTotal); | ||||
|     return disponible >= quantiteTotal; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -30,13 +30,14 @@ export class DialogItemAchat extends Dialog { | ||||
|   } | ||||
|  | ||||
|  | ||||
|   static async onAcheter({ item, vendeur, acheteur, service, tailleLot, prixLot, nbLots, quantiteIllimite, chatMessageIdVente }) { | ||||
|   static async onAcheter({ item, vendeur, acheteur, service, serviceSubItem, tailleLot, prixLot, nbLots, quantiteIllimite, chatMessageIdVente }) { | ||||
|     const venteData = { | ||||
|       item, | ||||
|       actingUserId: game.user.id, | ||||
|       vendeurId: vendeur?.id, | ||||
|       vendeur, | ||||
|       acheteur, | ||||
|       serviceSubItem: serviceSubItem, | ||||
|       service, | ||||
|       tailleLot, | ||||
|       quantiteIllimite, | ||||
|   | ||||
| @@ -23,7 +23,7 @@ export class RdDItemService extends RdDItem { | ||||
|   getProprietes() { return []; } | ||||
|  | ||||
|   getServiceItem(itemRef) { | ||||
|     if (this.isService()) { | ||||
|     if (itemRef && this.isService()) { | ||||
|       return this.system.items.find(it => it.id == itemRef.id && it.pack == itemRef.pack); | ||||
|     } | ||||
|     return undefined; | ||||
| @@ -64,6 +64,7 @@ export class RdDItemService extends RdDItem { | ||||
|     await DialogItemAchat.onAcheter({ | ||||
|       item: await RdDItem.getCorrespondingItem(subItem), | ||||
|       acheteur, | ||||
|       serviceSubItem: subItem, | ||||
|       service: this, | ||||
|       quantiteIllimite: this.system.illimite, | ||||
|       nbLots, | ||||
|   | ||||
| @@ -428,7 +428,7 @@ export class RdDItem extends Item { | ||||
|     } | ||||
|     await DialogItemVente.display({ | ||||
|       item: this, | ||||
|       service, | ||||
|       service: service, | ||||
|       quantiteMax, | ||||
|       callback: async (vente) => { | ||||
|         vente["properties"] = this.getProprietes(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user