Consommation part le consommateur

Pour afficher la fenêtre d'appréciation côté acheteur, et utiliser ses
dés
This commit is contained in:
2025-12-14 16:43:15 +01:00
parent 455beb2820
commit e33727ac8d
7 changed files with 351 additions and 313 deletions

View File

@@ -220,7 +220,7 @@ export class RdDActor extends RdDBaseActorSang {
initiative: RdDInitiative.getRollInitiative(caracValue, niveau, ajustement)
};
attaque.isDistance = Distance.typeAttaqueDistance(attaque),
actions.push(attaque)
actions.push(attaque)
}
addAttaque(RdDItemArme.empoignade(this), ATTAQUE_TYPE.CORPS_A_CORPS)
@@ -1092,7 +1092,7 @@ export class RdDActor extends RdDBaseActorSang {
}
$createSortReserve(sort) {
const ptReve = Number.isInteger(sort.system.ptreve) ? Number(sort.system.ptreve) :Number(sort.system.ptreve.match(/\d+/))
const ptReve = Number.isInteger(sort.system.ptreve) ? Number(sort.system.ptreve) : Number(sort.system.ptreve.match(/\d+/))
this.createEmbeddedDocuments("Item",
[{
type: ITEM_TYPES.sortreserve,
@@ -1316,14 +1316,6 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async consommerNourritureboisson(itemId, choix = { doses: 1, seForcer: false, supprimerSiZero: false }) {
if (!this.isOwner) {
RdDBaseActor.remoteActorCall({
tokenId: this.token?.id,
actorId: this.id,
method: 'consommerNourritureboisson', args: [itemId, choix]
})
return
}
const item = this.getItem(itemId)
if (!item.getUtilisationCuisine()) {
return
@@ -1333,26 +1325,36 @@ export class RdDActor extends RdDBaseActorSang {
return
}
const onManger = [
async () => await this.manger(item, choix.doses, { diminuerQuantite: false }),
async () => await this.boire(item, choix.doses, { diminuerQuantite: false }),
async () => await item.diminuerQuantite(choix.doses, choix)
]
if (!this.isOwner) {
RdDBaseActor.remoteActorCall({
tokenId: this.token?.id,
actorId: this.id,
method: 'consommerNourritureboisson', args: [itemId, choix]
})
return
}
if (await this._surmonterExotisme(item)) {
const appreciation = item.system.appreciation;
new Apprecier(this, appreciation, item.system.qualite)
.apprecier(onManger)
if (item.system.qualite > 0) {
new Apprecier(this, item.system.appreciation, item.system.qualite).apprecier()
}
await this.onConsommerNourritureboisson(item, choix)
}
else if (choix.seForcer) {
await this.jetDeMoral(MORAL.MALHEUREUX)
await Promise.all(onManger.map(async callback => await callback()))
await this.onConsommerNourritureboisson(item, choix)
}
else {
ui.notifications.info(`${this.name} ne n'arrive pas à manger de ${item.name}`)
}
}
async onConsommerNourritureboisson(item, choix) {
await this.manger(item, choix.doses, { diminuerQuantite: false })
await this.boire(item, choix.doses, { diminuerQuantite: false })
await item.diminuerQuantite(choix.doses, choix)
}
/* -------------------------------------------- */
async _surmonterExotisme(item) {
const qualite = Math.min(item.system.qualite, 0)
@@ -1363,7 +1365,7 @@ export class RdDActor extends RdDBaseActorSang {
const rolled = await this.doRollCaracCompetence(CARACS.VOLONTE, competence, difficulte, { title: `tente de surmonter l'exotisme de ${item.name}` })
return rolled.isSuccess
}
return true;
return true
}
/* -------------------------------------------- */