Boire une potion de soin
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
@ -17,9 +18,26 @@ export class RdDItem extends Item {
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
if (RdDItem.getTypeObjetsEquipement().includes(Misc.data(this).type)) {
|
||||
const itemData = Misc.data(this);
|
||||
if (RdDItem.getTypeObjetsEquipement().includes(itemData.type)) {
|
||||
this._calculsEquipement();
|
||||
}
|
||||
if (itemData.type == 'potion') {
|
||||
this.prepareDataPotion()
|
||||
}
|
||||
itemData.data.actionPrincipale = this.getActionPrincipale({ warnIfNot: false });
|
||||
|
||||
}
|
||||
|
||||
prepareDataPotion() {
|
||||
const tplData = Misc.templateData(this);
|
||||
const categorie = Grammar.toLowerCaseNoAccent(tplData.categorie);
|
||||
tplData.isEnchante = categorie.includes('enchante');
|
||||
if (tplData.isEnchante) {
|
||||
if (categorie.includes('soin') || categorie.includes('repos')) {
|
||||
tplData.puissance = tplData.herbebonus * tplData.pr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_calculsEquipement() {
|
||||
@ -36,32 +54,30 @@ export class RdDItem extends Item {
|
||||
|
||||
getEnc() {
|
||||
const itemData = Misc.data(this);
|
||||
switch (itemData.type)
|
||||
{
|
||||
switch (itemData.type) {
|
||||
case 'herbe':
|
||||
return encBrin;
|
||||
}
|
||||
return itemData.data.encombrement
|
||||
}
|
||||
|
||||
isConsommable(options = { warnIfNot: true }) {
|
||||
getActionPrincipale(options = { warnIfNot: true }) {
|
||||
const itemData = Misc.data(this);
|
||||
if ((itemData.data.quantite ?? 0) <= 0) {
|
||||
if (options.warnIfNot) {
|
||||
ui.notifications.warn(`Vous n'avez plus de ${itemData.name}.`);
|
||||
}
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
switch (itemData.type) {
|
||||
case 'nourritureboisson':
|
||||
case 'potion':
|
||||
return true;
|
||||
case 'nourritureboisson': return itemData.data.boisson ? 'Boire' : 'Manger';
|
||||
case 'potion': return 'Boire';
|
||||
}
|
||||
if (options.warnIfNot) {
|
||||
ui.notifications.warn(`Impossible de consommer un ${itemData.name}, ce n'est pas commestible.`);
|
||||
ui.notifications.warn(`Impossible d'utilise un ${itemData.name}, aucune action associée définie.`);
|
||||
}
|
||||
return false;
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
isAlcool() {
|
||||
|
Reference in New Issue
Block a user