#46 lancer de sort
Fix regressions: - renommage updatePointsDeReve pas fait partout - coût de rêve des sort fixes introduction de RdDItemSort pour grouper les fonctions liées aux sorts (et tester les sorts variables partout pareil)
This commit is contained in:
parent
dca4e28044
commit
759626ebbe
@ -336,11 +336,11 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#ptreve-actuel-plus').click((event) => {
|
||||
this.actor.updatePointsDeReve(1);
|
||||
this.actor.reveActuelIncDec(1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#ptreve-actuel-moins').click((event) => {
|
||||
this.actor.updatePointsDeReve(-1);
|
||||
this.actor.reveActuelIncDec(-1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#fatigue-plus').click((event) => {
|
||||
|
@ -220,7 +220,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
// Sort management
|
||||
if (rollData.selectedSort) { // Lancement de sort !
|
||||
resumeCompetence = rollData.selectedDraconic.name + "/" + sort.name;
|
||||
resumeCompetence = rollData.selectedDraconic.name + "/" + rollData.selectedSort.name;
|
||||
explications = await this._rollLancementDeSort(rollData, rolled);
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ export class RdDActor extends Actor {
|
||||
let sort = duplicate(rollData.selectedSort);
|
||||
|
||||
let closeTMR = true;
|
||||
let coutReve = sort.data.ptreve_reel || sort.data.ptreve; // cas de sort à ptreve variables
|
||||
let coutReve = sort.data.ptreve_reel; // toujours positionné par cas de sort à ptreve variables
|
||||
|
||||
let explications = "<br>Lancement du sort <strong>" + sort.name + "</strong> : " + Misc.upperFirst(sort.data.draconic)
|
||||
+ " pour " + coutReve + " points de Rêve"
|
||||
|
25
module/item-sort.js
Normal file
25
module/item-sort.js
Normal file
@ -0,0 +1,25 @@
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
export class RdDItemSort extends Item {
|
||||
|
||||
static isDifficulteVariable(sort) {
|
||||
return sort && (sort.data.difficulte.toLowerCase() == "variable");
|
||||
}
|
||||
static isCoutVariable(sort) {
|
||||
return sort && (sort.data.ptreve.toLowerCase() == "variable" || sort.data.ptreve.indexOf("+") >= 0);
|
||||
}
|
||||
|
||||
static setCoutReveReel(sort){
|
||||
if (sort) {
|
||||
sort.data.ptreve_reel = this.isCoutVariable(sort) ? 1 : sort.data.ptreve;
|
||||
}
|
||||
}
|
||||
|
||||
static getDifficulte(sort, variable) {
|
||||
if (sort && !RdDItemSort.isDifficulteVariable(sort)) {
|
||||
return Misc.toInt(sort.data.difficulte);
|
||||
}
|
||||
return variable;
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import { RdDItemSort } from "./item-sort.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
|
||||
@ -72,12 +73,12 @@ export class RdDRollDialog extends Dialog {
|
||||
// Sort management
|
||||
if ( rollData.selectedSort ) {
|
||||
//console.log("Toggle show/hide", rollData.selectedSort);
|
||||
if (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") {
|
||||
if (RdDItemSort.isDifficulteVariable(rollData.selectedSort)) {
|
||||
$("#div-sort-difficulte").show();
|
||||
} else {
|
||||
$("#div-sort-difficulte").hide();
|
||||
}
|
||||
if (rollData.selectedSort.data.ptreve.toLowerCase() == "variable" || rollData.selectedSort.data.ptreve.indexOf("+")>=0) {
|
||||
if (RdDItemSort.isCoutVariable(rollData.selectedSort)) {
|
||||
$("#div-sort-ptreve").show();
|
||||
} else {
|
||||
$("#div-sort-ptreve").hide();
|
||||
@ -88,6 +89,7 @@ export class RdDRollDialog extends Dialog {
|
||||
$("#compdialogTitle").text(RdDRollDialog._getTitle(rollData));
|
||||
$(".table-resolution").remove();
|
||||
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel));
|
||||
|
||||
}
|
||||
|
||||
// Setup everything onload
|
||||
@ -99,9 +101,7 @@ export class RdDRollDialog extends Dialog {
|
||||
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
|
||||
$("#carac").val(rollData.competence.data.defaut_carac);
|
||||
}
|
||||
// Si sort, for les points de reve à 1
|
||||
if (rollData.selectedSort && !rollData.selectedSort.data.ptreve_reel)
|
||||
rollData.selectedSort.data.ptreve_reel = 1;
|
||||
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
|
||||
$("#diffConditions").val(Misc.toInt(rollData.diffConditions));
|
||||
updateRollResult(rollData);
|
||||
@ -133,12 +133,13 @@ export class RdDRollDialog extends Dialog {
|
||||
html.find('#sort').change((event) => {
|
||||
let sortKey = Misc.toInt(event.currentTarget.value);
|
||||
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
|
||||
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||
//console.log("RdDRollDialog - Sort selection", rollData.selectedSort);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#ptreve-variable').change((event) => {
|
||||
let ptreve = Misc.toInt(event.currentTarget.value);
|
||||
this.rollData.selectedSort.data.ptreve_reel = ptreve; // Update the selectedCarac
|
||||
this.rollData.selectedSort.data.ptreve_reel = ptreve;
|
||||
console.log("RdDRollDialog - Cout reve", ptreve);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
@ -149,17 +150,18 @@ export class RdDRollDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _computeFinalLevel(rollData) {
|
||||
let etat = Misc.toInt(rollData.etat);
|
||||
const diffLibre = Misc.toInt(rollData.diffLibre);
|
||||
const etat = Misc.toInt(rollData.etat);
|
||||
const diffConditions = Misc.toInt(rollData.diffConditions);
|
||||
let diffLibre = Misc.toInt(rollData.diffLibre);
|
||||
let diffCompetence = 0;
|
||||
if (rollData.competence) {
|
||||
return etat + Misc.toInt(rollData.competence.data.niveau) + diffLibre + diffConditions;
|
||||
diffCompetence = Misc.toInt(rollData.competence.data.niveau);
|
||||
}
|
||||
if (rollData.draconicList) {
|
||||
let diffSort = (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") ? diffLibre : Misc.toInt(rollData.selectedSort.data.difficulte);
|
||||
return etat + Misc.toInt(rollData.selectedDraconic.data.niveau) + diffSort + diffConditions;
|
||||
else if (rollData.draconicList) {
|
||||
diffCompetence = Misc.toInt(rollData.selectedDraconic.data.niveau);
|
||||
diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
|
||||
}
|
||||
return etat + diffLibre + diffConditions;
|
||||
return etat + diffCompetence + diffLibre + diffConditions;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -124,7 +124,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
/* -------------------------------------------- */
|
||||
async gererTourbillon( value ) {
|
||||
this.nbFatigue += value;
|
||||
await this.actor.updatePointsDeReve( -value );
|
||||
await this.actor.reveActuelIncDec( -value );
|
||||
if ( !this.currentRencontre.tourbillonDirection ) {
|
||||
this.currentRencontre.tourbillonDirection = TMRUtility.getDirectionPattern();
|
||||
}
|
||||
@ -512,7 +512,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
if (this.viewOnly) {
|
||||
return;
|
||||
}
|
||||
await this.actor.updatePointsDeReve((this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue
|
||||
await this.actor.reveActuelIncDec((this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue
|
||||
this.updateValuesDisplay();
|
||||
let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord);
|
||||
await this.manageRencontre(this.actor.data.data.reve.tmrpos.coord, cellDescr);
|
||||
|
@ -429,7 +429,7 @@ export class TMRUtility {
|
||||
state = "passeur";
|
||||
|
||||
} else if (rencontre.name == "Fleur des Rêves") {
|
||||
await actor.updatePointsDeReve( rencontre.force );
|
||||
await actor.reveActuelIncDec( rencontre.force );
|
||||
msg += "La Fleur des rêves s'évanouit en vous fournissant " + rencontre.force + " Points de Rêve";
|
||||
|
||||
} else if (rencontre.name == "Mangeur de Rêve") {
|
||||
@ -474,7 +474,7 @@ export class TMRUtility {
|
||||
msg += "La Fleur des rêves s'éloigne de vous et se perd dans les Terres Médianes";
|
||||
|
||||
} else if (rencontre.name == "Mangeur de Rêve") {
|
||||
await actor.updatePointsDeReve( -rencontre.force );
|
||||
await actor.reveActuelIncDec( -rencontre.force );
|
||||
msg += "Ce Mangeur des Rêves croque votre Rêve ! Vous perdez " + rencontre.force + " points de rêve actuels, votre nouveau total est de " + actor.data.data.reve.reve.value;
|
||||
|
||||
} else if (rencontre.name == "Changeur de Rêve") {
|
||||
|
Loading…
Reference in New Issue
Block a user