Gestion des signes draconiques #455

Closed
vincent.vandeme wants to merge 233 commits from v1.4-signes-draconiques into master
9 changed files with 114 additions and 67 deletions
Showing only changes of commit f25ae66de1 - Show all commits

View File

@ -29,6 +29,7 @@ import { RdDCarac } from "./rdd-carac.js";
import { Monnaie } from "./item-monnaie.js"; import { Monnaie } from "./item-monnaie.js";
import { RdDHerbes } from "./rdd-herbes.js"; import { RdDHerbes } from "./rdd-herbes.js";
import { DialogConsommer } from "./dialog-consommer.js"; import { DialogConsommer } from "./dialog-consommer.js";
import { RdDItem } from "./item.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -2264,7 +2265,12 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollRecetteCuisine(id) { 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)); const oeuvre = duplicate(this.getRecetteCuisine(id));
await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r)); await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r));
} }
@ -2272,9 +2278,28 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _resultRecetteCuisine(artData) { async _resultRecetteCuisine(artData) {
const baseQualite = (artData.rolled.isSuccess ? artData.oeuvre.data.niveau : artData.competence.data.niveau); 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.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); artData.exotismeFinal = Math.min(Math.min(artData.qualiteFinale, -Math.abs(artData.oeuvre.data.exotisme ?? 0)), 0);
console.log("OEUVRE", artData.art, artData) 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`); RdDResolutionTable.displayRollData(artData, this.name, `chat-resultat-${artData.art}.html`);
} }

View File

@ -1,7 +1,7 @@
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
const typesObjetsEquipement = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "nourritureboisson"]; const typesObjetsEquipement = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "nourritureboisson", "monnaie"];
const typesObjetsOeuvres = ["oeuvre", "recettecuisine", "musique", "chant", "danse", "jeu"]; const typesObjetsOeuvres = ["oeuvre", "recettecuisine", "musique", "chant", "danse", "jeu"];
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDItem extends Item { export class RdDItem extends Item {
@ -15,15 +15,19 @@ export class RdDItem extends Item {
prepareDerivedData() { prepareDerivedData() {
super.prepareDerivedData(); super.prepareDerivedData();
const itemData = this.data; const itemData = this.data;
const tplData = itemData.data;
if (RdDItem.getTypeObjetsEquipement().includes(itemData.type)) { if (RdDItem.getTypeObjetsEquipement().includes(itemData.type)) {
const quantite = itemData.type == 'conteneur' ? 1 : (tplData.quantite ?? 0); this._calculsEquipement(itemData);
if (tplData.encombrement != undefined) { }
tplData.encTotal = Math.max(tplData.encombrement, 0) * quantite; }
}
if (tplData.cout != undefined) { _calculsEquipement(itemData) {
tplData.prixTotal = Math.max(tplData.cout, 0) * quantite; const tplData = itemData.data;
} const quantite = itemData.type == 'conteneur' ? 1 : (tplData.quantite ?? 0);
if (tplData.encombrement != undefined) {
tplData.encTotal = Math.max(tplData.encombrement, 0) * quantite;
}
if (tplData.cout != undefined) {
tplData.prixTotal = Math.max(tplData.cout, 0) * quantite;
} }
} }

View File

@ -223,12 +223,13 @@ export class RdDRoll extends Dialog {
this.rollData.tactique = event.currentTarget.value; this.rollData.tactique = event.currentTarget.value;
this.updateRollResult(); this.updateRollResult();
}); });
html.find('#useMalusSurenc').change((event) => { html.find('.cuisine-proportions').change((event) => {
this.rollData.useMalusSurenc = event.currentTarget.checked; this.rollData.proportions = Number(event.currentTarget.value);
this.updateRollResult(); this.updateRollResult();
}); });
html.find('#useMalusEncTotal').change((event) => { html.find('.checkbox-by-name').change((event) => {
this.rollData.useMalusEncTotal = event.currentTarget.checked; const attribute = event.currentTarget.attributes['name'].value;
this.rollData[attribute] = event.currentTarget.checked;
this.updateRollResult(); this.updateRollResult();
}); });
html.find('.imgAppelAuMoral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */ html.find('.imgAppelAuMoral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */

View File

@ -745,7 +745,7 @@
</div> </div>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
<li class="competence-header flexrow"> <li class="competence-header flexrow">
<img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/objets/sac_a_dos.webp" title="Equipement"/> <img class="sheet-competence-img" src="{{img}}" title="Equipement"/>
<span class="competence-title flex-grow">Nom</span> <span class="competence-title flex-grow">Nom</span>
<span class="competence-title">Q.</span> <span class="competence-title">Q.</span>
<span class="competence-title">Enc.</span> <span class="competence-title">Enc.</span>

View File

@ -75,18 +75,18 @@
{{/if}} {{/if}}
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
<li class="competence-header flexrow"> <li class="competence-header flexrow">
<span class="competence-title competence-label">Nom</span> <img class="sheet-competence-img" src="{{img}}" title="Equipement"/>
<span class="competence-title competence-label flex-grow">Nom</span>
<span class="competence-title competence-label">Q.</span> <span class="competence-title competence-label">Q.</span>
<span class="competence-title competence-value">Enc.</span> <span class="competence-title competence-value">Enc.</span>
<span class="competence-title competence-value">Equiper</span> <span class="competence-title competence-value">Equiper/Editer/Suppr.</span>
<span class="competence-title competence-value">Editer/Suppr.</span>
</li> </li>
{{#each data.objets as |item id|}} {{#each objets as |item id|}}
{{#unless item.estContenu}} {{#unless item.estContenu}}
{{#if (ne item.type 'conteneur')}} {{#if (ne item.type 'conteneur')}}
<li class="item flexrow list-item" data-item-id="{{item._id}}"> <li class="item flexrow list-item" data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/> <img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<span class="item-name">{{item.name}}</span> <span class="item-name flex-grow">{{item.name}}</span>
<span class="item-quantite">{{item.data.quantite}}</span> <span class="item-quantite">{{item.data.quantite}}</span>
<span class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</span> <span class="item-quantite">{{numberFormat item.data.encTotal decimals=2}}</span>
<div class="item-controls"> <div class="item-controls">
@ -98,7 +98,7 @@
{{/if}} {{/if}}
{{/unless}} {{/unless}}
{{/each}} {{/each}}
{{#each data.conteneurs as |conteneur id|}} {{#each conteneurs as |conteneur id|}}
{{buildConteneur this}} {{buildConteneur this}}
{{/each}} {{/each}}
</ul> </ul>

View File

@ -5,16 +5,18 @@
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}}
<hr> <hr>
<span> <span>
<img class="chat-icon" src="{{platCuisine.img}}" alt="{{platCuisine.name}}" />
<br>Vous avez préparé {{platCuisine.data.quantite}} portions de {{platCuisine.name}}
{{~#if ajouterEquipement}}, qui ont été ajoutées à votre équipement{{/if}}.
{{#if rolled.isSuccess}} {{#if rolled.isSuccess}}
{{alias}} réussit sa recette, avec un plat de qualité {{qualiteFinale}} pour {{oeuvre.data.sust}} Points de Sustentation. Vous avez réussi la recette, pour un plat de qualité {{qualiteFinale}}.
{{else}} {{else}}
{{alias}} fait un piètre cuisinier(e), et obtient {{#if (lt qualiteFinale 0)}}un plat à l'exotisme certain{{else}}un plat de qualité {{qualiteFinale}}{{/if}}. Vous faites un piètre cuisinier, et obtenez un plat {{#if (lt exotismeFinal 0)}}à l'exotisme certain{{else}}de qualité {{qualiteFinale}}{{/if}}.
Selon la décision du MJ, le plat peut fournir {{oeuvre.data.sust}} Points de Sustentation
{{/if}} {{/if}}
Pensez à faire goûter vos compagnons!
{{#if (lt exotismeFinal 0)}} {{#if (lt exotismeFinal 0)}}
<br>Au vu de l'exotisme du plat, les convives devront réussir un jet de Volonté / Cuisine à {{exotismeFinal}}. <br>Au vu de l'exotisme du plat, les convives devront réussir un jet de Volonté / Cuisine à {{exotismeFinal}}.
En cas d'échec, ils peuvent se forcer pour faire plaisir au Maître Queux, mais devront faire un jet de moral Malheureux. En cas d'échec, ils peuvent se forcer pour vous faire plaisir, mais devront faire un jet de moral Malheureux.
{{/if}} {{/if}}
</span> </span>
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-info-appel-au-moral.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/chat-info-appel-au-moral.html"}}

View File

@ -1,7 +1,6 @@
{{#if ajustements.encTotal.visible}} {{#if ajustements.encTotal.visible}}
<div class="form-group"> <div class="form-group">
<label>Appliquer l'encombrement total comme malus ({{encTotal}}) ? </label> <label>Appliquer l'encombrement total comme malus ({{encTotal}}) ? </label>
<input class="attribute-value" type="checkbox" id="ajustements-encTotal-apply" <input class="attribute-value checkbox-by-name" type="checkbox" name="useMalusEncTotal" {{#if useMalusEncTotal}}checked{{/if}}/>
name="ajustements.encTotal.apply" {{#if ajustements.encTotal.apply}}checked{{/if}}/>
</div> </div>
{{/if}} {{/if}}

View File

@ -1,43 +1,59 @@
<form class="rdddialog"> <form class="rdddialog">
<div class="grid grid-2col">
<div class="form-group"> <div class="flex-group-left">
<ul> <ul>
<li><label>Cuisiner : {{oeuvre.name}}</label></li> <li><label>Cuisiner : {{oeuvre.name}}</label></li>
<li><label>Jet : ODORAT-GOUT / {{competence.name}}</label></li> <li><label>Jet : ODORAT-GOUT / {{competence.name}}</label></li>
<li><label>Exotisme : {{oeuvre.data.exotisme}}</label></li> <li><label>Exotisme : {{oeuvre.data.exotisme}}</label></li>
</ul> </ul>
<div class="tooltipAppelAuMoral divAppelAuMoral"> </div>
<img class="imgAppelAuMoral small-button-container" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg"> <div class="flex-group-left">
<span class="tooltipAppelAuMoralText">Sans appel au moral</span> <div class="flexrow">
<label class="competence-label">Multiplier les proportions</label>
<input class="competence-value cuisine-proportions" type="number" size="4" name="proportions" value="{{proportions}}" data-dtype="Number" />
</div>
<div class="flexrow">
<label class="competence-label">Ajouter à l'équipement</label>
<input class="checkbox-by-name" type="checkbox" name="ajouterEquipement" {{#if ajouterEquipement}}checked{{/if}} />
</div>
</div>
</div>
<div class="grid grid-3col">
<div class="flex-group-left">
<label>Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number">
{{#select diffConditions}}
{{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="flex-group-left">
<label>Difficulté</label>
<select name="diffLibre" id="diffLibre" data-dtype="number">
{{#select diffLibre}}
{{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="flex-group-right flexrow">
<div class="tooltipAppelAuMoral divAppelAuMoral">
<img class="imgAppelAuMoral small-button-container" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg">
<span class="tooltipAppelAuMoralText">Sans appel au moral</span>
</div>
</div>
</div>
<div id="tableAjustements">
</div>
<div id="tableResolution">
</div>
<div id="tableProbaReussite">
</div> </div>
</div>
<div class="form-group">
<label>conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number">
{{#select diffConditions}}
{{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
<label>Difficulté </label>
<select name="diffLibre" id="diffLibre" data-dtype="number">
{{#select diffLibre}}
{{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div id="tableAjustements">
</div>
<div id="tableResolution">
</div>
<div id="tableProbaReussite">
</div>
</form> </form>
<script> <script>
</script> </script>

View File

@ -1,6 +1,6 @@
{{#if surencMalusFlag}} {{#if surencMalusFlag}}
<div class="form-group"> <div class="form-group">
<label for="xp">Appliquer le malus de sur-encombrement ? </label> <label for="xp">Appliquer le malus de sur-encombrement ? </label>
<input class="attribute-value" type="checkbox" id="useMalusSurenc" name="useMalusSurenc" {{#if useMalusSurenc}}checked{{/if}}/> <input class="attribute-value checkbox-by-name" type="checkbox" name="useMalusSurenc" {{#if useMalusSurenc}}checked{{/if}}/>
</div> </div>
{{/if}} {{/if}}