Rework dialog Alchimie

This commit is contained in:
Vincent Vandemeulebrouck 2021-04-20 23:16:18 +02:00
parent 0e9bc372bf
commit 550f45d14c
16 changed files with 124 additions and 97 deletions

View File

@ -3202,24 +3202,33 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
async effectuerTacheAlchimie(recetteId, alchimieName, alchimieData) {
let recette = this.getItemOfType(recetteId, 'recettealchimique');
async effectuerTacheAlchimie(recetteId, tacheAlchimie, texteTache) {
let recetteData = Misc.data(this.getItemOfType(recetteId, 'recettealchimique'));
const actorData = Misc.data(this);
if (recette) {
let competence = Misc.data(this.getCompetence("alchimie"));
let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData);
if (recetteData) {
if (tacheAlchimie != "couleur" && tacheAlchimie != "consistance") {
ui.notifications.warn(`L'étape alchimique ${tacheAlchimie} - ${texteTache} est inconnue`);
return;
}
const sansCristal = tacheAlchimie == "couleur" && this.data.items.filter(it => it.isCristalAlchimique()).length == 0;
const caracTache = RdDAlchimie.getCaracTache(tacheAlchimie);
const alchimieData = Misc.data(this.getCompetence("alchimie"));
let rollData = {
recette: recette,
competence: competence,
diffLibre: diffAlchimie // Per default at startup
}
if (alchimieName == "couleur") {
rollData.selectedCarac = actorData.data.carac.vue,
rollData.alchimieTexte = `Couleurs ${alchimieData} (${diffAlchimie}) (Malus de -4 si vous ne possédez pas de Cristal Alchimique)`;
} else {
rollData.selectedCarac = actorData.data.carac.dexterite,
rollData.alchimieTexte = `Consistances ${alchimieData} (${diffAlchimie})`;
recette: recetteData,
carac: { [caracTache]: actorData.data.carac[caracTache] },
selectedCarac: actorData.data.carac[caracTache],
competence: alchimieData,
diffLibre: RdDAlchimie.getDifficulte(texteTache),
diffConditions: sansCristal ? -4 : 0,
alchimie: {
tache: Misc.upperFirst(tacheAlchimie),
texte: texteTache,
sansCristal: sansCristal
}
}
rollData.competence.data.defaut_carac = caracTache;
const dialog = await RdDRoll.create(this, rollData,
{
@ -3239,6 +3248,10 @@ export class RdDActor extends Actor {
}
}
isCristalAlchimique(it) {
return it.type == 'objet' && Grammar.toLowerCaseNoAccent(it.name) == 'cristal alchimique' && it.data.quantite > 0;
}
/* -------------------------------------------- */
_alchimieResult(rollData) {
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html');

View File

@ -34,6 +34,12 @@ export class RdDItem extends Item {
return RdDItem.getTypeObjetsEquipement().includes(Misc.data(this).type);
}
isCristalAlchimique() {
const itemData = Misc.data(this);
return itemData.type == 'objet' && Grammar.toLowerCaseNoAccent(itemData.name) == 'cristal alchimique' && itemData.data.quantite > 0;
}
getEnc() {
const itemData = Misc.data(this);
switch (itemData.type) {

View File

@ -53,4 +53,13 @@ export class RdDAlchimie {
}
return Math.min(0, -composantes);
}
static getCaracTache(tache) {
switch (tache) {
case "consistance": return 'dexterite';
case "couleur": return 'vue';
}
return 'intellect';
}
}

View File

@ -285,7 +285,7 @@ export class RdDRoll extends Dialog {
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
// Mise à jour valeurs
$("#compdialogTitle").text(this._getTitle(rollData));
$(".dialog-roll-title").text(this._getTitle(rollData));
$('#coupsNonMortels').prop('checked', rollData.coupsNonMortels);
$(".dmg-arme-actor").text(dmgText);
$('.table-ajustement').remove();
@ -299,7 +299,7 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */
async buildAjustements(rollData) {
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData);
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html`, rollData);
return html;
}

View File

@ -147,7 +147,6 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html',
'systems/foundryvtt-reve-de-dragon/templates/casetmr-specific-list.html',
// Dialogs
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
@ -155,10 +154,15 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-meditation.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-alchimie.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html',
// Partials
'systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-roll-enctotal.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html',
// Calendrier
'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html',
'systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html',

View File

@ -1,5 +1,5 @@
<form class="skill-roll-dialog">
<h2 class="compdialog" id="compdialogTitle"></h2>
<h2 class="dialog-roll-title"></h2>
<div class="grid grid-2col">
<div class="flex-group-left">
@ -63,47 +63,22 @@
{{/unless}}
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-enctotal.html"}}
</div>
<div class="flex-group-left">
{{#if attackerRoll}}
<div class="flexrow">
{{#if attackerRoll}}
<label>Difficulté</label>
<label>{{diffLibre}}</label>
{{else}}
<label>Difficulté libre</label>
<select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless use.libre}}disabled{{/unless}}>
{{#select diffLibre}}
{{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
{{/if}}
</div>
<div class="flexrow">
</div>
<div class="flexrow">
<label>Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}>
{{#select diffConditions}}
{{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="flexrow">
<label class="diffMoral">Moral: {{#if (gt moral 0)}}+{{/if}}{{moral}}</label>
<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 id="tableAjustements" class="flexrow">
</div>
{{else}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html"}}
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div>
</div>
</div>

View File

@ -1,41 +1,34 @@
{{log 'recette alchimique' this}}
<form class="rdddialog">
<div class="form-group">
<ul>
<li><label>Recette : {{recetteName}}</label></li>
<li><label>Tâche Alchimique : {{alchimieTexte}}</label></li>
<li><label>Jet : {{selectedCarac.label}} / {{competence.name}}</label></li>
</ul>
<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>
<h2>Fabrication: {{recette.name}}</h2>
<div class="grid grid-2col">
<div class="flex-group-left">
<img class="chat-icon" src="{{competence.img}}" alt="{{competence.name}}"/>
<div class="grid grid-2col">
<label>{{alchimie.tache}}:</label><label class="flex-grow">{{alchimie.texte}}</label>
<label>Caractéristique: </label><label class="flex-grow">{{selectedCarac.label}}</label>
<label>{{competence.name}}:</label><label class="flex-grow">{{numberFormat competence.data.niveau decimals=0 sign=true}}</label></label>
</div>
</div>
<div class="flex-group-left">
<div class="flexrow">
<label>Difficulté</label>
<label>{{numberFormat diffLibre decimals=0 sign=true}}</label>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{#if alchimie.sansCristal}}
<div class="flexrow">
<label></label>
<label>(-4 sans Cristal Alchimique)</label>
</div>
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div>
</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>
<div id="tableResolution"></div>
<div id="tableProbaReussite"></div>
</form>
<script>

View File

@ -1,5 +1,5 @@
<form class="skill-roll-dialog">
<h2 class="compdialog" id="compdialogTitle"></h2>
<h2 class="dialog-roll-title"></h2>
<div class="form-group">
<label>Difficulté libre</label>
<select name="diffLibre" id="diffLibre" data-dtype="number">
@ -24,7 +24,7 @@
<span class="tooltipAppelAuMoralText">Sans appel au moral</span>
</div>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}}
<div id="tableAjustements">
</div>
<div id="tableResolution">

View File

@ -14,7 +14,7 @@
</select>
</span>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}}
<div id="tableAjustements">
</div>
<div id="tableResolution">

View File

@ -1,5 +1,5 @@
<form class="skill-roll-dialog">
<h2 class="compdialog">Rêve de Dragon de force {{rencontre.force}}!</h2>
<h2>Rêve de Dragon de force {{rencontre.force}}!</h2>
<div class="form-group">
</div>
<div id="tableAjustements"></div>

View File

@ -0,0 +1,10 @@
<div class="flexrow">
<label>Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}>
{{#select diffConditions}}
{{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>

View File

@ -0,0 +1,10 @@
<div class="flexrow">
<label>Difficulté libre</label>
<select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless use.libre}}disabled{{/unless}}>
{{#select diffLibre}}
{{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>

View File

@ -0,0 +1,7 @@
<div class="flexrow">
<label class="diffMoral">Moral: {{#if (gt moral 0)}}+{{/if}}{{moral}}</label>
<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>