Preparation maîtrise fleuve

This commit is contained in:
Vincent Vandemeulebrouck 2021-02-06 02:29:58 +01:00
parent 0e037b0c34
commit aa1c93ce22
6 changed files with 43 additions and 30 deletions

View File

@ -1731,8 +1731,7 @@ export class RdDActor extends Actor {
sortList: sortList,
competence: this.getBestDraconic(),
selectedSort: sortList[0],
coord: coord,
coordLabel: TMRUtility.getTMR(coord).label,
tmr: TMRUtility.getTMR(coord),
diffLibre: sortList[0].data.difficulte, // Per default at startup
coutreve: Array(20).fill().map((item, index) => 1 + index)
}

View File

@ -46,15 +46,16 @@ export class RdDRoll extends Dialog {
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
surencMalusValue: actor.getSurenc(),
useMalusSurenc: false,
use: { libre:true, conditions: true, surenc: false, encTotal: false, },
use: { libre: true, conditions: true, surenc: false, encTotal: false, },
isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
useMalusEncTotal: false,
encTotal: actor.getEncTotal(),
ajustementAstrologique: actor.ajustementAstrologique(),
surprise: actor.getSurprise(false),
canClose: true
}
mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false });
if ( rollData.forceCarac) {
if (rollData.forceCarac) {
rollData.carac = rollData.forceCarac;
}
RollDataAjustements.calcul(rollData, actor);
@ -82,7 +83,12 @@ export class RdDRoll extends Dialog {
close: close
};
for (let action of actions) {
conf.buttons[action.name] = { label: action.label, callback: html => this.onAction(action, html) };
conf.buttons[action.name] = {
label: action.label, callback: html => {
this.rollData.canClose = true;
this.onAction(action, html)
}
};
}
super(conf, options);
@ -91,6 +97,14 @@ export class RdDRoll extends Dialog {
this.rollData = rollData;
}
close() {
if (this.rollData.canClose) {
return super.close();
}
ui.notifications.info("Vous devez faire ce jet de dés!");
}
/* -------------------------------------------- */
async onAction(action, html) {
await RdDResolutionTable.rollData(this.rollData);
@ -111,7 +125,7 @@ export class RdDRoll extends Dialog {
this.bringToTop();
var dialog = this;
function onLoad() {
let rollData = dialog.rollData;
// Update html, according to data
@ -121,7 +135,7 @@ export class RdDRoll extends Dialog {
$("#carac").val(rollData.competence.data.defaut_carac);
}
if (rollData.selectedSort) {
$("#draconic").val( rollData.selectedSort.data.listIndex ); // Uniquement a la selection du sort, pour permettre de changer
$("#draconic").val(rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer
}
RdDItemSort.setCoutReveReel(rollData.selectedSort);
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
@ -154,9 +168,9 @@ export class RdDRoll extends Dialog {
html.find('#sort').change((event) => {
let sortKey = Misc.toInt(event.currentTarget.value);
this.rollData.selectedSort = this.rollData.sortList[sortKey]; // Update the selectedCarac
this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.coord);
this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.tmr.coord);
RdDItemSort.setCoutReveReel(this.rollData.selectedSort);
$("#draconic").val( this.rollData.selectedSort.data.listIndex ); // Uniquement a la selection du sort, pour permettre de changer
$("#draconic").val(this.rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer
this.updateRollResult();
});
html.find('#ptreve-variable').change((event) => {
@ -208,29 +222,22 @@ export class RdDRoll extends Dialog {
dmgText = '(' + dmgText + ')';
}
if (rollData.selectedSort) {
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord);
}
RollDataAjustements.calcul(rollData, this.actor);
rollData.finalLevel = this._computeFinalLevel(rollData);
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used);
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence));
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
// Sort management
if (rollData.selectedSort) {
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord);
//console.log("Toggle show/hide", rollData.selectedSort);
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.tmr.coord);
HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort))
HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(rollData.selectedSort))
}
RollDataAjustements.calcul(rollData, this.actor);
rollData.finalLevel = this._computeFinalLevel(rollData);
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used);
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence));
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
// Mise à jour valeurs
$("#compdialogTitle").text(this._getTitle(rollData));
$('#coupsNonMortels').prop('checked', rollData.coupsNonMortels);
$("#dmg-arme-actor").text(dmgText);
// $("#defenseur-surprise").text(RdDBonus.description(rollData.ajustements.attaqueDefenseurSurpris.descr));
$('.table-ajustement').remove();
$(".table-resolution").remove();
$(".table-proba-reussite").remove();
@ -241,7 +248,7 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */
async buildAjustements(rollData){
async buildAjustements(rollData) {
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData);
return html;
}

View File

@ -292,6 +292,9 @@ export class RdDTMRDialog extends Dialog {
let dialog = new RdDTMRRencontreDialog("", this, this.currentRencontre, postRencontre);
dialog.render(true);
}
else {
postRencontre();
}
}
/* -------------------------------------------- */

View File

@ -116,8 +116,8 @@ export const referenceAjustements = {
getDescr: (rollData, actor) => rollData.selectedSort && rollData.coord ? `Bonus de case: ${RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord)}%` : ''
},
rencontreTMR: {
isVisible: (rollData, actor) => rollData.tmr && rollData.rencontre.name,
isUsed: (rollData, actor) => rollData.tmr && rollData.rencontre.name,
isVisible: (rollData, actor) => rollData.tmr && rollData.rencontre?.name,
isUsed: (rollData, actor) => rollData.tmr && rollData.rencontre?.name,
getLabel: (rollData, actor) => rollData.rencontre?.name,
getValue: (rollData, actor) => - (rollData.rencontre?.force ?? 0)
}

View File

@ -4,7 +4,7 @@
le {{#if selectedSort.data.isrituel}}rituel{{else}}sort{{/if}}
{{selectedSort.name}}
</h4>
<div>Pour {{selectedSort.data.ptreve_reel}} point{{~#if (gt selectedSort.data.ptreve_reel 1)}}s{{/if}} de rêve en {{coordLabel}} ({{coord}}).
<div>Pour {{selectedSort.data.ptreve_reel}} point{{~#if (gt selectedSort.data.ptreve_reel 1)}}s{{/if}} de rêve en {{tmr.label}} ({{tmr.coord}}).
{{#if show.reveInsuffisant}}
<span>Pas assez de rêve!</span>
{{/if}}
@ -22,4 +22,8 @@
{{else}}{{depenseReve}} points de rêve ont été dépensés
{{~/if}}.
</span>
</div>
</div>
<hr>
<span class="poesie-extrait">
{{{selectedSort.data.description}}}
</span>

View File

@ -1,7 +1,7 @@
<form class="dialog-roll-sort">
<div class="form-group">
<label for="categorie">Rêve : <label>{{numberFormat selectedCarac.value decimals=0 sign=false}}</label></label>
<label for="categorie">TMR : {{coord}} - {{coordLabel}}</label>
<label for="categorie">TMR : {{tmr.label}} ({{tmr.coord}})</label>
</div>
<div class="form-group">