diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js
index 793ad9b3..28d238aa 100644
--- a/module/actor-creature-sheet.js
+++ b/module/actor-creature-sheet.js
@@ -42,9 +42,8 @@ export class RdDActorCreatureSheet extends ActorSheet {
data.data.caracSum = sum;
data.data.carac.taille.isTaille = true; // To avoid button link;
- data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
- data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
- data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
+ data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
+
data.data.isGM = game.user.isGM;
data.data.competencecreature = data.itemsByType["competencecreature"];
diff --git a/module/actor-humanoide-sheet.js b/module/actor-humanoide-sheet.js
index b321a3e5..a7360cf9 100644
--- a/module/actor-humanoide-sheet.js
+++ b/module/actor-humanoide-sheet.js
@@ -41,9 +41,9 @@ export class RdDActorHumanoideSheet extends ActorSheet {
data.data.caracSum = sum;
data.data.carac.taille.isTaille = true; // To avoid button link;
- data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
- data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
- data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
+ data.data.carac.chance.isChance = true; // Ajouter chance actuelle et utiliser;
+ data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
+
data.data.competencecreature = data.itemsByType["competencecreature"];
data.data.isGM = game.user.isGM;
diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 71515a82..ad95fb49 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -5,6 +5,7 @@
import { RdDUtility } from "./rdd-utility.js";
import { RdDEncaisser } from "./rdd-roll-encaisser.js";
+import { HtmlUtility } from "./html-utility.js";
/* -------------------------------------------- */
export class RdDActorSheet extends ActorSheet {
@@ -90,9 +91,8 @@ export class RdDActorSheet extends ActorSheet {
this.armesList = duplicate(data.data.combat);
data.data.carac.taille.isTaille = true; // To avoid button link;
- data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
- data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
- data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
+ data.data.compteurs.chance.isChance = true;
+ data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
// Mise à jour de l'encombrement total
this.actor.computeEncombrementTotalEtMalusArmure();
@@ -190,11 +190,7 @@ export class RdDActorSheet extends ActorSheet {
activateListeners(html) {
super.activateListeners(html);
- if (game.user.isGM) {
- $(".gm-only").show();
- } else {
- $(".gm-only").hide();
- }
+ HtmlUtility._showControlWhen(".gm-only", game.user.isGM);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
@@ -258,6 +254,14 @@ export class RdDActorSheet extends ActorSheet {
this.actor.rollCarac( caracName.toLowerCase() );
});
+ html.find('#chance-actuel').click((event) => {
+ this.actor.rollCarac( 'chance-actuel' );
+ });
+
+ html.find('#chance-appel').click((event) => {
+ this.actor.appelChance();
+ });
+
// Roll Skill
html.find('.competence-label a').click((event) => {
let compName = event.currentTarget.text;
diff --git a/module/actor.js b/module/actor.js
index 5cb8a8ef..9368dc2b 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -7,6 +7,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 { RdDRoll } from "./rdd-roll.js";
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
import { Misc } from "./misc.js";
@@ -108,6 +109,10 @@ export class RdDActor extends Actor {
return this.data.data.reve.reve.value;
}
+ getChanceActuel() {
+ return this.data.data.compteurs.chance.value;
+ }
+
/* -------------------------------------------- */
getBestDraconic() {
const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau);
@@ -271,7 +276,7 @@ export class RdDActor extends Actor {
this.computeRecul( rollData, encaisser );
} else { // This is the attack roll!
if (rolled.isSuccess) {
- let target = this.getTarget();
+ let target = this._getTarget();
if (await this.targetEntiteNonAccordee(target, 'avant-defense')) {
return;
}
@@ -863,6 +868,33 @@ export class RdDActor extends Actor {
}
}
+ computeResumeBlessure(blessures = this.data.data.blessures) {
+ let nbLegeres = this.countBlessures(blessures.legeres.liste );
+ let nbGraves = this.countBlessures(blessures.graves.liste );
+ let nbCritiques = this.countBlessures(blessures.critiques.liste );
+
+ let resume = "Blessures:";
+ if (nbCritiques > 0 || nbGraves > 0 || nbLegeres > 0) {
+ if (nbLegeres > 0) {
+ resume += " " + nbLegeres + " légères";
+ }
+ if (nbGraves > 0) {
+ if (nbLegeres > 0)
+ resume += ",";
+ resume += " " + nbGraves + " graves";
+ }
+ if (nbCritiques > 0) {
+ if (nbGraves > 0 || nbLegeres > 0)
+ resume += ",";
+ resume += " une CRITIQUE !";
+ }
+ }
+ else {
+ resume += " aucune";
+ }
+ return resume;
+ }
+
/* -------------------------------------------- */
computeEtatGeneral( )
{
@@ -978,7 +1010,7 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
- async reveActuelIncDec( value ) {
+ async reveActuelIncDec( value ) {
let reve = duplicate(this.data.data.reve.reve);
reve.value = Math.max(reve.value + value, 0);
await this.update( {"data.reve.reve": reve } );
@@ -1285,91 +1317,150 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async rollCarac( caracName )
{
- let carac;
- if ( caracName == "reveActuel") { // Fake carac for Reve Actuel
- carac = {type: "number",
- value: this.getReveActuel(),
- label: "Rêve Actuel"
- }
- } else {
- carac = this.data.data.carac[caracName];// Per default
- }
+ let carac = this.getCaracByName(caracName);
let rollData = {
- selectedCarac: carac,
- ajustementsConditions: CONFIG.RDD.ajustementsConditions,
- difficultesLibres: CONFIG.RDD.difficultesLibres,
- etat: this.data.data.compteurs.etat.value,
- finalLevel: 0,
- diffConditions: 0,
- diffLibre: 0,
- malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
- surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
- surencMalusValue: this.data.data.compteurs.surenc.value,
- surencMalusApply: false,
- isNatation: false,
- useEncForNatation: false
- }
- console.log(caracName, rollData);
- let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
- new RdDRollDialog("carac", html, rollData, this ).render(true);
+ selectedCarac: carac,
+ ajustementsConditions: CONFIG.RDD.ajustementsConditions,
+ difficultesLibres: CONFIG.RDD.difficultesLibres,
+ etat: this.data.data.compteurs.etat.value,
+ finalLevel: 0,
+ diffConditions: 0,
+ diffLibre: 0,
+ malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
+ surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
+ surencMalusValue: this.data.data.compteurs.surenc.value,
+ surencMalusApply: false,
+ isNatation: false,
+ useEncForNatation: false
}
-
- /* -------------------------------------------- */
- getSortList() {
- return this.data.items.filter(item => item.type == "sort");
- }
-
- /* -------------------------------------------- */
- getDraconicList() {
- return this.data.items.filter(item => item.data.categorie == 'draconic')
- }
-
- /* -------------------------------------------- */
- async displayTMR(mode="normal")
- {
- let isRapide= mode == "rapide"
- if (mode != "visu")
- {
- let minReveValue = (isRapide) ? 3 : 2;
- if (this.getReveActuel() < minReveValue ) {
- ChatMessage.create( {
- content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
- whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
- return;
- }
- }
-
- // Notification au MJ
- ChatMessage.create( { content: game.user.name + " est monté dans les TMR en mode : " + mode, whisper: ChatMessage.getWhisperRecipients("GM") } );
+ console.log(caracName, rollData);
+ let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
+ new RdDRollDialog("carac", html, rollData, this ).render(true);
+ }
- let data = {
- fatigue: {
- malus: RdDUtility.calculMalusFatigue(this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max),
- html: "
" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "
"
- },
- draconic: this.getDraconicList(),
- sort: this.getSortList(),
- caracReve: this.data.data.carac.reve.value,
- pointsReve: this.getReveActuel(),
- isRapide: isRapide
- }
- let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data );
- this.currentTMR = new RdDTMRDialog(html, this, data, mode);
- this.currentTMR.render(true);
+ async appelChance( )
+ {
+ let rollData = {
+ selectedCarac: this.getCaracByName('chance-actuelle'),
+ diffConditions: this.ajustementAstrologique()
}
- /* -------------------------------------------- */
- rollArme( armeName, competenceName=undefined )
- {
- let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
- if (armeItem ) {
- if ( competenceName == undefined) competenceName = armeItem.data.competence;
- this.rollCompetence( competenceName, armeItem );
- } else {
- this.rollCompetence( armeName ); //Bypass mode!
+ const dialog = await RdDRoll.create(
+ 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
+ this,
+ rollData,
+ {
+ name: 'appelChance',
+ label: 'Appel à la chance',
+ callbacks: [
+ { action: rollData => this._appelChanceResultat(rollData) }
+ ]
}
+ );
+ dialog.render(true);
+ }
+
+ _appelChanceResultat(rollData) {
+ const message = {
+ user: game.user._id,
+ alias: this.name,
+ content: this.name + " fait appel à la chance" + RdDResolutionTable.explain(rollData.rolled)
+ };
+ if (rollData.rolled.isSuccess) {
+ message.content += "
Dépense d'un point de chance, l'action peut être retentée"
+ this.chanceActuelleIncDec(-1)
+ }
+ ChatMessage.create(message);
+ }
+
+ async chanceActuelleIncDec(value) {
+ let chance = duplicate(this.data.data.compteurs.chance);
+ chance.value = Math.max(chance.value + value, 0);
+ await this.update( {"data.compteurs.chance": chance } );
+ }
+
+ ajustementAstrologique() {
+ //TODO: selon heure et heure de naissance...
+ return 0;
+ }
+
+ getCaracByName(caracName) {
+ switch (caracName)
+ {
+ case 'reveActuel':
+ return {
+ label: 'Rêve Actuel',
+ value: this.getReveActuel(),
+ type: "number",
+ ignoreEtatGeneral: true
+ };
+ case 'chance-actuelle':
+ return {
+ type: "number",
+ value: this.getChanceActuel(),
+ label: 'Chance actuelle',
+ ignoreEtatGeneral: true
+ };
+ default:
+ return this.data.data.carac[caracName]; // Per default
+ }
+ }
+
+ /* -------------------------------------------- */
+ getSortList() {
+ return this.data.items.filter(item => item.type == "sort");
+ }
+
+ /* -------------------------------------------- */
+ getDraconicList() {
+ return this.data.items.filter(item => item.data.categorie == 'draconic')
+ }
+
+ /* -------------------------------------------- */
+ async displayTMR(mode="normal")
+ {
+ let isRapide= mode == "rapide"
+ if (mode != "visu")
+ {
+ let minReveValue = (isRapide) ? 3 : 2;
+ if (this.getReveActuel() < minReveValue ) {
+ ChatMessage.create( {
+ content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
+ whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
+ return;
+ }
}
+ // Notification au MJ
+ ChatMessage.create( { content: game.user.name + " est monté dans les TMR en mode : " + mode, whisper: ChatMessage.getWhisperRecipients("GM") } );
+
+ let data = {
+ fatigue: {
+ malus: RdDUtility.calculMalusFatigue(this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max),
+ html: "" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "
"
+ },
+ draconic: this.getDraconicList(),
+ sort: this.getSortList(),
+ caracReve: this.data.data.carac.reve.value,
+ pointsReve: this.getReveActuel(),
+ isRapide: isRapide
+ }
+ let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data );
+ this.currentTMR = new RdDTMRDialog(html, this, data, mode);
+ this.currentTMR.render(true);
+ }
+
+ /* -------------------------------------------- */
+ rollArme( armeName, competenceName=undefined ) {
+ let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
+ if (armeItem ) {
+ if ( competenceName == undefined) competenceName = armeItem.data.competence;
+ this.rollCompetence( competenceName, armeItem );
+ } else {
+ this.rollCompetence( armeName ); //Bypass mode!
+ }
+ }
+
/* -------------------------------------------- */
async rollCompetence( name, armeItem=undefined, attackerRoll=undefined, attacker = undefined) {
let competence = RdDUtility.findCompetence( this.data.items, name);
@@ -1427,7 +1518,7 @@ export class RdDActor extends Actor {
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
if (rollData.arme) {
- if (await this.targetEntiteNonAccordee(this.getTarget(), 'avant-attaque')) {
+ if (await this.targetEntiteNonAccordee(this._getTarget(), 'avant-attaque')) {
return;
}
new RdDRollDialog("arme", html, rollData, this, attacker).render(true);
@@ -1436,8 +1527,7 @@ export class RdDActor extends Actor {
}
}
- /* -------------------------------------------- */
- getTarget() {
+ _getTarget() {
if (game.user.targets && game.user.targets.size == 1) {
for (let target of game.user.targets) {
return target;
@@ -1447,8 +1537,7 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
- async equiperObjet( itemID )
- {
+ async equiperObjet( itemID ) {
let item = this.getOwnedItem(itemID);
if ( item && item.data.data ) {
let update = {_id: item._id, "data.equipe": !item.data.data.equipe };
@@ -1488,7 +1577,6 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async encaisserDommages( attackerRoll, attacker = undefined ) {
-
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
return;
}
diff --git a/module/html-utility.js b/module/html-utility.js
new file mode 100644
index 00000000..28f3551d
--- /dev/null
+++ b/module/html-utility.js
@@ -0,0 +1,10 @@
+export class HtmlUtility{
+ static _showControlWhen(control, condition) {
+ if (condition) {
+ $(control).show();
+ }
+ else {
+ $(control).hide();
+ }
+ }
+}
\ No newline at end of file
diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js
index 9edf47d3..13ec0e76 100644
--- a/module/rdd-resolution-table.js
+++ b/module/rdd-resolution-table.js
@@ -80,24 +80,28 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static explain(rolled) {
- let message = "
Jet : " + rolled.roll + " sur " + rolled.score + "%";
+ let message = "
Jet : " + rolled.roll + " sur " + rolled.score + "% ";
if (rolled.caracValue != null && rolled.finalLevel!= null) {
- message += " (" + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ")";
+ message += "(" + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ") ";
}
+ message += rolled.quality
return message;
}
/* -------------------------------------------- */
static updateChancesWithBonus( chances, bonus ) {
- let newScore = Number(chances.score) + Number(bonus);
- chances.score = newScore;
- chances.sign = this._reussiteSignificative(newScore);
- chances.part = this._reussitePart(newScore);
- chances.epart = this._echecParticulier(newScore);
- chances.etotal = this._echecTotal(newScore);
+ if (bonus) {
+ let newScore = Number(chances.score) + Number(bonus);
+ mergeObject(chances, this._computeCell(null, newScore), {overwrite: true});
+ }
}
+ static async rollData(rollData ) {
+ rollData.rolled = await this.roll(rollData.caracValue, rollData.finalLevel, rollData.bonus);
+ return rollData;
+ }
+
/* -------------------------------------------- */
static async roll(caracValue, finalLevel, bonus = 0 ) {
let chances = this.computeChances(caracValue, finalLevel);
diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js
index c434c475..a73607b2 100644
--- a/module/rdd-roll-dialog.js
+++ b/module/rdd-roll-dialog.js
@@ -1,3 +1,4 @@
+import { HtmlUtility } from "./html-utility.js";
import { RdDItemSort } from "./item-sort.js";
import { Misc } from "./misc.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
@@ -71,20 +72,13 @@ export class RdDRollDialog extends Dialog {
rollData.finalLevel = rollLevel;
rollData.caracValue = caracValue
-
+
+ HtmlUtility._showControlWhen(".etat-general", !RdDRollDialog._isIgnoreEtatGeneral(rollData));
// Sort management
if ( rollData.selectedSort ) {
//console.log("Toggle show/hide", rollData.selectedSort);
- if (RdDItemSort.isDifficulteVariable(rollData.selectedSort)) {
- $("#div-sort-difficulte").show();
- } else {
- $("#div-sort-difficulte").hide();
- }
- if (RdDItemSort.isCoutVariable(rollData.selectedSort)) {
- $("#div-sort-ptreve").show();
- } else {
- $("#div-sort-ptreve").hide();
- }
+ HtmlUtility._showControlWhen("#div-sort-difficulte",RdDItemSort.isDifficulteVariable(rollData.selectedSort));
+ HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort));
}
// Mise à jour valeurs
@@ -167,9 +161,13 @@ export class RdDRollDialog extends Dialog {
});
}
+ static _isIgnoreEtatGeneral(rollData) {
+ return rollData.selectedCarac.ignoreEtatGeneral;
+ }
+
/* -------------------------------------------- */
static _computeFinalLevel(rollData) {
- const etat = Misc.toInt(rollData.etat);
+ const etat = RdDRollDialog._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
const diffConditions = Misc.toInt(rollData.diffConditions);
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
let diffLibre = Misc.toInt(rollData.diffLibre);
diff --git a/module/rdd-roll.js b/module/rdd-roll.js
new file mode 100644
index 00000000..0766b793
--- /dev/null
+++ b/module/rdd-roll.js
@@ -0,0 +1,230 @@
+import { HtmlUtility } from "./html-utility.js";
+import { RdDItemSort } from "./item-sort.js";
+import { Misc } from "./misc.js";
+import { RdDResolutionTable } from "./rdd-resolution-table.js";
+
+/**
+ * Extend the base Dialog entity to select roll parameters
+ * @extends {Dialog}
+ */
+
+export class RdDRoll extends Dialog {
+
+ static async create(htmlTemplate, actor, rollData, ...actions) {
+ RdDRoll._ensureCorrectActions(actions);
+
+ RdDRoll._setDefaultOptions(actor, rollData);
+
+ const html = await renderTemplate(htmlTemplate, rollData);
+
+ return new RdDRoll(actor, rollData, html, {
+ classes: ["rdddialog"],
+ width: 600, height: 500, 'z-index': 99999
+ }, actions);
+ }
+
+ static _setDefaultOptions(actor, rollData) {
+
+ mergeObject(rollData,
+ {
+ ajustementsConditions: CONFIG.RDD.ajustementsConditions,
+ difficultesLibres: CONFIG.RDD.difficultesLibres,
+ etat: actor.data.data.compteurs.etat.value,
+ finalLevel: 0,
+ diffConditions: 0,
+ diffLibre: 0,
+ malusArmureValue: 0,
+ surencMalusFlag: actor.data.data.attributs ? actor.data.data.attributs.malusarmure.value : 0,
+ surencMalusValue: actor.data.data.compteurs.surenc.value,
+ surencMalusApply: false,
+ isNatation: false,
+ useEncForNatation: false
+ },
+ { overwrite: false });
+ }
+
+ static _ensureCorrectActions(actions) {
+ if (actions.length==0) {
+ throw 'No action defined';
+ }
+ actions.forEach(action => {
+ if (action.callbacks == undefined) {
+ action.callbacks = [{action: r => console.log(action.name, r)}];
+ }
+ });
+ }
+
+ constructor(actor, rollData, html, options, actions) {
+ let conf = {
+ title: actions[0].label,
+ content: html,
+ buttons: {},
+ default: actions[0].name
+ };
+ for (let action of actions) {
+ conf.buttons[action.name] = { label: action.label, callback: html => this.onAction(action, html) };
+ }
+
+ super(conf, options);
+
+ this.actor = actor;
+ this.rollData = rollData;
+ }
+
+ async onAction(action, html) {
+ await RdDResolutionTable.rollData(this.rollData);
+ if (action.callbacks)
+ for (let callback of action.callbacks) {
+ if (callback.condition == undefined || callback.condition(this.rollData.rolled)) {
+ callback.action(this.rollData);
+ }
+ }
+ }
+
+ /* -------------------------------------------- */
+ activateListeners(html) {
+ super.activateListeners(html);
+
+ this.bringToTop();
+
+ var rollData = this.rollData;
+
+ function updateRollResult(rollData) {
+ let caracValue = parseInt(rollData.selectedCarac.value)
+ let rollLevel = RdDRoll._computeFinalLevel(rollData);
+
+ rollData.finalLevel = rollLevel;
+ rollData.caracValue = caracValue
+
+ HtmlUtility._showControlWhen(".etat-general", !RdDRoll._isIgnoreEtatGeneral(rollData));
+
+ // Sort management
+ if (rollData.selectedSort) {
+ //console.log("Toggle show/hide", rollData.selectedSort);
+ HtmlUtility._showControlWhen("#div-sort-difficulte", RdDItemSort.isDifficulteVariable(rollData.selectedSort))
+ HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort))
+ }
+
+ // Mise à jour valeurs
+ $("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel));
+ $("#compdialogTitle").text(RdDRoll._getTitle(rollData));
+ $(".table-resolution").remove();
+ $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel));
+ }
+
+ // Setup everything onload
+ $(function () {
+ // Update html, according to data
+ if (rollData.competence) {
+ // Set the default carac from the competence item
+ rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
+ $("#carac").val(rollData.competence.data.defaut_carac);
+ }
+ RdDItemSort.setCoutReveReel(rollData.selectedSort);
+ $("#diffLibre").val(Misc.toInt(rollData.diffLibre));
+ $("#diffConditions").val(Misc.toInt(rollData.diffConditions));
+ updateRollResult(rollData);
+ });
+
+ // Update !
+ html.find('#diffLibre').change((event) => {
+ rollData.diffLibre = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
+ //console.log("RdDRollSelectDialog","BM CLICKED !!!", rollData);
+ updateRollResult(rollData);
+ });
+ html.find('#diffConditions').change((event) => {
+ rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
+ //console.log("RdDRollSelectDialog","BM CLICKED !!!", rollData);
+ updateRollResult(rollData);
+ });
+ html.find('#carac').change((event) => {
+ let caracKey = event.currentTarget.value;
+ this.rollData.selectedCarac = rollData.carac[caracKey]; // Update the selectedCarac
+ //console.log("RdDRollSelectDialog","CARAC CLICKED !!!", rollData);
+ updateRollResult(rollData);
+ });
+ html.find('#draconic').change((event) => {
+ let draconicKey = Misc.toInt(event.currentTarget.value);
+ this.rollData.selectedDraconic = rollData.draconicList[draconicKey]; // Update the selectedCarac
+ //console.log("RdDRollSelectDialog","CARAC CLICKED !!!", rollData);
+ updateRollResult(rollData);
+ });
+ html.find('#sort').change((event) => {
+ let sortKey = Misc.toInt(event.currentTarget.value);
+ this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
+ RdDItemSort.setCoutReveReel(rollData.selectedSort);
+ //console.log("RdDRollSelectDialog - Sort selection", rollData.selectedSort);
+ updateRollResult(rollData);
+ });
+ html.find('#ptreve-variable').change((event) => {
+ let ptreve = Misc.toInt(event.currentTarget.value);
+ this.rollData.selectedSort.data.ptreve_reel = ptreve;
+ console.log("RdDRollSelectDialog - Cout reve", ptreve);
+ updateRollResult(rollData);
+ });
+ html.find('#ptreve-variable').change((event) => {
+ let ptreve = Misc.toInt(event.currentTarget.value);
+ this.rollData.selectedSort.data.ptreve_reel = ptreve; // Update the selectedCarac
+ console.log("RdDRollSelectDialog - Cout reve", ptreve);
+ updateRollResult(rollData);
+ });
+ html.find('#coupsNonMortels').change((event) => {
+ this.rollData.mortalite = event.currentTarget.checked ? "non-mortel" : "non-mortel";
+ });
+ html.find('#surencMalusApply').change((event) => {
+ this.rollData.surencMalusApply = event.currentTarget.checked;
+ updateRollResult(rollData);
+ });
+ html.find('#useEncForNatation').change((event) => {
+ this.rollData.useEncForNatation = event.currentTarget.checked;
+ updateRollResult(rollData);
+ });
+ }
+
+ static _isIgnoreEtatGeneral(rollData) {
+ return rollData.selectedCarac.ignoreEtatGeneral;
+ }
+
+ /* -------------------------------------------- */
+ static _computeFinalLevel(rollData) {
+ const etat = RdDRoll._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
+ const diffConditions = Misc.toInt(rollData.diffConditions);
+ let malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0;
+ let diffLibre = Misc.toInt(rollData.diffLibre);
+ let malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0;
+
+ // Gestion malus armure
+ let malusArmureValue = 0;
+ if (rollData.malusArmureValue != 0 && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) {
+ $("#addon-message").text("Malus armure appliqué : " + rollData.malusArmureValue);
+ malusArmureValue = rollData.malusArmureValue;
+ } else {
+ $("#addon-message").text("");
+ }
+
+ let diffCompetence = 0;
+ if (rollData.competence) {
+ diffCompetence = Misc.toInt(rollData.competence.data.niveau);
+ }
+ else if (rollData.draconicList) {
+ diffCompetence = Misc.toInt(rollData.selectedDraconic.data.niveau);
+ diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
+ }
+
+ return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue;
+ }
+
+ /* -------------------------------------------- */
+ static _getTitle(rollData) {
+ if (rollData.competence) {
+ // If a weapon is there, add it in the title
+ let armeTitle = (rollData.arme) ? " (" + rollData.arme.name + ") " : "";
+ let niveau = Misc.toSignedString(rollData.competence.data.niveau);
+ return rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveau
+ }
+ if (rollData.draconicList) {
+ return rollData.selectedDraconic.name + " - " + rollData.selectedSort.name;
+ }
+ return rollData.selectedCarac.label;
+ }
+}
diff --git a/system.json b/system.json
index 3b2a594b..69d3c3d9 100644
--- a/system.json
+++ b/system.json
@@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
- "version": "1.1.0",
+ "version": "1.1.1",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.7",
"templateVersion": 58,
diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html
index 6ccde2d1..ba5215f8 100644
--- a/templates/actor-creature-sheet.html
+++ b/templates/actor-creature-sheet.html
@@ -7,9 +7,7 @@
-
Blessures légères : {{data.nbLegeres}}
-
Blessures graves : {{data.nbGraves}}
-
Blessure critique : {{data.nbCritiques}}
+
{{data.blessures.resume}}
diff --git a/templates/actor-humanoide-sheet.html b/templates/actor-humanoide-sheet.html
index 691537b2..eefec3dc 100644
--- a/templates/actor-humanoide-sheet.html
+++ b/templates/actor-humanoide-sheet.html
@@ -7,9 +7,7 @@
-
Blessures légères : {{data.nbLegeres}}
-
Blessures graves : {{data.nbGraves}}
-
Blessure critique : {{data.nbCritiques}}
+
{{data.blessures.resume}}
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index 7a6af26f..859888b1 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -70,22 +70,11 @@
Malus de fatigue : {{data.fatigue.malus}}
{{{data.fatigue.html}}}
-
- {{#if data.nbLegeres}}
- Blessures: {{data.nbLegeres}} légères
- {{#if data.nbGraves}}, {{data.nbGraves}} graves{{/if}}
- {{#if data.nbCritiques}}, une CRITIQUE !{{/if}}
- {{else}}
- {{#if data.nbGraves}}
- Blessures:{{data.nbGraves}} graves
- {{#if data.nbCritiques}}et une CRITIQUE !{{data.nbCritiques}}{{/if}}
- {{else}}
- {{#if data.nbCritiques}}une CRITIQUE !{{data.nbCritiques}}
- {{else}}Aucune blessure
- {{/if}}
- {{/if}}
- {{/if}}
-
+ {{data.blessures.resume}}
+ {{data.compteurs.etat.label}}: {{data.compteurs.etat.value}}
+
+
+ {{data.compteurs.surenc.label}}: {{data.compteurs.surenc.value}}
@@ -118,12 +107,12 @@
{{else}}
{{carac.label}}
{{/if}}
- {{#if carac.derivee}}
-
- {{else}}
-
-
- {{/if}}
+ {{#if carac.derivee}}
+
+ {{else}}
+
+
+ {{/if}}
{{/each}}
@@ -135,16 +124,37 @@
{{#each data.attributs as |attr key|}}
- -
- {{attr.label}} : {{attr.value}}
-
- {{/each}}
- {{#each data.sante as |point key|}}
- -
- {{point.label}} : {{point.value}} / {{point.max}}
-
+ -
+ {{attr.label}} : {{attr.value}}
+
{{/each}}
+
+
@@ -336,31 +346,6 @@
{{!-- Compteurs/Blessures Tab --}}
-
{{!-- Liste de blessures --}}
Blessures Légeres :
diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html
index dc929b5f..316ef4cb 100644
--- a/templates/dialog-competence.html
+++ b/templates/dialog-competence.html
@@ -45,7 +45,7 @@
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-natation.html"}}
-