Fix: calculs des bonus de potions
Le calcul du bonus d'herbe d'une potion dépend des brins manquants. La fabrication de potion propose les nombres de brins pour avoir un effet. Impossible de faire une potion si on n'a pas assez de brins. La puissance/points de guérison des potions magiques sont affichées lors de la consomation
This commit is contained in:
@ -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)
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user