diff --git a/module/actor.js b/module/actor.js
index f416259f..c09e2a44 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -4019,11 +4019,12 @@ export class RdDActor extends Actor {
name: `Potion de ${herbeData.system.categorie} (${herbeData.name})`, type: 'potion',
img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp",
system: {
- quantite: 1, valeur_deniers: 1, encombrement: 0.01,
+ quantite: 1, cout: 0, encombrement: 0.1,
categorie: herbeData.system.categorie,
herbe: herbeData.name,
rarete: herbeData.system.rarete,
herbebrins: herbeData.nbBrins,
+ herbebonus: herbeData.herbebonus,
description: ""
}
}
diff --git a/module/dialog-fabriquer-potion.js b/module/dialog-fabriquer-potion.js
index fe4d1744..a8571c5a 100644
--- a/module/dialog-fabriquer-potion.js
+++ b/module/dialog-fabriquer-potion.js
@@ -6,6 +6,11 @@ export class DialogFabriquerPotion extends Dialog {
/* -------------------------------------------- */
static async create(actor, item, dialogConfig) {
+ const min = DialogFabriquerPotion.nombreBrinsMinimum(item);
+ if (item.system.quantite < min) {
+ ui.notifications.warn(`Vous avez ${item.system.quantite} brins de ${item.name}, il en faut au moins ${min} pour faire une potion!`);
+ return;
+ }
let potionData = DialogFabriquerPotion.prepareData(actor, item);
let conf = {
@@ -25,8 +30,11 @@ export class DialogFabriquerPotion extends Dialog {
/* -------------------------------------------- */
static prepareData(actor, item) {
let potionData = duplicate(item)
- potionData.nbBrinsSelect = RdDUtility.buildListOptions(1, potionData.system.quantite);
- potionData.nbBrins = Math.min(potionData.system.quantite, DialogFabriquerPotion.getNombreBrinOptimal(potionData));
+ potionData.nbBrinsSelect = RdDUtility.buildListOptions(
+ DialogFabriquerPotion.nombreBrinsMinimum(item),
+ DialogFabriquerPotion.nombreBrinsOptimal(item));
+ potionData.nbBrins = Math.min(potionData.system.quantite, DialogFabriquerPotion.nombreBrinsOptimal(potionData));
+ potionData.herbebonus = item.system.niveau;
potionData.buttonName = "Fabriquer";
return potionData;
}
@@ -45,7 +53,15 @@ export class DialogFabriquerPotion extends Dialog {
this.potionData = potionData;
}
- static getNombreBrinOptimal(herbeData) {
+ static nombreBrinsMinimum(herbeData) {
+ switch (herbeData.system.categorie ?? '') {
+ case "Soin": return 1 + Math.max(0, 12 - 2 * herbeData.system.niveau);
+ case "Repos": return 1 + Math.max(0, 7 - 2 * herbeData.system.niveau);
+ }
+ return 1;
+ }
+
+ static nombreBrinsOptimal(herbeData) {
switch (herbeData.system.categorie ?? '') {
case "Soin": return 12 - herbeData.system.niveau;
case "Repos": return 7 - herbeData.system.niveau;
@@ -59,6 +75,8 @@ export class DialogFabriquerPotion extends Dialog {
html.find("#nbBrins").change(event => {
this.potionData.nbBrins = Misc.toInt(event.currentTarget.value);
+ const brinsManquants = Math.max(0, DialogFabriquerPotion.nombreBrinsOptimal(this.potionData) - this.potionData.nbBrins);
+ this.potionData.herbebonus = Math.max(0, this.potionData.system.niveau - brinsManquants)
});
}
diff --git a/templates/chat-consommer-potion-repos.html b/templates/chat-consommer-potion-repos.html
index e8c37969..047eac78 100644
--- a/templates/chat-consommer-potion-repos.html
+++ b/templates/chat-consommer-potion-repos.html
@@ -1,6 +1,6 @@