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:
Vincent Vandemeulebrouck 2022-09-23 02:23:20 +02:00
parent e2ff813226
commit 3a29c25b09
4 changed files with 25 additions and 6 deletions

View File

@ -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: ""
}
}

View File

@ -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)
});
}

View File

@ -1,6 +1,6 @@
<img class="chat-icon" src="{{img}}" alt="potion de repos" />
<h4>
{{alias}} a bu une <strong>{{name}}{{#if system.magique}} enchantée{{/if}}</strong>
{{alias}} a bu une <strong>{{name}}{{#if system.magique}} enchantée de puissance {{system.puissance}}{{/if}}</strong>.
</h4>
<hr>
<div>

View File

@ -1,6 +1,6 @@
<img class="chat-icon" src="{{img}}" alt="potion de soin" />
<h4>
{{alias}} a bu une <strong>{{name}}{{#if system.magique}} enchantée{{/if}}</strong>
{{alias}} a bu une <strong>{{name}}{{#if system.magique}} enchantée de {{system.puissance}} points de guérison{{/if}}</strong>
</h4>
<hr>
<div>