From 8bbf40a84b75d3129358b7a3f6fe57bcacb93f9c Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 8 Apr 2021 20:36:02 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9er=20des=20plats=20cuisin=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lors de l'exécution d'une recette de cuisine, permettre l'ajout d'un plat à l'équipement --- module/actor.js | 27 +++++- module/rdd-roll.js | 9 +- templates/actor-sheet.html | 2 +- templates/chat-resultat-recettecuisine.html | 12 +-- templates/dialog-roll-enctotal.html | 3 +- templates/dialog-roll-recettecuisine.html | 92 ++++++++++++--------- templates/dialog-roll-surenc.html | 2 +- 7 files changed, 95 insertions(+), 52 deletions(-) diff --git a/module/actor.js b/module/actor.js index 5b554778..d4d3d0fb 100644 --- a/module/actor.js +++ b/module/actor.js @@ -29,6 +29,7 @@ import { RdDCarac } from "./rdd-carac.js"; import { Monnaie } from "./item-monnaie.js"; import { RdDHerbes } from "./rdd-herbes.js"; import { DialogConsommer } from "./dialog-consommer.js"; +import { RdDItem } from "./item.js"; /* -------------------------------------------- */ @@ -2264,7 +2265,12 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollRecetteCuisine(id) { - const artData = { art: 'cuisine', verbe: 'Cuisiner' }; + const artData = { + art: 'cuisine', + verbe: 'Cuisiner', + proportions: 1, + ajouterEquipement: false + }; const oeuvre = duplicate(this.getRecetteCuisine(id)); await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r)); } @@ -2272,9 +2278,28 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _resultRecetteCuisine(artData) { const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.data.niveau : artData.competence.data.niveau); + const sust = artData.oeuvre.data.sust * artData.proportions; artData.qualiteFinale = Math.min(baseQualite, artData.oeuvre.data.niveau) + artData.rolled.ptQualite; artData.exotismeFinal = Math.min(Math.min(artData.qualiteFinale, -Math.abs(artData.oeuvre.data.exotisme ?? 0)), 0); console.log("OEUVRE", artData.art, artData) + const platCuisine = { + name: artData.oeuvre.name, + type: 'nourritureboisson', + img: 'systems/foundryvtt-reve-de-dragon/icons/objets/provision_cuite.webp', + data: { + "description": artData.oeuvre.data.description, + "sust": Math.min(sust, 1), + "qualite": artData.exotismeFinal < 0 ? artData.exotismeFinal : artData.qualiteFinale, + "encombrement": 0.1, + "quantite": Math.max(1, Math.floor(sust)), + "cout": artData.exotismeFinal < 0 ? 0 : artData.qualiteFinale * 0.01 + } + }; + if (artData.ajouterEquipement){ + await this.createEmbeddedDocuments('Item', [platCuisine]); + ui.notifications.info(`${platCuisine.data.quantite} rations de ${platCuisine.name} ont été ajoutés à votre équipement`); + } + artData.platCuisine = platCuisine; RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`); } diff --git a/module/rdd-roll.js b/module/rdd-roll.js index cbdad129..cbc8f5cd 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -223,12 +223,13 @@ export class RdDRoll extends Dialog { this.rollData.tactique = event.currentTarget.value; this.updateRollResult(); }); - html.find('#useMalusSurenc').change((event) => { - this.rollData.useMalusSurenc = event.currentTarget.checked; + html.find('.cuisine-proportions').change((event) => { + this.rollData.proportions = Number(event.currentTarget.value); this.updateRollResult(); }); - html.find('#useMalusEncTotal').change((event) => { - this.rollData.useMalusEncTotal = event.currentTarget.checked; + html.find('.checkbox-by-name').change((event) => { + const attribute = event.currentTarget.attributes['name'].value; + this.rollData[attribute] = event.currentTarget.checked; this.updateRollResult(); }); html.find('.imgAppelAuMoral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */ diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index fe460e2a..916dd344 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -745,7 +745,7 @@