forked from public/foundryvtt-reve-de-dragon
Liste des ajustements
Après le travail sur les ChatMessage, centraliser les difficultés pour les dialog-roll afin d'afficher tous les ajustements sous forme de tooltips Les ajustements à améliorer: * malus armure * sur-encombrement * encombrement total + fix regression tâches + fix méditation isisPuritication
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
import { referenceAjustements, RollDataAjustements } from "./rolldata-ajustements.js";
|
||||
import { HtmlUtility } from "./html-utility.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDItemMeditation } from "./item-meditation.js";
|
||||
import { RdDItemSort } from "./item-sort.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDBonus } from "./rdd-bonus.js";
|
||||
import { RdDCarac } from "./rdd-carac.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
|
||||
/**
|
||||
@ -24,18 +27,17 @@ export class RdDRoll extends Dialog {
|
||||
if (dialogConfig.options) {
|
||||
mergeObject(options, dialogConfig.options, { overwrite: true })
|
||||
}
|
||||
return new RdDRoll(actor, rollData, html, options, actions, dialogConfig.close );
|
||||
return new RdDRoll(actor, rollData, html, options, actions, dialogConfig.close);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _setDefaultOptions(actor, rollData) {
|
||||
|
||||
let defaultRollData = {
|
||||
alias: actor.name,
|
||||
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,
|
||||
etat: actor.getEtatGeneral(),
|
||||
moral: actor.getMoralTotal(),
|
||||
carac: actor.data.data.carac,
|
||||
finalLevel: 0,
|
||||
diffConditions: rollData.arme ? RdDBonus.bonusAttaque(rollData.surpriseDefenseur) : 0,
|
||||
@ -43,17 +45,22 @@ export class RdDRoll extends Dialog {
|
||||
editLibre: true,
|
||||
editConditions: true,
|
||||
forceValue: actor.getForceValue(),
|
||||
malusArmureValue: actor.isPersonnage() ? actor.data.data.attributs?.malusarmure?.value ?? 0 : 0,
|
||||
malusArmureValue: actor.getMalusArmure(),
|
||||
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
|
||||
surencMalusValue: actor.isPersonnage() ? actor.data.data.compteurs.surenc.value : 0,
|
||||
surencMalusValue: actor.getSurenc(),
|
||||
useMalusSurenc: false,
|
||||
use: {
|
||||
surenc: false,
|
||||
encTotal: false,
|
||||
},
|
||||
isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
|
||||
useMalusEncTotal: false,
|
||||
encTotal: actor.getEncTotal(),
|
||||
ajustementAstrologique: actor.ajustementAstrologique(),
|
||||
surprise: actor.getSurprise()
|
||||
surprise: actor.getSurprise(),
|
||||
}
|
||||
mergeObject(rollData, defaultRollData, { overwrite: false });
|
||||
mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false });
|
||||
RollDataAjustements.calcul(rollData, actor);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -106,47 +113,10 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
this.bringToTop();
|
||||
|
||||
var rollData = this.rollData;
|
||||
var actor = this.actor;
|
||||
var dialog = this;
|
||||
|
||||
function updateRollResult(rollData) {
|
||||
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, actor.getBonusDegat());
|
||||
rollData.finalLevel = dialog._computeFinalLevel(rollData);
|
||||
rollData.caracValue = parseInt(rollData.selectedCarac.value);
|
||||
rollData.coupsNonMortels = (rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite) == 'non-mortel';
|
||||
let dmgText = Misc.toSignedString(rollData.dmg.total);
|
||||
if (rollData.coupsNonMortels) {
|
||||
dmgText = '(' + dmgText + ')';
|
||||
}
|
||||
|
||||
HtmlUtility._showControlWhen($(".diffMoral"), rollData.selectedCarac == actor.data.data.carac.volonte);
|
||||
|
||||
HtmlUtility._showControlWhen($("#etat-general"), !dialog._isIgnoreEtatGeneral(rollData));
|
||||
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
|
||||
|
||||
// Sort management
|
||||
if (rollData.selectedSort) {
|
||||
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord);
|
||||
//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(dialog._getTitle(rollData));
|
||||
$('#coupsNonMortels').prop('checked', rollData.coupsNonMortels);
|
||||
$("#dmg-arme-actor").text(dmgText);
|
||||
$("#defenseur-surprise").text(RdDBonus.description(rollData.surpriseDefenseur));
|
||||
$(".table-resolution").remove();
|
||||
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(rollData.caracValue, rollData.finalLevel));
|
||||
$(".span-valeur").remove();
|
||||
$("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel));
|
||||
}
|
||||
|
||||
// Setup everything onload
|
||||
$(function () {
|
||||
|
||||
function onLoad() {
|
||||
let rollData = dialog.rollData;
|
||||
// Update html, according to data
|
||||
if (rollData.competence) {
|
||||
// Set the default carac from the competence item
|
||||
@ -156,109 +126,126 @@ export class RdDRoll extends Dialog {
|
||||
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
|
||||
$("#diffConditions").val(Misc.toInt(rollData.diffConditions));
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
dialog.updateRollResult();
|
||||
}
|
||||
|
||||
// Setup everything onload
|
||||
$(function () { onLoad(); });
|
||||
|
||||
// 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);
|
||||
this.rollData.diffLibre = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
||||
this.updateRollResult();
|
||||
});
|
||||
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);
|
||||
this.rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
||||
this.updateRollResult();
|
||||
});
|
||||
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);
|
||||
this.rollData.selectedCarac = this.rollData.carac[caracKey]; // Update the selectedCarac
|
||||
this.updateRollResult();
|
||||
});
|
||||
html.find('#draconic').change((event) => {
|
||||
let draconicKey = Misc.toInt(event.currentTarget.value);
|
||||
this.rollData.competence = rollData.draconicList[draconicKey]; // Update the selectedCarac
|
||||
//console.log("RdDRollSelectDialog","CARAC CLICKED !!!", rollData);
|
||||
updateRollResult(rollData);
|
||||
this.rollData.competence = this.rollData.draconicList[draconicKey]; // Update the selectedCarac
|
||||
this.updateRollResult();
|
||||
});
|
||||
html.find('#sort').change((event) => {
|
||||
let sortKey = Misc.toInt(event.currentTarget.value);
|
||||
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
|
||||
this.rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord);
|
||||
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||
//console.log("RdDRollSelectDialog - Sort selection", rollData.selectedSort);
|
||||
updateRollResult(rollData);
|
||||
this.rollData.selectedSort = this.rollData.sortList[sortKey]; // Update the selectedCarac
|
||||
this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.coord);
|
||||
RdDItemSort.setCoutReveReel(this.rollData.selectedSort);
|
||||
this.updateRollResult();
|
||||
});
|
||||
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);
|
||||
this.updateRollResult();
|
||||
});
|
||||
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);
|
||||
this.updateRollResult();
|
||||
});
|
||||
html.find('#coupsNonMortels').change((event) => {
|
||||
this.rollData.dmg.mortalite = event.currentTarget.checked ? "non-mortel" : "mortel";
|
||||
updateRollResult(rollData);
|
||||
this.updateRollResult();
|
||||
});
|
||||
html.find('#tactique-combat').change((event) => {
|
||||
this.rollData.tactique = event.currentTarget.value;
|
||||
updateRollResult(rollData);
|
||||
this.updateRollResult();
|
||||
});
|
||||
html.find('#useMalusSurenc').change((event) => {
|
||||
this.rollData.useMalusSurenc = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
this.updateRollResult();
|
||||
});
|
||||
html.find('#useMalusEncTotal').change((event) => {
|
||||
this.rollData.useMalusEncTotal = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
this.updateRollResult();
|
||||
});
|
||||
// Section Méditation
|
||||
html.find('#isHeure').change((event) => {
|
||||
this.rollData.isHeure = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
html.find('.conditionMeditation').change((event) => {
|
||||
let condition = event.currentTarget.attributes['id'].value;
|
||||
this.rollData.conditionMeditation[condition] = event.currentTarget.checked;
|
||||
this.updateRollResult();
|
||||
});
|
||||
html.find('#isPurification').change((event) => {
|
||||
this.rollData.isPurification = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#isVeture').change((event) => {
|
||||
this.rollData.isVeture = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#isComportement').change((event) => {
|
||||
this.rollData.isComportement = event.currentTarget.checked;
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_isIgnoreEtatGeneral(rollData) {
|
||||
return rollData.selectedCarac.ignoreEtatGeneral;
|
||||
}
|
||||
async updateRollResult() {
|
||||
let rollData = this.rollData;
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeDiffMeditation( rollData ) {
|
||||
let diff = 0;
|
||||
if ( rollData.meditation ) {
|
||||
diff = (!rollData.isHeure) ? diff - 2 : diff;
|
||||
diff = (!rollData.isVeture) ? diff - 2 : diff;
|
||||
diff = (!rollData.isComportement) ? diff - 2 : diff;
|
||||
diff = (!rollData.isisPuritication) ? diff - 2 : diff;
|
||||
diff = diff - rollData.meditation.data.malus; // Malus permanent éventuel
|
||||
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';
|
||||
let dmgText = Misc.toSignedString(rollData.dmg.total);
|
||||
|
||||
if (rollData.coupsNonMortels) {
|
||||
dmgText = '(' + dmgText + ')';
|
||||
}
|
||||
return diff;
|
||||
if (rollData.selectedSort) {
|
||||
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord);
|
||||
}
|
||||
|
||||
RollDataAjustements.calcul(rollData, this.actor);
|
||||
rollData.finalLevel = this._computeFinalLevel(rollData);
|
||||
|
||||
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used);
|
||||
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac));
|
||||
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData));
|
||||
|
||||
// Sort management
|
||||
if (rollData.selectedSort) {
|
||||
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord);
|
||||
//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
|
||||
$("#compdialogTitle").text(this._getTitle(rollData));
|
||||
$('#coupsNonMortels').prop('checked', rollData.coupsNonMortels);
|
||||
$("#dmg-arme-actor").text(dmgText);
|
||||
$("#defenseur-surprise").text(RdDBonus.description(rollData.surpriseDefenseur));
|
||||
$('.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));
|
||||
}
|
||||
|
||||
|
||||
async buildAjustements(rollData){
|
||||
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData);
|
||||
return html;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeFinalLevel(rollData) {
|
||||
const etat = this._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
|
||||
const etat = RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac) ? 0 : rollData.etat;
|
||||
const diffConditions = Misc.toInt(rollData.diffConditions);
|
||||
const malusSurenc = (rollData.useMalusSurenc) ? rollData.surencMalusValue : 0;
|
||||
const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique);
|
||||
@ -267,12 +254,14 @@ export class RdDRoll extends Dialog {
|
||||
// Gestion malus armure
|
||||
const malusArmureValue = this._computeMalusArmure(rollData);
|
||||
|
||||
const diffMeditation = this._computeDiffMeditation( rollData );
|
||||
const diffMeditation = RdDItemMeditation.calculDifficulte(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 + diffMoral + diffConditions + malusSurenc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique;
|
||||
let ajust = RollDataAjustements.sum(rollData.ajustements);
|
||||
return ajust;
|
||||
//return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusSurenc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -297,7 +286,7 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
_computeMalusArmure(rollData) {
|
||||
let malusArmureValue = 0;
|
||||
if (rollData.malusArmureValue != 0 && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) {
|
||||
if (rollData.malusArmureValue && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) {
|
||||
$("#addon-message").text("Malus armure appliqué : " + rollData.malusArmureValue);
|
||||
malusArmureValue = rollData.malusArmureValue;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user