Moral sur les oeuvres

Simplification de l'appel au moral pour les oeuvres

Ajout de la possibilité d'utiliser le moral sur les oeuvres

Affichage du moral/appel selon la caractéristique
This commit is contained in:
Vincent Vandemeulebrouck
2021-03-16 21:49:21 +01:00
parent dab371578d
commit 98de1a6922
14 changed files with 199 additions and 178 deletions

View File

@ -489,15 +489,15 @@ export class RdDActorSheet extends ActorSheet {
this.actor.transformerStress();
this.render(true);
});
html.find('#moral-malheureux').click((event) => {
html.find('.moral-malheureux').click((event) => {
this.actor.jetDeMoral('malheureuse');
this.render(true);
});
html.find('#moral-neutre').click((event) => {
html.find('.moral-neutre').click((event) => {
this.actor.jetDeMoral('neutre');
this.render(true);
});
html.find('#moral-heureux').click((event) => {
html.find('.moral-heureux').click((event) => {
this.actor.jetDeMoral('heureuse');
this.render(true);
});

View File

@ -18,7 +18,7 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData, dialogConfig, ...actions) {
if (actor.isRollWindowsOpened() ) {
if (actor.isRollWindowsOpened()) {
ui.notifications.warn("Vous avez déja une fenêtre de Test ouverte, il faut la fermer avant d'en ouvrir une autre.")
return;
}
@ -49,20 +49,21 @@ export class RdDRoll extends Dialog {
diffConditions: 0,
diffLibre: rollData.competence?.data.default_diffLibre ?? 0,
malusArmureValue: actor.getMalusArmure(),
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
surencMalusValue: actor.getSurenc(),
useMalusSurenc: false,
appelAuMoralPossible : false, /* Est-ce que l'appel au moral est possible ? Variable utisé pour l'affichage ou non de la ligne concernant le moral */
appelAuMoralDemander :false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */
perteMoralEchec : false, /* Pour l'affichage dans le chat */
use: { libre: true, conditions: true, surenc: false, encTotal: false, appelAuMoral : false /* Le jet se fait ou non en utilisant l'appel au moral */},
useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */
perteMoralEchec: false, /* Pour l'affichage dans le chat */
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) {
rollData.carac = rollData.forceCarac;
@ -120,7 +121,7 @@ export class RdDRoll extends Dialog {
await RdDResolutionTable.rollData(this.rollData);
console.log("RdDRoll -=>", this.rollData, this.rollData.rolled);
this.actor.setRollWindowsOpened(false);
if (action.callbacks)
for (let callback of action.callbacks) {
if (callback.condition == undefined || callback.condition(this.rollData)) {
@ -206,27 +207,22 @@ export class RdDRoll extends Dialog {
this.rollData.useMalusEncTotal = event.currentTarget.checked;
this.updateRollResult();
});
html.find('#iconeSmile').change((event) => {
console.log("iconeSmile");
console.log(html.find('.iconeSmile'));
html.find('.imgAppelAuMoral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */
this.rollData.useMoral = !this.rollData.useMoral;
if (this.rollData.useMoral) {
if (this.rollData.moral > 0) {
html.find('.imgAppelAuMoral')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-heureux.svg";
html.find('.tooltipAppelAuMoralText')[0].innerHTML = "Appel au moral";
} else {
html.find('.imgAppelAuMoral')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-malheureux.svg";
html.find('.tooltipAppelAuMoralText')[0].innerHTML = "Appel à l'énergie du désespoir";
}
} else {
html.find('.imgAppelAuMoral')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg";
html.find('.tooltipAppelAuMoralText')[0].innerHTML = "Sans appel au moral";
}
this.updateRollResult();
});
html.find('#iconeSmile').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */
this.rollData.appelAuMoralDemander = ! this.rollData.appelAuMoralDemander;
if ( this.rollData.appelAuMoralDemander ) {
if ( this.rollData.moral > 0 ) {
html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-heureux.svg";
html.find('#tooltipAppelAuMoralText')[0].innerHTML = "Appel au moral";
} else {
html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-malheureux.svg";
html.find('#tooltipAppelAuMoralText')[0].innerHTML = "Appel à l'énergie du désespoir";
}
} else {
html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg";
html.find('#tooltipAppelAuMoralText')[0].innerHTML = "Sans appel au moral";
}
this.updateRollResult();
});
});
// Section Méditation
html.find('.conditionMeditation').change((event) => {
let condition = event.currentTarget.attributes['id'].value;
@ -238,10 +234,11 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */
async updateRollResult() {
let rollData = this.rollData;
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat());
rollData.caracValue = parseInt(rollData.selectedCarac.value);
rollData.coupsNonMortels = (rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite) == 'non-mortel';
rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac);
let dmgText = Misc.toSignedString(rollData.dmg.total);
if (rollData.coupsNonMortels) {
@ -252,21 +249,12 @@ export class RdDRoll extends Dialog {
HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort))
HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(rollData.selectedSort))
}
if ( ! RdDCarac.isActionPhysique(rollData.selectedCarac || ! actor.isPersonnage() ) ) {
rollData.appelAuMoralPossible = false;
rollData.use.appelAuMoral = false;
} else {
rollData.appelAuMoralPossible = true;
rollData.use.appelAuMoral = rollData.appelAuMoralDemander;
}
RollDataAjustements.calcul(rollData, this.actor);
rollData.finalLevel = this._computeFinalLevel(rollData);
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used);
HtmlUtility._showControlWhen($("#divAppelAuMoral"), rollData.appelAuMoralPossible );
HtmlUtility._showControlWhen($(".divAppelAuMoral"), rollData.use.appelAuMoral);
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence));
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));

View File

@ -73,8 +73,8 @@ export const referenceAjustements = {
getValue: (rollData, actor) => actor.getSurenc()
},
moral: {
isVisible: (rollData, actor) => RdDCarac.isActionPhysique(rollData.selectedCarac),
isUsed: (rollData, actor) => rollData.use?.appelAuMoral,
isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.useMoral,
isUsed: (rollData, actor) => rollData.useMoral,
getLabel: (rollData, actor) => 'Appel au moral',
getValue: (rollData, actor) => 1
},