Volonté ajusté par moral

This commit is contained in:
Vincent Vandemeulebrouck 2020-12-18 23:57:28 +01:00
parent 15d67e72a3
commit 6f22c4ab18
5 changed files with 31 additions and 17 deletions

View File

@ -109,6 +109,11 @@ export class RdDActor extends Actor {
return this.data.type == 'creature' || this.data.type == 'entite';
}
/* -------------------------------------------- */
isPersonnage() {
return this.data.type == 'personnage';
}
/* -------------------------------------------- */
getReveActuel() {
return this.data.data.reve.reve.value;

View File

@ -92,6 +92,9 @@ export class RdDResolutionTable {
let message = "<br>Difficultés <strong>libre: " + rollData.diffLibre + "</strong> / conditions: " + Misc.toSignedString(rollData.diffConditions)
+ " / état: " + rollData.etat;
message += RdDResolutionTable.explain(rollData.rolled)
if (rollData.selectedCarac == rollData.carac.volonte) {
message += " / moral: " + rollData.moral;
}
return message;
}

View File

@ -33,6 +33,7 @@ export class RdDRoll extends Dialog {
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
difficultesLibres: CONFIG.RDD.difficultesLibres,
etat: actor.data.data.compteurs.etat.value,
moral: actor.isPersonnage() ? actor.data.data.compteurs.moral.value : 0,
carac: actor.data.data.carac,
finalLevel: 0,
diffConditions: rollData.arme ? RdDBonus.bonusAttaque(rollData.surpriseDefenseur) :0,
@ -40,9 +41,9 @@ export class RdDRoll extends Dialog {
editLibre: true,
editConditions: true,
forceValue: actor.getForceValue(),
malusArmureValue: (actor.type == 'personnage ' && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0,
surencMalusFlag: actor.type == 'personnage ' ? (actor.data.data.compteurs.surenc.value < 0) : false,
surencMalusValue: actor.type == 'personnage ' ? actor.data.data.compteurs.surenc.value : 0,
malusArmureValue: (actor.isPersonnage() && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0,
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
surencMalusValue: actor.isPersonnage() ? actor.data.data.compteurs.surenc.value : 0,
surencMalusApply: false,
isNatation: rollData.competence ? rollData.competence.name.toLowerCase().includes("natation") : false,
useEncForNatation: false,
@ -103,10 +104,11 @@ export class RdDRoll extends Dialog {
var rollData = this.rollData;
var actor = this.actor;
var dialog = this;
function updateRollResult(rollData) {
let caracValue = parseInt(rollData.selectedCarac.value)
let rollLevel = RdDRoll._computeFinalLevel(rollData);
let rollLevel = dialog._computeFinalLevel(rollData);
rollData.dmg = rollData.attackerRoll ? rollData.attackerRoll.dmg : RdDBonus.dmg(rollData, actor.getBonusDegat());
rollData.finalLevel = rollLevel;
rollData.caracValue = caracValue;
@ -116,7 +118,8 @@ export class RdDRoll extends Dialog {
dmgText = '(' + dmgText + ')';
}
HtmlUtility._showControlWhen(".etat-general", !RdDRoll._isIgnoreEtatGeneral(rollData));
HtmlUtility._showControlWhen(".diffMoral", rollData.selectedCarac == actor.data.data.carac.volonte);
HtmlUtility._showControlWhen(".etat-general", !dialog._isIgnoreEtatGeneral(rollData));
// Sort management
if (rollData.selectedSort) {
@ -128,7 +131,7 @@ export class RdDRoll extends Dialog {
// Mise à jour valeurs
$("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel));
$("#compdialogTitle").text(RdDRoll._getTitle(rollData));
$("#compdialogTitle").text(dialog._getTitle(rollData));
$('#coupsNonMortels').prop('checked', rollData.coupsNonMortels);
$("#dmg-arme-actor").text(dmgText);
$("#defenseur-surprise").text(RdDBonus.description(rollData.surpriseDefenseur));
@ -213,28 +216,29 @@ export class RdDRoll extends Dialog {
});
}
static _isIgnoreEtatGeneral(rollData) {
_isIgnoreEtatGeneral(rollData) {
return rollData.selectedCarac.ignoreEtatGeneral;
}
/* -------------------------------------------- */
static _computeFinalLevel(rollData) {
const etat = RdDRoll._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
_computeFinalLevel(rollData) {
const etat = this._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
const diffConditions = Misc.toInt(rollData.diffConditions);
const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0;
const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique);
const malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0;
const ajustementChance = rollData.selectedCarac.label.toLowerCase().includes('chance') ? rollData.ajustementAstrologique : 0;
// Gestion malus armure
const malusArmureValue = RdDRoll._computeMalusArmure(rollData);
const malusArmureValue = this._computeMalusArmure(rollData);
const diffLibre = RdDRoll._computeDiffLibre(rollData);
const diffCompetence = RdDRoll._computeDiffCompetence(rollData);
const diffLibre = this._computeDiffLibre(rollData);
const diffCompetence = this._computeDiffCompetence(rollData);
const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0;
return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue + ajustementChance + bonusTactique;
return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncNatation + malusArmureValue + ajustementChance + bonusTactique;
}
static _computeDiffCompetence(rollData) {
_computeDiffCompetence(rollData) {
if (rollData.competence) {
return Misc.toInt(rollData.competence.data.niveau);
}
@ -244,7 +248,7 @@ export class RdDRoll extends Dialog {
return 0;
}
static _computeDiffLibre(rollData) {
_computeDiffLibre(rollData) {
let diffLibre = Misc.toInt(rollData.diffLibre);
if (rollData.draconicList && rollData.selectedSort) {
return RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
@ -252,7 +256,7 @@ export class RdDRoll extends Dialog {
return diffLibre;
}
static _computeMalusArmure(rollData) {
_computeMalusArmure(rollData) {
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);
@ -264,7 +268,7 @@ export class RdDRoll extends Dialog {
}
/* -------------------------------------------- */
static _getTitle(rollData) {
_getTitle(rollData) {
if (rollData.competence) {
// If a weapon is there, add it in the title
let armeTitle = (rollData.arme) ? " (" + rollData.arme.name + ") " : "";

View File

@ -33,6 +33,7 @@
{{/each}}
{{/select}}
</select>
<label class="diffMoral" for="categorie">Moral: {{#if (gt moral 0)}}+{{/if}}{{moral}}</label>
</div>
{{#if arme}}
<div class="form-group">

View File

@ -17,6 +17,7 @@
{{/each}}
{{/select}}
</select>
<label class="diffMoral" for="categorie">Moral: {{#if (gt moral 0)}}+{{/if}}{{moral}}</label>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
<div class="form-group etat-general">