diff --git a/module/dialog-item-vente.js b/module/dialog-item-vente.js index 78698d2a..ac17a001 100644 --- a/module/dialog-item-vente.js +++ b/module/dialog-item-vente.js @@ -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)); diff --git a/module/item.js b/module/item.js index a36bb4cb..03edc4fa 100644 --- a/module/item.js +++ b/module/item.js @@ -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); } diff --git a/module/rdd-utility.js b/module/rdd-utility.js index be4091d0..d8cb280c 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -191,7 +191,6 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-potion.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-vehicule.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-competence.html', - 'systems/foundryvtt-reve-de-dragon/templates/enum-herbesoin-ingredient.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-heures.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-initpremierround.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-niveau-ethylisme.html', diff --git a/templates/actor/commerce-inventaire-item.html b/templates/actor/commerce-inventaire-item.html index 313b4ef4..831e7440 100644 --- a/templates/actor/commerce-inventaire-item.html +++ b/templates/actor/commerce-inventaire-item.html @@ -41,24 +41,20 @@ {{#if options.isOwner}} - {{#if (and (eq item.type 'conteneur') (not vide))}} - - {{else}} - + + {{#unless (and (eq item.type 'conteneur') (not vide))}} {{#if (or item.parent.system.illimite (ne item.system.quantite 0))}} {{/if}} - {{#if (gt item.system.quantite 0)}} - - {{/if}} - {{/if}} - {{else}} + {{/unless}} + {{/if}} + {{#unless (and (eq item.type 'conteneur') (not vide))}} {{#if (or item.parent.system.illimite (gt item.system.quantite 0))}} {{/if}} - {{/if}} - + + {{/unless}} {{/if}} diff --git a/templates/dialog-item-vente.html b/templates/dialog-item-vente.html index 52d78e42..1307b33a 100644 --- a/templates/dialog-item-vente.html +++ b/templates/dialog-item-vente.html @@ -2,19 +2,21 @@