Big WIP...
This commit is contained in:
@ -38,18 +38,19 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _setDefaultOptions(actor, rollData) {
|
||||
const actorData = actor.system
|
||||
let defaultRollData = {
|
||||
alias: actor.name,
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: actor.getEtatGeneral(),
|
||||
moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */
|
||||
carac: actor.system.carac,
|
||||
carac: actorData.carac,
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: rollData.competence?.system.default_diffLibre ?? 0,
|
||||
malusArmureValue: actor.getMalusArmure(),
|
||||
surencMalusFlag: actor.isPersonnage() ? (actor.system.compteurs.surenc.value < 0) : false,
|
||||
surencMalusFlag: actor.isPersonnage() ? (actorData.compteurs.surenc.value < 0) : false,
|
||||
surencMalusValue: actor.computeMalusSurEncombrement(),
|
||||
useMalusSurenc: false,
|
||||
useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */
|
||||
@ -63,7 +64,11 @@ export class RdDRoll extends Dialog {
|
||||
canClose: true,
|
||||
isGM: game.user.isGM,
|
||||
forceDiceResult: -1
|
||||
};
|
||||
}
|
||||
// Mini patch :Ajout du rêve actuel
|
||||
if ( actorData.type == "personnage") {
|
||||
defaultRollData.carac["reve-actuel"] = actorData.reve.reve
|
||||
}
|
||||
|
||||
mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false });
|
||||
if (rollData.forceCarac) {
|
||||
@ -73,7 +78,6 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
RollDataAjustements.calcul(rollData, actor);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getDiviseurSignificative(rollData) {
|
||||
let facteurSign = 1;
|
||||
@ -166,12 +170,12 @@ export class RdDRoll extends Dialog {
|
||||
if (rollData.competence) {
|
||||
const defaut_carac = rollData.competence.system.defaut_carac
|
||||
// Set the default carac from the competence item
|
||||
rollData.selectedCarac = rollData.carac[defaut_carac]
|
||||
$("#carac").val(defaut_carac)
|
||||
rollData.selectedCarac = rollData.carac[defaut_carac];
|
||||
$("#carac").val(defaut_carac);
|
||||
}
|
||||
if (rollData.selectedSort) {
|
||||
dialog.setSelectedSort(rollData.selectedSort)
|
||||
$(".draconic").val(rollData.selectedSort.data.listIndex) // Uniquement a la selection du sort, pour permettre de changer
|
||||
dialog.setSelectedSort(rollData.selectedSort);
|
||||
$(".draconic").val(rollData.selectedSort.system.listIndex); // Uniquement a la selection du sort, pour permettre de changer
|
||||
}
|
||||
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
|
||||
@ -267,47 +271,47 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
async setSelectedSort(sort) {
|
||||
this.rollData.selectedSort = sort; // Update the selectedCarac
|
||||
this.rollData.competence = RdDItemCompetence.getVoieDraconic(this.rollData.draconicList, sort.data.draconic);
|
||||
this.rollData.competence = RdDItemCompetence.getVoieDraconic(this.rollData.draconicList, sort.system.draconic);
|
||||
this.rollData.bonus = RdDItemSort.getCaseBonus(sort, this.rollData.tmr.coord);
|
||||
this.rollData.diffLibre = RdDItemSort.getDifficulte(sort, -7);
|
||||
RdDItemSort.setCoutReveReel(sort);
|
||||
const htmlSortDescription = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/partial-description-sort.html", { sort: sort });
|
||||
$(".sort-ou-rituel").text(sort.data.isrituel ? "rituel" : "sort");
|
||||
$(".sort-ou-rituel").text(sort.system.isrituel ? "rituel" : "sort");
|
||||
$(".bonus-case").text(`${this.rollData.bonus}%`);
|
||||
$(".details-sort").remove();
|
||||
$(".description-sort").append(htmlSortDescription);
|
||||
$(".roll-draconic").val(sort.data.listIndex);
|
||||
$(".div-sort-difficulte-fixe").text(Misc.toSignedString(sort.data.difficulte));
|
||||
$(".div-sort-ptreve-fixe").text(sort.data.ptreve);
|
||||
$(".roll-draconic").val(sort.system.listIndex);
|
||||
$(".div-sort-difficulte-fixe").text(Misc.toSignedString(sort.system.difficulte));
|
||||
$(".div-sort-ptreve-fixe").text(sort.system.ptreve);
|
||||
const diffVariable = RdDItemSort.isDifficulteVariable(sort);
|
||||
const coutVariable = RdDItemSort.isCoutVariable(sort);
|
||||
HtmlUtility._showControlWhen($(".div-sort-non-rituel"), !sort.data.isrituel);
|
||||
HtmlUtility._showControlWhen($(".div-sort-non-rituel"), !sort.system.isrituel);
|
||||
HtmlUtility._showControlWhen($(".div-sort-difficulte-var"), diffVariable);
|
||||
HtmlUtility._showControlWhen($(".div-sort-difficulte-fixe"), !diffVariable);
|
||||
HtmlUtility._showControlWhen($(".div-sort-ptreve-var"), coutVariable);
|
||||
HtmlUtility._showControlWhen($(".div-sort-ptreve-fixe"), !coutVariable);
|
||||
}
|
||||
|
||||
async setSelectedSigneDraconique(signe) {
|
||||
async setSelectedSigneDraconique(signe){
|
||||
this.rollData.signe = signe;
|
||||
this.rollData.diffLibre = Misc.data(signe).data.difficulte,
|
||||
$(".signe-difficulte").text(Misc.toSignedString(this.rollData.diffLibre));
|
||||
this.rollData.diffLibre = Misc.data(signe).data.difficulte,
|
||||
$(".signe-difficulte").text(Misc.toSignedString(this.rollData.diffLibre));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateRollResult() {
|
||||
let rollData = this.rollData;
|
||||
|
||||
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat());
|
||||
rollData.caracValue = parseInt(rollData.selectedCarac.value);
|
||||
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat())
|
||||
rollData.caracValue = parseInt(rollData.selectedCarac.value)
|
||||
rollData.mortalite = rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite ?? 'mortel';
|
||||
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);
|
||||
|
||||
switch (rollData.mortalite) {
|
||||
case 'non-mortel': dmgText = `(${dmgText}) non-mortel`; break;
|
||||
case 'empoignade': dmgText = `empoignade`; break;
|
||||
switch (rollData.mortalite){
|
||||
case 'non-mortel': dmgText = `(${dmgText}) non-mortel`; break;
|
||||
case 'empoignade': dmgText = `empoignade`; break;
|
||||
}
|
||||
|
||||
RollDataAjustements.calcul(rollData, this.actor);
|
||||
@ -339,7 +343,7 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeFinalLevel(rollData) {
|
||||
return RollDataAjustements.sum(rollData.ajustements)
|
||||
return RollDataAjustements.sum(rollData.ajustements);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_computeDiffCompetence(rollData) {
|
||||
@ -375,13 +379,13 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getTitle(rollData) {
|
||||
const carac = rollData.selectedCarac.label
|
||||
const carac = rollData.selectedCarac.label;
|
||||
if (!rollData.competence) {
|
||||
return carac
|
||||
return carac;
|
||||
}
|
||||
const compName = rollData.competence.name
|
||||
const compName = rollData.competence.name;
|
||||
if (rollData.draconicList && rollData.selectedSort) {
|
||||
return compName + " - " + rollData.selectedSort.name
|
||||
return compName + " - " + rollData.selectedSort.name;
|
||||
}
|
||||
// If a weapon is there, add it in the title
|
||||
const niveau = Misc.toSignedString(rollData.competence.system.niveau)
|
||||
|
Reference in New Issue
Block a user