2021-01-07 00:40:56 +01:00
|
|
|
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
2020-12-06 19:29:10 +01:00
|
|
|
import { HtmlUtility } from "./html-utility.js";
|
2020-12-20 21:54:09 +01:00
|
|
|
import { RdDItemCompetence } from "./item-competence.js";
|
2021-01-05 18:43:13 +01:00
|
|
|
import { RdDItemMeditation } from "./item-meditation.js";
|
2020-12-06 19:29:10 +01:00
|
|
|
import { RdDItemSort } from "./item-sort.js";
|
|
|
|
import { Misc } from "./misc.js";
|
2020-12-16 23:02:15 +01:00
|
|
|
import { RdDBonus } from "./rdd-bonus.js";
|
2021-01-05 18:43:13 +01:00
|
|
|
import { RdDCarac } from "./rdd-carac.js";
|
2020-12-06 19:29:10 +01:00
|
|
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extend the base Dialog entity to select roll parameters
|
|
|
|
* @extends {Dialog}
|
|
|
|
*/
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-06 19:29:10 +01:00
|
|
|
export class RdDRoll extends Dialog {
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-06 23:31:23 +01:00
|
|
|
static async create(actor, rollData, dialogConfig, ...actions) {
|
2020-12-06 19:29:10 +01:00
|
|
|
|
2021-03-16 21:49:21 +01:00
|
|
|
if (actor.isRollWindowsOpened()) {
|
2021-02-26 23:54:17 +01:00
|
|
|
ui.notifications.warn("Vous avez déja une fenêtre de Test ouverte, il faut la fermer avant d'en ouvrir une autre.")
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
actor.setRollWindowsOpened(true);
|
|
|
|
|
2020-12-06 23:31:23 +01:00
|
|
|
RdDRoll._ensureCorrectActions(actions);
|
2020-12-06 19:29:10 +01:00
|
|
|
RdDRoll._setDefaultOptions(actor, rollData);
|
|
|
|
|
2020-12-06 23:31:23 +01:00
|
|
|
const html = await renderTemplate(dialogConfig.html, rollData);
|
2020-12-06 19:29:10 +01:00
|
|
|
|
2020-12-06 23:31:23 +01:00
|
|
|
let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 };
|
|
|
|
if (dialogConfig.options) {
|
|
|
|
mergeObject(options, dialogConfig.options, { overwrite: true })
|
|
|
|
}
|
2021-01-05 18:43:13 +01:00
|
|
|
return new RdDRoll(actor, rollData, html, options, actions, dialogConfig.close);
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-06 19:29:10 +01:00
|
|
|
static _setDefaultOptions(actor, rollData) {
|
2021-03-22 20:10:37 +01:00
|
|
|
const actorData = Misc.data(actor);
|
2020-12-15 08:37:52 +01:00
|
|
|
let defaultRollData = {
|
2021-01-02 04:28:43 +01:00
|
|
|
alias: actor.name,
|
2020-12-15 08:37:52 +01:00
|
|
|
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
|
|
|
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
2021-01-05 18:43:13 +01:00
|
|
|
etat: actor.getEtatGeneral(),
|
2021-02-09 23:23:40 +01:00
|
|
|
moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */
|
2021-03-22 20:10:37 +01:00
|
|
|
carac: actorData.data.carac,
|
2020-12-15 08:37:52 +01:00
|
|
|
finalLevel: 0,
|
2021-01-13 03:42:13 +01:00
|
|
|
diffConditions: 0,
|
2021-01-04 14:06:35 +01:00
|
|
|
diffLibre: rollData.competence?.data.default_diffLibre ?? 0,
|
2021-01-05 18:43:13 +01:00
|
|
|
malusArmureValue: actor.getMalusArmure(),
|
2021-03-22 20:10:37 +01:00
|
|
|
surencMalusFlag: actor.isPersonnage() ? (actorData.data.compteurs.surenc.value < 0) : false,
|
2021-01-05 18:43:13 +01:00
|
|
|
surencMalusValue: actor.getSurenc(),
|
2021-01-05 18:39:12 +01:00
|
|
|
useMalusSurenc: false,
|
2021-03-16 21:49:21 +01:00
|
|
|
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 },
|
2020-12-20 21:54:09 +01:00
|
|
|
isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
|
|
|
|
useMalusEncTotal: false,
|
2021-01-05 18:39:12 +01:00
|
|
|
encTotal: actor.getEncTotal(),
|
2021-01-02 14:10:43 +01:00
|
|
|
ajustementAstrologique: actor.ajustementAstrologique(),
|
2021-01-13 03:42:13 +01:00
|
|
|
surprise: actor.getSurprise(false),
|
2021-02-06 02:29:58 +01:00
|
|
|
canClose: true
|
2021-03-16 21:49:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-01-05 18:43:13 +01:00
|
|
|
mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false });
|
2021-02-06 02:29:58 +01:00
|
|
|
if (rollData.forceCarac) {
|
2021-01-27 23:35:45 +01:00
|
|
|
rollData.carac = rollData.forceCarac;
|
|
|
|
}
|
2021-01-05 18:43:13 +01:00
|
|
|
RollDataAjustements.calcul(rollData, actor);
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-06 19:29:10 +01:00
|
|
|
static _ensureCorrectActions(actions) {
|
2020-12-06 23:31:23 +01:00
|
|
|
if (actions.length == 0) {
|
2020-12-06 19:29:10 +01:00
|
|
|
throw 'No action defined';
|
|
|
|
}
|
|
|
|
actions.forEach(action => {
|
|
|
|
if (action.callbacks == undefined) {
|
2020-12-06 23:31:23 +01:00
|
|
|
action.callbacks = [{ action: r => console.log(action.name, r) }];
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-28 10:17:40 +01:00
|
|
|
constructor(actor, rollData, html, options, actions, close = undefined) {
|
2020-12-06 19:29:10 +01:00
|
|
|
let conf = {
|
|
|
|
title: actions[0].label,
|
|
|
|
content: html,
|
|
|
|
buttons: {},
|
2020-12-28 10:17:40 +01:00
|
|
|
default: actions[0].name,
|
|
|
|
close: close
|
2020-12-06 19:29:10 +01:00
|
|
|
};
|
|
|
|
for (let action of actions) {
|
2021-02-06 02:29:58 +01:00
|
|
|
conf.buttons[action.name] = {
|
|
|
|
label: action.label, callback: html => {
|
|
|
|
this.rollData.canClose = true;
|
|
|
|
this.onAction(action, html)
|
|
|
|
}
|
|
|
|
};
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
super(conf, options);
|
|
|
|
|
|
|
|
this.actor = actor;
|
|
|
|
this.rollData = rollData;
|
|
|
|
}
|
|
|
|
|
2021-02-06 02:29:58 +01:00
|
|
|
close() {
|
|
|
|
if (this.rollData.canClose) {
|
2021-02-26 23:54:17 +01:00
|
|
|
this.actor.setRollWindowsOpened(false);
|
2021-02-06 02:29:58 +01:00
|
|
|
return super.close();
|
|
|
|
}
|
|
|
|
ui.notifications.info("Vous devez faire ce jet de dés!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 23:02:15 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-06 19:29:10 +01:00
|
|
|
async onAction(action, html) {
|
|
|
|
await RdDResolutionTable.rollData(this.rollData);
|
2020-12-08 23:07:41 +01:00
|
|
|
console.log("RdDRoll -=>", this.rollData, this.rollData.rolled);
|
2021-02-26 23:54:17 +01:00
|
|
|
this.actor.setRollWindowsOpened(false);
|
2021-03-16 21:49:21 +01:00
|
|
|
|
2020-12-06 19:29:10 +01:00
|
|
|
if (action.callbacks)
|
2020-12-06 23:31:23 +01:00
|
|
|
for (let callback of action.callbacks) {
|
|
|
|
if (callback.condition == undefined || callback.condition(this.rollData)) {
|
2021-03-18 00:41:26 +01:00
|
|
|
await callback.action(this.rollData);
|
2020-12-06 23:31:23 +01:00
|
|
|
}
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
this.bringToTop();
|
|
|
|
|
2020-12-18 23:57:28 +01:00
|
|
|
var dialog = this;
|
2021-02-06 02:29:58 +01:00
|
|
|
|
2021-01-05 18:43:13 +01:00
|
|
|
function onLoad() {
|
|
|
|
let rollData = dialog.rollData;
|
2021-03-25 18:33:10 +01:00
|
|
|
console.log(rollData);
|
2020-12-06 19:29:10 +01:00
|
|
|
// Update html, according to data
|
|
|
|
if (rollData.competence) {
|
2021-03-28 22:37:04 +02:00
|
|
|
let compData = rollData.competence.data.data || rollData.competence.data;
|
2020-12-06 19:29:10 +01:00
|
|
|
// Set the default carac from the competence item
|
2021-03-28 22:37:04 +02:00
|
|
|
rollData.selectedCarac = rollData.carac[compData.defaut_carac];
|
|
|
|
$("#carac").val(compData.defaut_carac);
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
2021-02-02 07:56:45 +01:00
|
|
|
if (rollData.selectedSort) {
|
2021-02-06 02:29:58 +01:00
|
|
|
$("#draconic").val(rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer
|
2021-02-02 07:56:45 +01:00
|
|
|
}
|
2020-12-06 19:29:10 +01:00
|
|
|
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
|
|
|
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
|
|
|
|
$("#diffConditions").val(Misc.toInt(rollData.diffConditions));
|
2021-01-05 18:43:13 +01:00
|
|
|
dialog.updateRollResult();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup everything onload
|
|
|
|
$(function () { onLoad(); });
|
2020-12-06 19:29:10 +01:00
|
|
|
|
|
|
|
// Update !
|
|
|
|
html.find('#diffLibre').change((event) => {
|
2021-01-05 18:43:13 +01:00
|
|
|
this.rollData.diffLibre = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
html.find('#diffConditions').change((event) => {
|
2021-01-05 18:43:13 +01:00
|
|
|
this.rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
html.find('#carac').change((event) => {
|
|
|
|
let caracKey = event.currentTarget.value;
|
2021-01-05 18:43:13 +01:00
|
|
|
this.rollData.selectedCarac = this.rollData.carac[caracKey]; // Update the selectedCarac
|
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
html.find('#draconic').change((event) => {
|
|
|
|
let draconicKey = Misc.toInt(event.currentTarget.value);
|
2021-01-05 18:43:13 +01:00
|
|
|
this.rollData.competence = this.rollData.draconicList[draconicKey]; // Update the selectedCarac
|
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
html.find('#sort').change((event) => {
|
|
|
|
let sortKey = Misc.toInt(event.currentTarget.value);
|
2021-01-05 18:43:13 +01:00
|
|
|
this.rollData.selectedSort = this.rollData.sortList[sortKey]; // Update the selectedCarac
|
2021-02-06 02:29:58 +01:00
|
|
|
this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.tmr.coord);
|
2021-01-05 18:43:13 +01:00
|
|
|
RdDItemSort.setCoutReveReel(this.rollData.selectedSort);
|
2021-02-06 02:29:58 +01:00
|
|
|
$("#draconic").val(this.rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer
|
2021-01-05 18:43:13 +01:00
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
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);
|
2021-01-05 18:43:13 +01:00
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
|
|
|
html.find('#coupsNonMortels').change((event) => {
|
2020-12-16 23:02:15 +01:00
|
|
|
this.rollData.dmg.mortalite = event.currentTarget.checked ? "non-mortel" : "mortel";
|
2021-01-05 18:43:13 +01:00
|
|
|
this.updateRollResult();
|
2020-12-12 21:58:44 +01:00
|
|
|
});
|
2020-12-16 23:02:15 +01:00
|
|
|
html.find('#tactique-combat').change((event) => {
|
|
|
|
this.rollData.tactique = event.currentTarget.value;
|
2021-01-05 18:43:13 +01:00
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
2021-01-05 18:39:12 +01:00
|
|
|
html.find('#useMalusSurenc').change((event) => {
|
|
|
|
this.rollData.useMalusSurenc = event.currentTarget.checked;
|
2021-01-05 18:43:13 +01:00
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
2020-12-20 21:54:09 +01:00
|
|
|
html.find('#useMalusEncTotal').change((event) => {
|
|
|
|
this.rollData.useMalusEncTotal = event.currentTarget.checked;
|
2021-01-05 18:43:13 +01:00
|
|
|
this.updateRollResult();
|
2020-12-06 19:29:10 +01:00
|
|
|
});
|
2021-03-16 21:49:21 +01:00
|
|
|
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";
|
|
|
|
}
|
2021-02-09 23:23:40 +01:00
|
|
|
this.updateRollResult();
|
2021-03-16 21:49:21 +01:00
|
|
|
});
|
2021-01-04 22:03:00 +01:00
|
|
|
// Section Méditation
|
2021-01-05 18:43:13 +01:00
|
|
|
html.find('.conditionMeditation').change((event) => {
|
|
|
|
let condition = event.currentTarget.attributes['id'].value;
|
|
|
|
this.rollData.conditionMeditation[condition] = event.currentTarget.checked;
|
|
|
|
this.updateRollResult();
|
2021-01-04 22:03:00 +01:00
|
|
|
});
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
|
2021-01-29 20:10:43 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-01-05 18:43:13 +01:00
|
|
|
async updateRollResult() {
|
|
|
|
let rollData = this.rollData;
|
2021-03-16 21:49:21 +01:00
|
|
|
|
2021-01-05 18:43:13 +01:00
|
|
|
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';
|
2021-03-16 21:49:21 +01:00
|
|
|
rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac);
|
2021-01-05 18:43:13 +01:00
|
|
|
let dmgText = Misc.toSignedString(rollData.dmg.total);
|
|
|
|
|
|
|
|
if (rollData.coupsNonMortels) {
|
|
|
|
dmgText = '(' + dmgText + ')';
|
2021-01-04 22:03:00 +01:00
|
|
|
}
|
2021-01-05 18:43:13 +01:00
|
|
|
if (rollData.selectedSort) {
|
2021-02-06 02:29:58 +01:00
|
|
|
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.tmr.coord);
|
|
|
|
HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort))
|
|
|
|
HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(rollData.selectedSort))
|
2021-01-05 18:43:13 +01:00
|
|
|
}
|
2021-02-09 23:23:40 +01:00
|
|
|
|
2021-01-05 18:43:13 +01:00
|
|
|
RollDataAjustements.calcul(rollData, this.actor);
|
|
|
|
rollData.finalLevel = this._computeFinalLevel(rollData);
|
2021-02-06 02:29:58 +01:00
|
|
|
|
2021-01-05 18:43:13 +01:00
|
|
|
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used);
|
2021-03-16 21:49:21 +01:00
|
|
|
HtmlUtility._showControlWhen($(".divAppelAuMoral"), rollData.use.appelAuMoral);
|
2021-01-13 17:30:44 +01:00
|
|
|
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence));
|
2021-01-05 18:43:13 +01:00
|
|
|
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
|
|
|
|
|
|
|
|
// Mise à jour valeurs
|
|
|
|
$("#compdialogTitle").text(this._getTitle(rollData));
|
|
|
|
$('#coupsNonMortels').prop('checked', rollData.coupsNonMortels);
|
|
|
|
$("#dmg-arme-actor").text(dmgText);
|
|
|
|
$('.table-ajustement').remove();
|
|
|
|
$(".table-resolution").remove();
|
|
|
|
$(".table-proba-reussite").remove();
|
|
|
|
$("#tableAjustements").append(await this.buildAjustements(rollData));
|
|
|
|
$("#tableResolution").append(RdDResolutionTable.buildHTMLTableExtract(rollData.caracValue, rollData.finalLevel));
|
|
|
|
$("#tableProbaReussite").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-29 20:10:43 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-02-06 02:29:58 +01:00
|
|
|
async buildAjustements(rollData) {
|
2021-01-05 18:43:13 +01:00
|
|
|
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData);
|
|
|
|
return html;
|
2021-01-04 22:03:00 +01:00
|
|
|
}
|
|
|
|
|
2020-12-06 19:29:10 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-18 23:57:28 +01:00
|
|
|
_computeFinalLevel(rollData) {
|
2021-01-13 03:11:03 +01:00
|
|
|
return RollDataAjustements.sum(rollData.ajustements);
|
2020-12-16 23:02:15 +01:00
|
|
|
}
|
2021-01-04 22:03:00 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-18 23:57:28 +01:00
|
|
|
_computeDiffCompetence(rollData) {
|
2020-12-16 23:02:15 +01:00
|
|
|
if (rollData.competence) {
|
|
|
|
return Misc.toInt(rollData.competence.data.niveau);
|
|
|
|
}
|
|
|
|
if (rollData.draconicList) {
|
2020-12-31 02:20:52 +01:00
|
|
|
return Misc.toInt(rollData.competence.data.niveau);
|
2020-12-16 23:02:15 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-01-04 22:03:00 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-18 23:57:28 +01:00
|
|
|
_computeDiffLibre(rollData) {
|
2020-12-16 23:02:15 +01:00
|
|
|
let diffLibre = Misc.toInt(rollData.diffLibre);
|
|
|
|
if (rollData.draconicList && rollData.selectedSort) {
|
|
|
|
return RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
|
|
|
|
}
|
|
|
|
return diffLibre;
|
|
|
|
}
|
|
|
|
|
2021-01-29 20:10:43 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-12-18 23:57:28 +01:00
|
|
|
_computeMalusArmure(rollData) {
|
2020-12-06 19:29:10 +01:00
|
|
|
let malusArmureValue = 0;
|
2021-01-05 18:43:13 +01:00
|
|
|
if (rollData.malusArmureValue && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) {
|
2020-12-06 19:29:10 +01:00
|
|
|
$("#addon-message").text("Malus armure appliqué : " + rollData.malusArmureValue);
|
|
|
|
malusArmureValue = rollData.malusArmureValue;
|
|
|
|
} else {
|
|
|
|
$("#addon-message").text("");
|
|
|
|
}
|
2020-12-16 23:02:15 +01:00
|
|
|
return malusArmureValue;
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2020-12-18 23:57:28 +01:00
|
|
|
_getTitle(rollData) {
|
2021-01-14 00:50:12 +01:00
|
|
|
const carac = rollData.selectedCarac.label;
|
|
|
|
if (!rollData.competence) {
|
|
|
|
return carac;
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
2021-01-14 00:50:12 +01:00
|
|
|
const compName = rollData.competence.name;
|
|
|
|
if (rollData.draconicList && rollData.selectedSort) {
|
|
|
|
return compName + " - " + rollData.selectedSort.name;
|
|
|
|
}
|
|
|
|
// If a weapon is there, add it in the title
|
|
|
|
const niveau = Misc.toSignedString(rollData.competence.data.niveau);
|
|
|
|
if (compName == carac) {
|
|
|
|
// cas des créatures
|
|
|
|
return carac + " " + niveau
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
2021-01-14 00:50:12 +01:00
|
|
|
const armeTitle = (rollData.arme) ? " (" + rollData.arme.name + ") " : "";
|
|
|
|
return carac + "/" + compName + armeTitle + " " + niveau
|
2020-12-06 19:29:10 +01:00
|
|
|
}
|
|
|
|
}
|