Appréciation de plats

This commit is contained in:
2025-12-08 19:39:21 +01:00
parent d9bc6309fb
commit aae603d798
2 changed files with 26 additions and 23 deletions

View File

@@ -53,7 +53,7 @@ import { PART_COMP } from "./roll/roll-part-comp.mjs";
import { PART_OEUVRE } from "./roll/roll-part-oeuvre.mjs"; import { PART_OEUVRE } from "./roll/roll-part-oeuvre.mjs";
import { PART_CUISINE } from "./roll/roll-part-cuisine.mjs"; import { PART_CUISINE } from "./roll/roll-part-cuisine.mjs";
import { RdDPossessionV2 } from "./rdd-possession-v2.mjs"; import { RdDPossessionV2 } from "./rdd-possession-v2.mjs";
import { MORAL, SITUATION_MORAL } from "./moral/apprecier.mjs"; import { Apprecier, MORAL, SITUATION_MORAL } from "./moral/apprecier.mjs";
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre'] export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
@@ -1322,33 +1322,31 @@ export class RdDActor extends RdDBaseActorSang {
} }
const item = this.getItem(itemId) const item = this.getItem(itemId)
if (!item.getUtilisationCuisine()) { if (!item.getUtilisationCuisine()) {
return; return
} }
if (choix.doses > item.system.quantite) { if (choix.doses > item.system.quantite) {
ui.notifications.warn(`Il n'y a pas assez de ${item.name} pour manger ${choix.doses}`) ui.notifications.warn(`Il n'y a pas assez de ${item.name} pour manger ${choix.doses}`)
return; return
} }
if (!this._apprecierCuisine(item, choix.seForcer)) {
ui.notifications.info(`${this.name} ne n'arrive pas à manger de ${item.name}`)
return;
}
await this.manger(item, choix.doses, { diminuerQuantite: false });
await this.boire(item, choix.doses, { diminuerQuantite: false });
await item.diminuerQuantite(choix.doses, choix);
}
async _apprecierCuisine(item, seForcer) { const onManger = [
const surmonteExotisme = await this._surmonterExotisme(item, seForcer); async () => await this.manger(item, choix.doses, { diminuerQuantite: false }),
if (surmonteExotisme) { async () => await this.boire(item, choix.doses, { diminuerQuantite: false }),
await this.apprecier(CARACS.ODORATGOUT, 'cuisine', item.system.qualite, item.system.boisson ? "apprécie la boisson" : "apprécie le plat"); async () => await item.diminuerQuantite(choix.doses, choix)
]
if (await this._surmonterExotisme(item)) {
const appreciation = item.system.appreciation;
new Apprecier(this, appreciation, item.system.qualite)
.apprecier(onManger)
} }
else if (seForcer) { else if (choix.seForcer) {
await this.jetDeMoral(MORAL.MALHEUREUX); await this.jetDeMoral(MORAL.MALHEUREUX)
await Promise.all(onManger.map(async callback => await callback()))
} }
else { else {
return false; ui.notifications.info(`${this.name} ne n'arrive pas à manger de ${item.name}`)
} }
return true;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@@ -100,7 +100,7 @@ export class Apprecier {
this.raisons = [] this.raisons = []
} }
apprecier() { apprecier(rollCallbacks = []) {
if (this.qualite <= 0) { if (this.qualite <= 0) {
this.raisons.push(`la qualité ${this.qualite} est négative.`) this.raisons.push(`la qualité ${this.qualite} est négative.`)
} }
@@ -117,14 +117,14 @@ export class Apprecier {
} }
if (this.appreciation.carac != "") { if (this.appreciation.carac != "") {
this.rollAppreciation() this.rollAppreciation(rollCallbacks)
} }
else { else {
this.rollMoral() this.rollMoral()
} }
} }
rollAppreciation() { rollAppreciation(rollCallbacks = []) {
const competence = (this.appreciation.jetComp && this.appreciation.competence) ? this.appreciation.competence : "" const competence = (this.appreciation.jetComp && this.appreciation.competence) ? this.appreciation.competence : ""
const rollData = { const rollData = {
ids: { actorId: this.actor.id }, ids: { actorId: this.actor.id },
@@ -140,7 +140,12 @@ export class Apprecier {
} }
} }
} }
RollDialog.create(rollData, { callbacks: [async r => await this.onRollAppreciation(r)] }) RollDialog.create(rollData, {
callbacks: [
async r => await this.onRollAppreciation(r),
...rollCallbacks
]
})
} }
async onRollAppreciation(roll) { async onRollAppreciation(roll) {