From ce97911781530c2aeabdda0f7fe57584f2ba0e75 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 11 Jan 2021 18:04:26 +0100 Subject: [PATCH] #112 - Quantite pour les objets pour le tchat --- module/item-rdd.js | 22 +++++++++++++--------- packs/equipement.db | 1 + templates/post-item.html | 9 ++++++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/module/item-rdd.js b/module/item-rdd.js index e77f0e39..4304f7ab 100644 --- a/module/item-rdd.js +++ b/module/item-rdd.js @@ -21,8 +21,8 @@ export class RdDItem extends Item { chatData.data.cout_deniers = Math.floor(sols * 100); dialogResult = await new Promise( (resolve, reject) => {new Dialog({ content : - ` - `, - title : "Quantité", + title : "Quantité & Prix", buttons : { post : { label : "Soumettre", @@ -63,12 +63,16 @@ export class RdDItem extends Item { } } } - - if (dialogResult[0] > 0) - chatData.postQuantity = dialogResult[0]; - if (dialogResult[1] > 0) { - chatData.postPrice = dialogResult[1]; - chatData.data.cout_deniers = Math.floor(dialogResult[1] * 100); // Mise à jour cout en deniers + + if ( chatData.hasPrice ) { + if (dialogResult[0] > 0) + chatData.postQuantity = Number(dialogResult[0]); + if (dialogResult[1] > 0) { + chatData.postPrice = dialogResult[1]; + chatData.data.cout_deniers = Math.floor(dialogResult[1] * 100); // Mise à jour cout en deniers + } + chatData.finalPrice = Number(chatData.postPrice) * Number(chatData.postQuantity); + chatData.data.cout_deniers_total *= Number(chatData.postQuantity); } // Don't post any image for the item (which would leave a large gap) if the default image is used if (chatData.img.includes("/blank.png")) diff --git a/packs/equipement.db b/packs/equipement.db index 7b74ed5f..fac07b1a 100644 --- a/packs/equipement.db +++ b/packs/equipement.db @@ -200,3 +200,4 @@ {"_id":"zQWlnUsd8bPySujd","name":"Aiguille à coudre","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.01,"equipe":false,"resistance":0,"qualite":0,"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/aiguille.webp","effects":[]} {"_id":"zYI8mDiysWtmsSyy","name":"Carquois","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":2,"encombrement":0.1,"equipe":false,"qualite":0,"cout":0.5},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/carquois.webp","effects":[]} {"_id":"zlDa1vwmls6Uf4pt","name":"Bourse de cuir","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"conteneur","data":{"description":"","capacite":0.5,"encombrement":0.01,"equipe":false,"qualite":0,"contenu":[],"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/bourse.webp","effects":[]} +{"_id":"zQWlnUsd8bPySujd","name":"Aiguille à coudre","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.01,"equipe":false,"resistance":0,"qualite":0,"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/aiguille.webp","effects":[]} diff --git a/templates/post-item.html b/templates/post-item.html index c21cda21..6e55110e 100644 --- a/templates/post-item.html +++ b/templates/post-item.html @@ -17,9 +17,16 @@ Quantité: {{postQuantity}} {{/if}} + + {{#if finalPrice}} +
+ Prix Total: {{finalPrice}} Sols +
+ {{/if}} + {{#if hasPrice}} - Payer + Payer {{/if}}