Ajout des "boutiques"

Une boutique est un Item service permettant de définir l'inventaire
en vente, et de le vendre facilement.

Les boutiques peuvent être accédées par les joueurs (avec le lien)
pour y faire leurs courses.
This commit is contained in:
Vincent Vandemeulebrouck
2022-12-23 00:34:17 +01:00
parent f397c82c6d
commit 7c70e944b1
15 changed files with 506 additions and 98 deletions

View File

@ -2,21 +2,24 @@ import { HtmlUtility } from "./html-utility.js";
export class DialogItemVente extends Dialog {
static async display(item, callback) {
const quantite = item.isConteneur() ? 1 : item.system.quantite;
static async display({ item, callback, service = undefined, quantiteMax = undefined }) {
const quantite = quantiteMax ?? item.getQuantite();
const isOwned = item.isOwned;
// const isOwned = item.isOwned || service?.actor;
const venteData = {
item: item,
alias: item.actor?.name ?? game.user.name,
vendeurId: item.actor?.id,
alias: item.actor?.name ?? service?.name ?? game.user.name,
serviceId: service?.id,
vendeurId: item.actor?.id ?? service?.actor?.id,
prixOrigine: item.system.cout,
prixUnitaire: item.system.cout,
prixLot: item.system.cout,
tailleLot: 1,
quantiteNbLots: quantite,
quantiteMaxLots: quantite,
quantiteMax: quantite ,
quantiteIllimite: !item.isOwned,
isOwned: item.isOwned,
quantiteMax: quantite,
quantiteIllimite: service? service.system.illimite : !isOwned,
isOwned: isOwned,
};
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-vente.html`, venteData);
return new DialogItemVente(venteData, html, callback).render(true);
@ -54,7 +57,7 @@ export class DialogItemVente extends Dialog {
await this.html.find(".quantiteIllimite").change();
await this.html.find(".prixLot").change();
this.callback(this.venteData);
}
}
/* -------------------------------------------- */
setPrixLot(prixLot) {
@ -68,13 +71,11 @@ export class DialogItemVente extends Dialog {
this.html.find(".prixLot").val(this.venteData.prixLot);
}
this.venteData.tailleLot = tailleLot;
if (this.venteData.isOwned) {
// recalculer le nombre de lots max
this.venteData.quantiteMaxLots = Math.floor(this.venteData.quantiteMax / tailleLot);
this.venteData.quantiteNbLots = Math.min(this.venteData.quantiteMaxLots, this.venteData.quantiteNbLots);
this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
this.html.find(".quantiteNbLots").attr("max", this.venteData.quantiteMaxLots)
}
// recalculer le nombre de lots max
this.venteData.quantiteMaxLots = Math.floor(this.venteData.quantiteMax / tailleLot);
this.venteData.quantiteNbLots = Math.min(this.venteData.quantiteMaxLots, this.venteData.quantiteNbLots);
this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
this.html.find(".quantiteNbLots").attr("max", this.venteData.quantiteMaxLots)
}
setNbLots(nbLots) {