Merge branch 'fix-46' into 'master'

Fix #46: lancement de sorts

Closes #46

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!41
This commit is contained in:
Leratier Bretonnien 2020-11-27 11:19:46 +00:00
commit f177ed7968
9 changed files with 64 additions and 34 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 51 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 31 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -336,11 +336,11 @@ export class RdDActorSheet extends ActorSheet {
this.render(true); this.render(true);
}); });
html.find('#ptreve-actuel-plus').click((event) => { html.find('#ptreve-actuel-plus').click((event) => {
this.actor.updatePointsDeReve(1); this.actor.reveActuelIncDec(1);
this.render(true); this.render(true);
}); });
html.find('#ptreve-actuel-moins').click((event) => { html.find('#ptreve-actuel-moins').click((event) => {
this.actor.updatePointsDeReve(-1); this.actor.reveActuelIncDec(-1);
this.render(true); this.render(true);
}); });
html.find('#fatigue-plus').click((event) => { html.find('#fatigue-plus').click((event) => {

View File

@ -220,7 +220,7 @@ export class RdDActor extends Actor {
// Sort management // Sort management
if (rollData.selectedSort) { // Lancement de sort ! 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); explications = await this._rollLancementDeSort(rollData, rolled);
} }
@ -284,10 +284,10 @@ export class RdDActor extends Actor {
let sort = duplicate(rollData.selectedSort); let sort = duplicate(rollData.selectedSort);
let closeTMR = true; 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) let explications = "<br>Lancement du sort <strong>" + sort.name + "</strong> : " + Misc.upperFirst(sort.data.draconic)
+ " pour "+coutReve+ " points de Rêve" + " pour " + coutReve + " points de Rêve"
+ "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")"; + "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
let myReve = duplicate(this.data.data.reve.reve); let myReve = duplicate(this.data.data.reve.reve);

25
module/item-sort.js Normal file
View 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;
}
}

View File

@ -1,3 +1,4 @@
import { RdDItemSort } from "./item-sort.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
@ -72,12 +73,12 @@ export class RdDRollDialog extends Dialog {
// Sort management // Sort management
if ( rollData.selectedSort ) { if ( rollData.selectedSort ) {
//console.log("Toggle show/hide", 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(); $("#div-sort-difficulte").show();
} else { } else {
$("#div-sort-difficulte").hide(); $("#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(); $("#div-sort-ptreve").show();
} else { } else {
$("#div-sort-ptreve").hide(); $("#div-sort-ptreve").hide();
@ -88,6 +89,7 @@ export class RdDRollDialog extends Dialog {
$("#compdialogTitle").text(RdDRollDialog._getTitle(rollData)); $("#compdialogTitle").text(RdDRollDialog._getTitle(rollData));
$(".table-resolution").remove(); $(".table-resolution").remove();
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel)); $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel));
} }
// Setup everything onload // Setup everything onload
@ -99,9 +101,7 @@ export class RdDRollDialog extends Dialog {
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac]; rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
$("#carac").val(rollData.competence.data.defaut_carac); $("#carac").val(rollData.competence.data.defaut_carac);
} }
// Si sort, for les points de reve à 1 RdDItemSort.setCoutReveReel(rollData.selectedSort);
if (rollData.selectedSort && !rollData.selectedSort.data.ptreve_reel)
rollData.selectedSort.data.ptreve_reel = 1;
$("#diffLibre").val(Misc.toInt(rollData.diffLibre)); $("#diffLibre").val(Misc.toInt(rollData.diffLibre));
$("#diffConditions").val(Misc.toInt(rollData.diffConditions)); $("#diffConditions").val(Misc.toInt(rollData.diffConditions));
updateRollResult(rollData); updateRollResult(rollData);
@ -133,12 +133,13 @@ export class RdDRollDialog extends Dialog {
html.find('#sort').change((event) => { html.find('#sort').change((event) => {
let sortKey = Misc.toInt(event.currentTarget.value); let sortKey = Misc.toInt(event.currentTarget.value);
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
RdDItemSort.setCoutReveReel(rollData.selectedSort);
//console.log("RdDRollDialog - Sort selection", rollData.selectedSort); //console.log("RdDRollDialog - Sort selection", rollData.selectedSort);
updateRollResult(rollData); updateRollResult(rollData);
}); });
html.find('#ptreve-variable').change((event) => { html.find('#ptreve-variable').change((event) => {
let ptreve = Misc.toInt(event.currentTarget.value); 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); console.log("RdDRollDialog - Cout reve", ptreve);
updateRollResult(rollData); updateRollResult(rollData);
}); });
@ -149,17 +150,18 @@ export class RdDRollDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _computeFinalLevel(rollData) { static _computeFinalLevel(rollData) {
let etat = Misc.toInt(rollData.etat); const etat = Misc.toInt(rollData.etat);
const diffLibre = Misc.toInt(rollData.diffLibre);
const diffConditions = Misc.toInt(rollData.diffConditions); const diffConditions = Misc.toInt(rollData.diffConditions);
let diffLibre = Misc.toInt(rollData.diffLibre);
let diffCompetence = 0;
if (rollData.competence) { if (rollData.competence) {
return etat + Misc.toInt(rollData.competence.data.niveau) + diffLibre + diffConditions; diffCompetence = Misc.toInt(rollData.competence.data.niveau);
} }
if (rollData.draconicList) { else if (rollData.draconicList) {
let diffSort = (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") ? diffLibre : Misc.toInt(rollData.selectedSort.data.difficulte); diffCompetence = Misc.toInt(rollData.selectedDraconic.data.niveau);
return etat + Misc.toInt(rollData.selectedDraconic.data.niveau) + diffSort + diffConditions; diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
} }
return etat + diffLibre + diffConditions; return etat + diffCompetence + diffLibre + diffConditions;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -124,7 +124,7 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async gererTourbillon( value ) { async gererTourbillon( value ) {
this.nbFatigue += value; this.nbFatigue += value;
await this.actor.updatePointsDeReve( -value ); await this.actor.reveActuelIncDec( -value );
if ( !this.currentRencontre.tourbillonDirection ) { if ( !this.currentRencontre.tourbillonDirection ) {
this.currentRencontre.tourbillonDirection = TMRUtility.getDirectionPattern(); this.currentRencontre.tourbillonDirection = TMRUtility.getDirectionPattern();
} }
@ -512,7 +512,7 @@ export class RdDTMRDialog extends Dialog {
if (this.viewOnly) { if (this.viewOnly) {
return; 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(); this.updateValuesDisplay();
let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord); let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord);
await this.manageRencontre(this.actor.data.data.reve.tmrpos.coord, cellDescr); await this.manageRencontre(this.actor.data.data.reve.tmrpos.coord, cellDescr);

View File

@ -429,7 +429,7 @@ export class TMRUtility {
state = "passeur"; state = "passeur";
} else if (rencontre.name == "Fleur des Rêves") { } 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"; 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") { } 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"; 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") { } 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; 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") { } else if (rencontre.name == "Changeur de Rêve") {