Merge branch 'feature/appelAuMoral' into 'v1.3'
Feature/appel au moral See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!148
This commit is contained in:
commit
5fab913b77
@ -1653,7 +1653,15 @@ export class RdDActor extends Actor {
|
|||||||
action: r => this._appliquerAjoutExperience(r, game.settings.get("core", "rollMode") != 'blindroll')
|
action: r => this._appliquerAjoutExperience(r, game.settings.get("core", "rollMode") != 'blindroll')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
createCallbackAppelAuMoral() { /* Si l'appel au moral est utilisé, on l'affiche dans le chat et on diminue éventuellement le moral */
|
||||||
|
return {
|
||||||
|
condition: r => r.use.appelAuMoral && game.settings.get("core", "rollMode") != 'selfroll',
|
||||||
|
action: r => { console.log("createCallbackAppelAuMoral"); this.displayAppelAuMoral ; console.log(r.rolled.isEchec); this._appliquerAppelMoral(r, game.settings.get("core", "rollMode") != 'blindroll') }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async checkCaracXP(caracName) {
|
async checkCaracXP(caracName) {
|
||||||
let carac = this.data.data.carac[caracName];
|
let carac = this.data.data.carac[caracName];
|
||||||
@ -1723,6 +1731,14 @@ export class RdDActor extends Actor {
|
|||||||
if (xpResult && xpResult.xpCarac > 0 && rollData.selectedCarac) {
|
if (xpResult && xpResult.xpCarac > 0 && rollData.selectedCarac) {
|
||||||
this.checkCaracXP(rollData.selectedCarac.name);
|
this.checkCaracXP(rollData.selectedCarac.name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async _appliquerAppelMoral(rollData, display = true) {
|
||||||
|
if (!this.isPersonnage()) return;
|
||||||
|
if (!rollData.rolled.isEchec) return;
|
||||||
|
const waitUpdate = this.moralIncDec(-1); /* L'appel au moral a échoué. Le personnage perd un point de moral */
|
||||||
|
rollData.jetEchouerMoralDiminuer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -1977,6 +1993,7 @@ export class RdDActor extends Actor {
|
|||||||
label: 'Jet ' + Grammar.apostrophe('de', name),
|
label: 'Jet ' + Grammar.apostrophe('de', name),
|
||||||
callbacks: [
|
callbacks: [
|
||||||
this.createCallbackExperience(),
|
this.createCallbackExperience(),
|
||||||
|
this.createCallbackAppelAuMoral(),
|
||||||
{ action: r => this._competenceResult(r) }
|
{ action: r => this._competenceResult(r) }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@ -2202,7 +2219,9 @@ export class RdDActor extends Actor {
|
|||||||
async _competenceResult(rollData) {
|
async _competenceResult(rollData) {
|
||||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-competence.html')
|
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-competence.html')
|
||||||
}
|
}
|
||||||
|
async _moralDecrease(rollData) {
|
||||||
|
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-competence.html')
|
||||||
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
|
async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
|
||||||
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
|
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
|
||||||
|
@ -29,4 +29,4 @@ export class RdDCarac {
|
|||||||
static isActionPhysique(selectedCarac) {
|
static isActionPhysique(selectedCarac) {
|
||||||
return Grammar.toLowerCaseNoAccent(selectedCarac?.label).match(/(apparence|force|agilite|dexterite|vue|ouie|odorat|empathie|melee|tir|lancer|derobee)/);
|
return Grammar.toLowerCaseNoAccent(selectedCarac?.label).match(/(apparence|force|agilite|dexterite|vue|ouie|odorat|empathie|melee|tir|lancer|derobee)/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,19 @@ export class RdDRoll extends Dialog {
|
|||||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||||
etat: actor.getEtatGeneral(),
|
etat: actor.getEtatGeneral(),
|
||||||
moral: actor.getMoralTotal(),
|
moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */
|
||||||
carac: actor.data.data.carac,
|
carac: actor.data.data.carac,
|
||||||
finalLevel: 0,
|
finalLevel: 0,
|
||||||
diffConditions: 0,
|
diffConditions: 0,
|
||||||
diffLibre: rollData.competence?.data.default_diffLibre ?? 0,
|
diffLibre: rollData.competence?.data.default_diffLibre ?? 0,
|
||||||
malusArmureValue: actor.getMalusArmure(),
|
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(),
|
surencMalusValue: actor.getSurenc(),
|
||||||
useMalusSurenc: false,
|
useMalusSurenc: false,
|
||||||
use: { libre: true, conditions: true, surenc: false, encTotal: 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. */
|
||||||
|
jetEchouerMoralDiminuer : 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 */},
|
||||||
isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
|
isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
|
||||||
useMalusEncTotal: false,
|
useMalusEncTotal: false,
|
||||||
encTotal: actor.getEncTotal(),
|
encTotal: actor.getEncTotal(),
|
||||||
@ -195,6 +198,27 @@ export class RdDRoll extends Dialog {
|
|||||||
this.rollData.useMalusEncTotal = event.currentTarget.checked;
|
this.rollData.useMalusEncTotal = event.currentTarget.checked;
|
||||||
this.updateRollResult();
|
this.updateRollResult();
|
||||||
});
|
});
|
||||||
|
html.find('#iconeSmile').change((event) => {
|
||||||
|
console.log("iconeSmile");
|
||||||
|
console.log(html.find('.iconeSmile'));
|
||||||
|
this.updateRollResult();
|
||||||
|
});
|
||||||
|
html.find('#useAppelAuMoralCheckbox').change((event) => { /* l'appel au moral, qui donne un bonus de +1 */
|
||||||
|
this.rollData.appelAuMoralDemander = event.currentTarget.checked
|
||||||
|
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('#textSmile')[0].innerHTML = "Appel au moral";
|
||||||
|
} else {
|
||||||
|
html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-malheureux.svg";
|
||||||
|
html.find('#textSmile')[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('#textSmile')[0].innerHTML = "Sans appel au moral";
|
||||||
|
}
|
||||||
|
this.updateRollResult();
|
||||||
|
});
|
||||||
// Section Méditation
|
// Section Méditation
|
||||||
html.find('.conditionMeditation').change((event) => {
|
html.find('.conditionMeditation').change((event) => {
|
||||||
let condition = event.currentTarget.attributes['id'].value;
|
let condition = event.currentTarget.attributes['id'].value;
|
||||||
@ -206,7 +230,7 @@ export class RdDRoll extends Dialog {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateRollResult() {
|
async updateRollResult() {
|
||||||
let rollData = this.rollData;
|
let rollData = this.rollData;
|
||||||
|
|
||||||
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat());
|
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat());
|
||||||
rollData.caracValue = parseInt(rollData.selectedCarac.value);
|
rollData.caracValue = parseInt(rollData.selectedCarac.value);
|
||||||
rollData.coupsNonMortels = (rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite) == 'non-mortel';
|
rollData.coupsNonMortels = (rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite) == 'non-mortel';
|
||||||
@ -220,11 +244,21 @@ export class RdDRoll extends Dialog {
|
|||||||
HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort))
|
HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort))
|
||||||
HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(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);
|
RollDataAjustements.calcul(rollData, this.actor);
|
||||||
rollData.finalLevel = this._computeFinalLevel(rollData);
|
rollData.finalLevel = this._computeFinalLevel(rollData);
|
||||||
|
|
||||||
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used);
|
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used);
|
||||||
|
HtmlUtility._showControlWhen($("#divAppelAuMoral"), rollData.appelAuMoralPossible );
|
||||||
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence));
|
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence));
|
||||||
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
|
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
|
||||||
|
|
||||||
|
@ -235,6 +235,7 @@ export class RdDUtility {
|
|||||||
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html',
|
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html',
|
||||||
// messages tchat
|
// messages tchat
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html',
|
'systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html',
|
||||||
|
'systems/foundryvtt-reve-de-dragon/templates/chat-info-appel-au-moral.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html',
|
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-particuliere.html',
|
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-particuliere.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.html',
|
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.html',
|
||||||
|
@ -74,8 +74,8 @@ export const referenceAjustements = {
|
|||||||
},
|
},
|
||||||
moral: {
|
moral: {
|
||||||
isVisible: (rollData, actor) => RdDCarac.isActionPhysique(rollData.selectedCarac),
|
isVisible: (rollData, actor) => RdDCarac.isActionPhysique(rollData.selectedCarac),
|
||||||
isUsed: (rollData, actor) => rollData.use?.moral,
|
isUsed: (rollData, actor) => rollData.use?.appelAuMoral,
|
||||||
getLabel: (rollData, actor) => 'Moral',
|
getLabel: (rollData, actor) => 'Appel au moral',
|
||||||
getValue: (rollData, actor) => 1
|
getValue: (rollData, actor) => 1
|
||||||
},
|
},
|
||||||
moralTotal: {
|
moralTotal: {
|
||||||
|
@ -812,6 +812,26 @@ ul, li {
|
|||||||
left: 0px;
|
left: 0px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
.diffAppelAuMoral {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
.diffAppelAuMoral-checker {
|
||||||
|
height: 20px;
|
||||||
|
background-image: url('../icons/moral-neutre.svg');
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
.diffAppelAuMoral:checked + .diffAppelAuMoral-checker {
|
||||||
|
background-image: url('../icons/moral-heureux.svg');
|
||||||
|
}
|
||||||
|
.iconeSmile {
|
||||||
|
height: 20px;
|
||||||
|
width: 20px;
|
||||||
|
border:none;
|
||||||
|
outline: none;
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
.textSmile {
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================================== */
|
/* ======================================== */
|
||||||
/* Fatigue CSS */
|
/* Fatigue CSS */
|
||||||
@ -1392,4 +1412,4 @@ display: inline-flex;
|
|||||||
content : url(img/logo.png);
|
content : url(img/logo.png);
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 68px;
|
height: 68px;
|
||||||
}
|
}
|
||||||
|
4
templates/chat-info-appel-au-moral.html
Normal file
4
templates/chat-info-appel-au-moral.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{{#if use.appelAuMoral}}<div>
|
||||||
|
{{alias}} fait appel {{#if (gt moral 0)}}au moral{{else}}à l'énergie du déspoir{{/if}} {{#if moralDiminuer}}et échoue, diminuant son moral.{{else}} et réussit.{{/if}}
|
||||||
|
{{^jetEchouerMoralDiminuer}} Son moral reste inchangé à {{moral}}.{{/jetEchouerMoralDiminuer}}
|
||||||
|
<div>{{/if}}
|
@ -12,6 +12,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<span>{{#if rolled.ptTache}}{{rolled.ptTache}} points de tâche{{/if}}{{#if rolled.ptQualite}}{{#if rolled.ptTache}},{{/if}} ajustement Qualité {{numberFormat rolled.ptQualite decimals=0 sign=true}}{{/if}}</span>
|
<span>{{#if rolled.ptTache}}{{rolled.ptTache}} points de tâche{{/if}}{{#if rolled.ptQualite}}{{#if rolled.ptTache}},{{/if}} ajustement Qualité {{numberFormat rolled.ptQualite decimals=0 sign=true}}{{/if}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-info-appel-au-moral.html"}}
|
||||||
{{~#if show.explications}}
|
{{~#if show.explications}}
|
||||||
<div>
|
<div>
|
||||||
{{show.explications}}
|
{{show.explications}}
|
||||||
|
@ -67,6 +67,12 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
<div class="form-group" id="divAppelAuMoral" >
|
||||||
|
<input class="diffAppelAuMoral" id="useAppelAuMoralCheckbox" type="checkbox" name="appelAuMoralDemander" />
|
||||||
|
<label for="useAppelAuMoralCheckbox" class="diffAppelAuMoral-checker" id="diffAppelAuMoral-checker"></label>
|
||||||
|
<label for="useAppelAuMoralCheckbox" class="textSmile" id="textSmile" >Sans appel au moral</label>
|
||||||
|
<img for="useAppelAuMoralCheckbox" class="iconeSmile" id="iconeSmile" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg">
|
||||||
|
</div>
|
||||||
|
|
||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
|
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
|
||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html"}}
|
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html"}}
|
||||||
|
Loading…
Reference in New Issue
Block a user