Fix: vente depuis un commerce
La quantité proposée est limitée à la quantité disponible ou illimité si le commerce est illimité
This commit is contained in:
parent
39d14c8496
commit
8e0825b6b9
@ -4,7 +4,7 @@ export class DialogItemVente extends Dialog {
|
||||
|
||||
static async display({ item, callback, quantiteMax = undefined }) {
|
||||
const quantite = quantiteMax ?? item.getQuantite() ?? 1;
|
||||
const isOwned = item.isOwned;
|
||||
const isOwned = item.parent;
|
||||
const venteData = {
|
||||
item: item,
|
||||
alias: item.actor?.name ?? game.user.name,
|
||||
@ -16,7 +16,7 @@ export class DialogItemVente extends Dialog {
|
||||
quantiteNbLots: quantite,
|
||||
quantiteMaxLots: quantite,
|
||||
quantiteMax: quantite,
|
||||
quantiteIllimite: !isOwned || quantiteMax == undefined,
|
||||
quantiteIllimite: item.isItemCommerce() ? quantiteMax == undefined : !isOwned,
|
||||
isOwned: isOwned,
|
||||
};
|
||||
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-vente.html`, venteData);
|
||||
@ -41,8 +41,7 @@ export class DialogItemVente extends Dialog {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
this.html = html;
|
||||
HtmlUtility._showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite)
|
||||
|
||||
this.setQuantiteIllimite(this.venteData.quantiteIllimite);
|
||||
this.html.find(".tailleLot").change(event => this.setTailleLot(Number(event.currentTarget.value)));
|
||||
this.html.find(".quantiteNbLots").change(event => this.setNbLots(Number(event.currentTarget.value)));
|
||||
this.html.find(".quantiteIllimite").change(event => this.setQuantiteIllimite(event.currentTarget.checked));
|
||||
|
@ -259,8 +259,12 @@ export class RdDItem extends Item {
|
||||
return this.system.cout ?? 0
|
||||
}
|
||||
|
||||
isItemCommerce() {
|
||||
return this.parent?.type == 'commerce';
|
||||
}
|
||||
|
||||
calculerPrixCommercant() {
|
||||
if (this.parent?.type == 'commerce') {
|
||||
if (this.isItemCommerce()) {
|
||||
// appliquer le pourcentage
|
||||
return this.parent.calculerPrix(this);
|
||||
}
|
||||
|
@ -2,19 +2,21 @@
|
||||
<img class="chat-icon" src="{{item.img}}" title="{{item.name}}" alt="{{item.name}}" />
|
||||
<h4>{{item.name}}</h4>
|
||||
<div class="flexcol">
|
||||
{{#if isOwned}}
|
||||
<div class="flexrow flex-group-left">
|
||||
{{#if quantiteIllimite}}
|
||||
<label>Quantité illimitée</label>
|
||||
{{else}}
|
||||
<label>Quantité disponible</label>
|
||||
<label>{{quantiteMax}}</label>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="flexrow flex-group-left">
|
||||
<label>Nombre de lots</label>
|
||||
<div class="flexrow">
|
||||
{{#unless isOwned}}
|
||||
<input name="quantiteIllimite" class="quantiteIllimite flex-shrink" type="checkbox" {{#if
|
||||
quantiteIllimite}}checked{{/if}} />
|
||||
<label class="label-quantiteIllimite flex-shrink">Illimités</label>
|
||||
<label class="label-quantiteIllimite flex-shrink">disponibles</label>
|
||||
{{/unless}}
|
||||
<input name="quantiteNbLots" class="quantiteNbLots flex-shrink number-x2" type="number" min="1"
|
||||
max="{{quantiteMaxLots}}" value="{{quantiteNbLots}}" data-dtype="Number" />
|
||||
@ -22,8 +24,10 @@
|
||||
</div>
|
||||
<div class="flexrow flex-group-left">
|
||||
<label for="tailleLot">Taille d'un lot</label>
|
||||
<input name="tailleLot" class="tailleLot flex-shrink number-x2" type="number" min="1"
|
||||
max="{{quantiteMax}}" value="{{tailleLot}}" data-dtype="Number" />
|
||||
<span class="flexrow">
|
||||
<input name="tailleLot" class="tailleLot flex-shrink number-x2" type="number" min="1"
|
||||
max="{{quantiteMax}}" value="{{tailleLot}}" data-dtype="Number" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="flexrow flex-group-left">
|
||||
<label>Prix unitaire</label>
|
||||
@ -32,7 +36,7 @@
|
||||
<div class="flexrow flex-group-left">
|
||||
<label for="prixLot">Prix du lot</label>
|
||||
<span class="flexrow">
|
||||
<input name="prixLot" class="prixLot flex-shrink" type="number" value="{{numberFormat prixLot decimals=2 sign=false}}"
|
||||
<input name="prixLot" class="prixLot flex-shrink number-x3" type="number" value="{{numberFormat prixLot decimals=2 sign=false}}"
|
||||
data-dtype="Number" />
|
||||
<label>Sols</label>
|
||||
</span>
|
||||
|
Loading…
Reference in New Issue
Block a user