Corrections et quelques améliorations #557
@ -4019,11 +4019,12 @@ export class RdDActor extends Actor {
|
|||||||
name: `Potion de ${herbeData.system.categorie} (${herbeData.name})`, type: 'potion',
|
name: `Potion de ${herbeData.system.categorie} (${herbeData.name})`, type: 'potion',
|
||||||
img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp",
|
img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp",
|
||||||
system: {
|
system: {
|
||||||
quantite: 1, valeur_deniers: 1, encombrement: 0.01,
|
quantite: 1, cout: 0, encombrement: 0.1,
|
||||||
categorie: herbeData.system.categorie,
|
categorie: herbeData.system.categorie,
|
||||||
herbe: herbeData.name,
|
herbe: herbeData.name,
|
||||||
rarete: herbeData.system.rarete,
|
rarete: herbeData.system.rarete,
|
||||||
herbebrins: herbeData.nbBrins,
|
herbebrins: herbeData.nbBrins,
|
||||||
|
herbebonus: herbeData.herbebonus,
|
||||||
description: ""
|
description: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,11 @@ export class DialogFabriquerPotion extends Dialog {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async create(actor, item, dialogConfig) {
|
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 potionData = DialogFabriquerPotion.prepareData(actor, item);
|
||||||
|
|
||||||
let conf = {
|
let conf = {
|
||||||
@ -25,8 +30,11 @@ export class DialogFabriquerPotion extends Dialog {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static prepareData(actor, item) {
|
static prepareData(actor, item) {
|
||||||
let potionData = duplicate(item)
|
let potionData = duplicate(item)
|
||||||
potionData.nbBrinsSelect = RdDUtility.buildListOptions(1, potionData.system.quantite);
|
potionData.nbBrinsSelect = RdDUtility.buildListOptions(
|
||||||
potionData.nbBrins = Math.min(potionData.system.quantite, DialogFabriquerPotion.getNombreBrinOptimal(potionData));
|
DialogFabriquerPotion.nombreBrinsMinimum(item),
|
||||||
|
DialogFabriquerPotion.nombreBrinsOptimal(item));
|
||||||
|
potionData.nbBrins = Math.min(potionData.system.quantite, DialogFabriquerPotion.nombreBrinsOptimal(potionData));
|
||||||
|
potionData.herbebonus = item.system.niveau;
|
||||||
potionData.buttonName = "Fabriquer";
|
potionData.buttonName = "Fabriquer";
|
||||||
return potionData;
|
return potionData;
|
||||||
}
|
}
|
||||||
@ -45,7 +53,15 @@ export class DialogFabriquerPotion extends Dialog {
|
|||||||
this.potionData = potionData;
|
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 ?? '') {
|
switch (herbeData.system.categorie ?? '') {
|
||||||
case "Soin": return 12 - herbeData.system.niveau;
|
case "Soin": return 12 - herbeData.system.niveau;
|
||||||
case "Repos": return 7 - herbeData.system.niveau;
|
case "Repos": return 7 - herbeData.system.niveau;
|
||||||
@ -59,6 +75,8 @@ export class DialogFabriquerPotion extends Dialog {
|
|||||||
|
|
||||||
html.find("#nbBrins").change(event => {
|
html.find("#nbBrins").change(event => {
|
||||||
this.potionData.nbBrins = Misc.toInt(event.currentTarget.value);
|
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)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<img class="chat-icon" src="{{img}}" alt="potion de repos" />
|
<img class="chat-icon" src="{{img}}" alt="potion de repos" />
|
||||||
<h4>
|
<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>
|
</h4>
|
||||||
<hr>
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<img class="chat-icon" src="{{img}}" alt="potion de soin" />
|
<img class="chat-icon" src="{{img}}" alt="potion de soin" />
|
||||||
<h4>
|
<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>
|
</h4>
|
||||||
<hr>
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user