#63 Jet d'éthylisme

This commit is contained in:
sladecraven 2020-12-06 20:11:30 +01:00
parent 54825fe756
commit 775f0c0423
9 changed files with 143 additions and 4 deletions

View File

@ -381,6 +381,10 @@ export class RdDActorSheet extends ActorSheet {
this.actor.stressTest();
this.render(true);
});
html.find('#ethylisme-test').click((event) => {
this.actor.ethylismeTest();
this.render(true);
});
html.find('#vie-plus').click((event) => {
this.actor.santeIncDec("vie", 1);

View File

@ -6,6 +6,7 @@
import { RdDUtility } from "./rdd-utility.js";
import { TMRUtility } from "./tmr-utility.js";
import { RdDRollDialog } from "./rdd-roll-dialog.js";
import { RdDRollDialogEthylisme } from "./rdd-roll-ethylisme.js";
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
import { Misc } from "./misc.js";
@ -1160,6 +1161,43 @@ export class RdDActor extends Actor {
this.update( { "data.blessures": blessures } );
}
/* -------------------------------------------- */
async ethylismeTest() {
let rollData = {
vieValue: this.data.data.sante.vie.value,
etat: this.data.data.compteurs.etat.value,
niveauEthylisme: this.data.data.compteurs.ethylisme.value,
nbDoses: this.data.data.compteurs.ethylisme.nb_doses || 0,
finalLevel: 0,
diffConditions: 0,
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
forceAlcool: 0
}
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ethylisme.html', rollData);
new RdDRollDialogEthylisme(html, rollData, this ).render(true);
}
/* -------------------------------------------- */
async performEthylisme( rollData ) {
let ethylisme = duplicate(this.data.data.compteurs.ethylisme);
let roll = await RdDResolutionTable.roll( rollData.vieValue, rollData.finalLevel);
let msgText;
if (roll.isSuccess ) {
ethylisme.value = ethylisme.value - 1;
msgText = "Vous avez échouez à votre jet d'éthylisme, votre niveau d'éthylisme est de " + ethylisme.value
+ "(" + RdDUtility.getNomEthylisme(ethylisme.value) + ")";
} else {
ethylisme.nb_doses = ethylisme.nb_doses + 1;
msgText = "Vous avez réussitvotre jet d'éthylisme, votre vous avez désormais " + ethylisme.nb_doses + " doses sans effet.";
}
const message = {
content: msgText,
whisper: ChatMessage.getWhisperRecipients(game.user.name)
};
ChatMessage.create(message);
}
/* -------------------------------------------- */
async stressTest() {
const message = {
@ -1171,6 +1209,7 @@ export class RdDActor extends Actor {
ChatMessage.create(message);
}
/* -------------------------------------------- */
async transformerStress(message) {
const stress = Misc.toInt(this.data.data.compteurs.stress.value);
if (stress<=0) {

View File

@ -0,0 +1,58 @@
import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { Misc } from "./misc.js";
/**
* Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog}
*/
export class RdDRollDialogEthylisme extends Dialog {
/* -------------------------------------------- */
constructor(html, rollData, actor) {
let myButtons = {
rollButton: { label: "Lancer", callback: html => this.actor.performEthylisme(this.rollData) }
};
// Common conf
let dialogConf = { content: html, title: "Test d'éthylisme", buttons: myButtons, default: "rollButton" };
let dialogOptions = { classes: ["rdddialog"], width: 400, height: 400, 'z-index': 99999 }
super(dialogConf, dialogOptions)
console.log("ETH", rollData);
this.rollData = rollData;
this.actor = actor;
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
this.bringToTop(); // Ensure top level
// Get the rollData stuff
var rollData = this.rollData;
function updateRollResult(rollData) {
let rollLevel = Number(rollData.etat) + Number(rollData.forceAlcool) + Number(rollData.niveauEthylisme) - Number(rollData.nbDoses);
rollData.finalLevel = rollLevel;
// Mise à jour valeurs
$("#roll-param").text(rollData.vieValue + " / " + Misc.toSignedString(rollData.finalLevel));
$(".table-resolution").remove();
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(rollData.vieValue, rollLevel));
}
// Setup everything onload
$(function () {
$("#forceAlcool").val(Misc.toInt(rollData.forceAlcool));
updateRollResult(rollData);
});
// Update !
html.find('#forceAlcool').change((event) => {
rollData.forceAlcool = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
updateRollResult(rollData);
});
}
}

View File

@ -190,6 +190,11 @@ export class RdDUtility {
return [];
}
/* -------------------------------------------- */
getNomEthylisme( niveauEthylisme ) {
}
/* -------------------------------------------- */
static initAfficheContenu( actorId ) { // persistent handling of conteneur show/hide
if ( !this.afficheContenu )

View File

@ -5,7 +5,7 @@
"version": "1.1.0",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.7",
"templateVersion": 56,
"templateVersion": 58,
"author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"],

View File

@ -488,7 +488,8 @@
"ethylisme": {
"value": 0,
"label": "Ethylisme",
"isInput": true
"isInput": true,
"nb_doses": 0
},
"stress": {
"value": 0,

View File

@ -346,8 +346,13 @@
{{#if compteur.isStress}}
<a class="item-control stress-test" id="stress-test" title="Faire un jet de Stress">Faire un jet de Stress</a>
{{else}}
{{#if (eq compteur.label 'Ethylisme')}}
<a class="item-control ethylisme-test" id="ethylisme-test" title="Faire un jet d'Ethylisme">Faire un jet d'Ethylisme</a>
{{else}}
<label></label>
{{/if}}
{{/if}}
<label></label>
{{/if}}
<label></label>
{{else}}
<span class="competence-label">{{compteur.value}}</span>

View File

@ -0,0 +1,27 @@
<form class="dialog-roll-sort">
<h2 class="compdialog" id="ethylisme-dialog"></h2>
<div class="form-group">
<label for="categorie">Vie : {{vieValue}}</label>
<label for="categorie">Etat Général : {{etat}}</label>
</div>
<div class="form-group" id="div-sort-difficulte">
<label for="categorie">Force du breuvage </label>
<select name="forceAlcool" id="forceAlcool" data-dtype="number">
{{#select forceAlcool}}
{{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="form-group">
<label>Ajustement final : </label><label id="roll-param">10 / 0</label>&nbsp;&nbsp;&nbsp;<label name="addon-message" id="addon-message"></label>
</div>
<div id="resolutionTable">
</div>
</form>

View File

@ -2,7 +2,7 @@
<h2 class="compdialog" id="sort-dialog"></h2>
<div class="form-group">
<label for="categorie">Rêve : {{selectedCarac.value}}</label>
<label for="categorie">Rêve : {{vieValue}}</label>
<label for="categorie">TMR : {{coord}} - {{coordLabel}}</label>
</div>