Consommer nourriture, suite #168
This commit is contained in:
@ -1610,25 +1610,70 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommer(item) {
|
||||
DialogConsommer.create(this, item, {
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-consommer-nourriture.html',
|
||||
}, []);
|
||||
async consommerDialog(item) {
|
||||
if (!item.isConsommable()) return;
|
||||
const dialog = await DialogConsommer.create(this, item);
|
||||
dialog.render(true)
|
||||
}
|
||||
|
||||
async manger(sust) {
|
||||
/* -------------------------------------------- */
|
||||
async consommer(item, choix) {
|
||||
switch (Misc.data(item).type) {
|
||||
case 'nourritureboisson':
|
||||
return await this.consommerNourritureboisson(item, choix);
|
||||
case 'potion':
|
||||
return await this.consommerPotion(item)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommerNourritureboisson(item, choix = { doses: 1, seForcer: false }) {
|
||||
const itemData = Misc.data(item);
|
||||
if (itemData.type != 'nourritureboisson') {
|
||||
return;
|
||||
}
|
||||
if (choix.doses > itemData.data.quantite) {
|
||||
ui.notifications.warn(`Il n'y a pas assez de ${itemData.name} poour manger ${choix.doses}`)
|
||||
return;
|
||||
}
|
||||
const surmonteExotisme = await this.surmonterExotisme(item, choix);
|
||||
if (!surmonteExotisme) {
|
||||
ui.notifications.warn(`Vous n'arrivez pas à manger de ${itemData.name}`)
|
||||
return;
|
||||
}
|
||||
await this.manger(item, choix.doses, { diminuerQuantite: false });
|
||||
await this.boire(item, choix.doses, { diminuerQuantite: false });
|
||||
await item.diminuerQuantite(choix.doses);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||
if (!item.isConsommable()) return;
|
||||
await this.apprecierCuisine(item);
|
||||
const sust = Misc.templateData(item).sust;
|
||||
if (sust > 0) {
|
||||
await this.updateCompteurValue('sust', Misc.templateData(this).compteurs.sust.value + sust);
|
||||
await this.updateCompteurValue('sust', Misc.keepDecimals(Misc.templateData(this).compteurs.sust.value + sust * doses, 2));
|
||||
}
|
||||
await item.diminuerQuantite(doses, options);
|
||||
}
|
||||
|
||||
async boire(eau) {
|
||||
if (eau > 0) {
|
||||
await this.actor.updateCompteurValue('eau', Misc.templateData(this).eau.value + this.consommerData.data.desaltere);
|
||||
/* -------------------------------------------- */
|
||||
async boire(item, doses, options = { diminuerQuantite: true }) {
|
||||
if (!item.isConsommable()) return;
|
||||
const tplData = Misc.templateData(item);
|
||||
const desaltere = tplData.desaltere;
|
||||
if (desaltere > 0) {
|
||||
await this.updateCompteurValue('eau', Misc.keepDecimals(Misc.templateData(this).compteurs.eau.value + desaltere * doses, 2));
|
||||
}
|
||||
if (item.isAlcool()) {
|
||||
for (let i = 0; i < doses; i++) {
|
||||
await this.saouler(tplData.force);
|
||||
}
|
||||
}
|
||||
await item.diminuerQuantite(doses, options);
|
||||
}
|
||||
|
||||
async alcool(forceAlcool) {
|
||||
async saouler(forceAlcool) {
|
||||
const actorTplData = Misc.templateData(this);
|
||||
const etatGeneral = this.getEtatGeneral({ ethylisme: true });
|
||||
const nbDoses = -Number(actorTplData.compteurs.ethylisme.nb_doses || 0);
|
||||
@ -1643,26 +1688,28 @@ export class RdDActor extends Actor {
|
||||
await this.performEthylisme(rollData);
|
||||
}
|
||||
|
||||
async apprecierCuisine(consommerData) {
|
||||
async apprecierCuisine(item) {
|
||||
const cuisine = Misc.data(this.getCompetence('cuisine'));
|
||||
const qualite = consommerData.data.qualite;
|
||||
const itemData = Misc.data(item);
|
||||
const qualite = itemData.data.qualite;
|
||||
if (cuisine && qualite > 0 && qualite > cuisine.data.niveau) {
|
||||
const rolled = await this.rollCaracCompetence('gout', 'cuisine', qualite, { title: consommerData.data.boisson ? "apprécie la boisson" : "apprécie le plat" });
|
||||
const rolled = await this.rollCaracCompetence('gout', 'cuisine', qualite, { title: itemData.data.boisson ? "apprécie la boisson" : "apprécie le plat" });
|
||||
if (rolled.isSuccess) {
|
||||
await this.jetDeMoral('heureux');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async surmonterExotisme(consommerData) {
|
||||
const qualite = consommerData.data.qualite;
|
||||
|
||||
async surmonterExotisme(item, choix = {}) {
|
||||
const itemData = Misc.data(item);
|
||||
const qualite = itemData.data.qualite;
|
||||
if (qualite < 0) {
|
||||
const rolled = await this.rollCaracCompetence('volonte', 'cuisine', qualite, { title: "tente de surmonter l'exotisme" });
|
||||
const rolled = await this.rollCaracCompetence('volonte', 'cuisine', qualite, { title: `surmonte l'exotisme de ${itemData.name}` });
|
||||
if (rolled.isEchec) {
|
||||
if (!consommerData.data.seForcer) {
|
||||
if (!choix.seForcer) {
|
||||
return false;
|
||||
}
|
||||
await this.actor.jetDeMoral('malheureux');
|
||||
await this.jetDeMoral('malheureux');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -2102,7 +2149,7 @@ export class RdDActor extends Actor {
|
||||
caracValue: Number(carac.value),
|
||||
selectedCarac: carac,
|
||||
competence: competence,
|
||||
finalLevel: (competence?.data.niveau ?? 0) + diff,
|
||||
finalLevel: (Misc.templateData(competence)?.niveau ?? 0) + diff,
|
||||
diffLibre: diff,
|
||||
showDice: true,
|
||||
show: { title: options?.title ?? '' }
|
||||
|
Reference in New Issue
Block a user