Gestion des signes draconiques #455

Closed
vincent.vandeme wants to merge 233 commits from v1.4-signes-draconiques into master
3 changed files with 25 additions and 33 deletions
Showing only changes of commit 710a768bb6 - Show all commits

View File

@ -1590,7 +1590,8 @@ export class RdDActor extends Actor {
etat: this.getEtatGeneral({ ethylisme: true }), etat: this.getEtatGeneral({ ethylisme: true }),
diffNbDoses: -Number(actorData.data.compteurs.ethylisme.nb_doses || 0), diffNbDoses: -Number(actorData.data.compteurs.ethylisme.nb_doses || 0),
finalLevel: 0, finalLevel: 0,
diffConditions: 0 diffConditions: 0,
ajustementsForce: CONFIG.RDD.difficultesLibres,
} }
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ethylisme.html', rollData); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ethylisme.html', rollData);
new RdDRollDialogEthylisme(html, rollData, this, r => this.performEthylisme(r)).render(true); new RdDRollDialogEthylisme(html, rollData, this, r => this.performEthylisme(r)).render(true);

View File

@ -16,7 +16,7 @@ export class RdDRollDialogEthylisme extends Dialog {
default: "rollButton", default: "rollButton",
buttons: { "rollButton": { label: "Test d'éthylisme", callback: html => this.onButton(html) } } buttons: { "rollButton": { label: "Test d'éthylisme", callback: html => this.onButton(html) } }
}; };
let dialogOptions = { classes: ["rdddialog"], width: 400, height: 220, 'z-index': 99999 } let dialogOptions = { classes: ["rdddialog"], width: 400, height: 270, 'z-index': 99999 }
super(dialogConf, dialogOptions) super(dialogConf, dialogOptions)
//console.log("ETH", rollData); //console.log("ETH", rollData);
@ -36,28 +36,27 @@ export class RdDRollDialogEthylisme extends Dialog {
this.bringToTop(); // Ensure top level this.bringToTop(); // Ensure top level
// Get the rollData stuff // Get the rollData stuff
var rollData = this.rollData; var rollData = this.rollData;
var dialog = this;
function updateRollResult(rollData) {
rollData.finalLevel = Number(rollData.etat) + Number(rollData.forceAlcool) + rollData.diffNbDoses;
// Mise à jour valeurs
$("#roll-param").text(rollData.vieValue + " / " + Misc.toSignedString(rollData.finalLevel));
$(".table-resolution").remove();
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(rollData.vieValue, rollData.finalLevel));
}
// Setup everything onload // Setup everything onload
$(function () { $(function () {
$("#forceAlcool").val(Misc.toInt(rollData.forceAlcool)); $("#forceAlcool").val(Misc.toInt(rollData.forceAlcool));
updateRollResult(rollData); dialog.updateRollResult();
}); });
// Update ! // Update !
html.find('#forceAlcool').change((event) => { html.find('#forceAlcool').change((event) => {
rollData.forceAlcool = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus rollData.forceAlcool = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
updateRollResult(rollData); dialog.updateRollResult();
}); });
} }
async updateRollResult() {
this.rollData.finalLevel = Number(this.rollData.etat) + Number(this.rollData.forceAlcool) + this.rollData.diffNbDoses;
// Mise à jour valeurs
$("#roll-param").text(this.rollData.vieValue + " / " + Misc.toSignedString(this.rollData.finalLevel));
$(".table-resolution").remove();
}
} }

View File

@ -1,27 +1,19 @@
<form class="rdddialog"> <form class="rdddialog">
<h2>Boire</h2>
<div class="form-group"> <img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/objets/chope_gres.webp" alt="Chope d'alcool"/>
<label>Vie : {{vieValue}}</label> <div class="grid grid-2col">
<label>Etat général : {{etat}}</label> <label>Vie</label><label class="flexrow"> {{vieValue}}</label>
<label>Déjà bu : {{diffNbDoses}}</label> <label>Etat général</label><label class="flexrow">{{etat}}</label>
</div> <label>Déjà bu</label><label class="flexrow">{{diffNbDoses}}</label>
<label>Force du breuvage</label>
<div class="form-group" id="div-sort-difficulte">
<label>Force du breuvage </label>
<select name="forceAlcool" id="forceAlcool" data-dtype="number"> <select name="forceAlcool" id="forceAlcool" data-dtype="number">
{{#select forceAlcool}} {{#select forceAlcool}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsForce as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{key}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
<label>Ajustement final</label><label id="roll-param">10 / 0</label>
</div> </div>
<div class="form-group">
<label>Ajustement final : <label id="roll-param">10 / 0</label>&nbsp;&nbsp;&nbsp;<label name="addon-message" id="addon-message"></label></label>
</div>
<div id="tableResolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>