#13 Support des sorts de difficulte et de cout variables + correction de regression

This commit is contained in:
2020-11-13 11:24:56 +01:00
parent e40b335886
commit a00f187f9f
4 changed files with 77 additions and 34 deletions

View File

@ -151,7 +151,7 @@ export class RdDActor extends Actor {
// Fight management !
let defenseMsg;
let encaisser = false;
if (rollData.arme || rollData.competence.name.toLowerCase() == 'esquive' ) {
if (rollData.arme || (rollData.competence && rollData.competence.name.toLowerCase() == 'esquive') ) {
// In case of fight, replace the message per dommages + localization. it indicates if result is OK or not
if (rollData.attackerRoll) { // Defense case !
if (rolled.isSuccess) {
@ -161,7 +161,7 @@ export class RdDActor extends Actor {
encaisser = true;
}
} else { // This is the attack roll!
if (rolled.isSuccess > 0) {
if (rolled.isSuccess) {
rollData.domArmePlusDom = parseInt(rollData.arme.data.dommages);
if (rollData.selectedCarac.label == "Mêlée") // +dom only for Melee
rollData.domArmePlusDom += parseInt(this.data.data.attributs.plusdom.value);
@ -189,14 +189,14 @@ export class RdDActor extends Actor {
let lvl = ""
if (rollData.selectedSort) { // Lancement de sort !
let draconic = rollData.selectedSort.data.draconic;
let costReve = rollData.selectedSort.data.ptreve_reel || rollData.selectedSort.data.ptreve; // cas de sort à ptreve variables
specialStr = "<br>Lancement du sort <strong>" + rollData.selectedSort.name + "</strong> : " + draconic.charAt(0).toUpperCase() + draconic.slice(1) + "/" + rollData.selectedSort.data.difficulte +
"/" + rollData.selectedSort.data.caseTMR + "/R" + rollData.selectedSort.data.ptreve;
"/" + rollData.selectedSort.data.caseTMR + "/R" + costReve;
specialStr += "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
lvl = rollData.selectedDraconic.name + "/" + rollData.selectedSort.name;
let costReve = rollData.selectedSort.data.ptreve;
let myReve = duplicate(this.data.data.reve.reve);
if (rollData.tache > 0) { // Réussite du sort !
if (rollData.tache >= 4) costReve = Math.ceil(costReve / 2);
if (rolled.isSuccess) { // Réussite du sort !
if (rolled.tache >= 4) costReve = Math.ceil(costReve / 2);
if (costReve < 1) costReve = 1;
myReve.value = myReve.value - costReve; // Todo 0 pts de reve !!!!
if (myReve.value < 0) myReve.value = 0;
@ -211,7 +211,7 @@ export class RdDActor extends Actor {
this.currentTMR.updateSortReserve();
}
} else {
if (rollData.tache == -4) { // Echec total !
if (rolled.tache == -4) { // Echec total !
costReve *= 2;
myReve.value = myReve.value - costReve; // Todo 0 pts de reve !!!!
if (myReve.value < 0) myReve.value = 0;
@ -231,9 +231,6 @@ export class RdDActor extends Actor {
}
// Save it for fight in the flags area
console.log("Saving Flag", this);
await this.setFlag('world', 'rollData', null);
await this.setFlag('world', 'rollData', rollData);
game.system.rdd.rollDataHandler[this.data._id] = duplicate(rollData);
// Final chat message
@ -642,7 +639,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async rollUnSort(coord) {
let draconicList = this.getDraconicList();
let sortList = this.getSortList();
let sortList = duplicate(this.getSortList()); // Duplication car les pts de reve sont modifiés dans le sort
let rollData = {
selectedCarac: this.data.data.carac.reve,
@ -653,7 +650,9 @@ export class RdDActor extends Actor {
selectedSort: sortList[0],
coord: coord,
finalLevel: 0,
bmValue: 0
bmValue: sortList[0].data.difficulte, // Per default at startup
coutreve: Array(20).fill().map((item, index) => 1 + index),
bonusmalusTable: CONFIG.RDD.bonusmalus
}
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData);
new RdDRollDialog("sort", html, rollData, this ).render(true);
@ -663,11 +662,11 @@ export class RdDActor extends Actor {
async rollCarac( caracName )
{
let rollData = {
"selectedCarac": this.data.data.carac[caracName],
"bonusmalusTable": CONFIG.RDD.bonusmalus,
"etat": this.data.data.compteurs.etat.value,
"finalLevel": 0,
"bmValue": 0
selectedCarac: this.data.data.carac[caracName],
bonusmalusTable: CONFIG.RDD.bonusmalus,
etat: this.data.data.compteurs.etat.value,
finalLevel: 0,
bmValue: 0
}
console.log(caracName, rollData);
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);