From 1d56bff61df12b9674a1ef00e570aa85d1a78793 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 13 Jan 2021 03:11:03 +0100 Subject: [PATCH] Utilisation des ajustements --- module/actor.js | 6 ++---- module/rdd-bonus.js | 4 ++-- module/rdd-combat.js | 12 ++++++------ module/rdd-roll.js | 23 ++--------------------- templates/actor-creature-sheet.html | 2 +- templates/actor-humanoide-sheet.html | 2 +- templates/dialog-competence.html | 10 +++++----- 7 files changed, 19 insertions(+), 40 deletions(-) diff --git a/module/actor.js b/module/actor.js index 2bc739f9..9d8c0d55 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1779,8 +1779,7 @@ export class RdDActor extends Actor { competence: competence, tache: tache, diffConditions: tache.data.difficulte, - editLibre: false, - editConditions: false, + use: { libre: false, conditions: false}, carac: {} }; rollData.carac[tache.data.carac] = duplicate(this.data.data.carac[tache.data.carac]); // Single carac @@ -1830,8 +1829,7 @@ export class RdDActor extends Actor { isPurification: false, }, diffConditions: 0, - editLibre: false, - editConditions: true, + use: { libre: false, conditions: true, }, carac: {} }; meditationData.carac["intellect"] = duplicate(this.data.data.carac["intellect"]); diff --git a/module/rdd-bonus.js b/module/rdd-bonus.js index 3a8806fd..a0d21036 100644 --- a/module/rdd-bonus.js +++ b/module/rdd-bonus.js @@ -36,9 +36,9 @@ export class RdDBonus { } else { dmg.dmgArme = RdDBonus._dmgArme(rollData); dmg.penetration = RdDBonus._peneration(rollData); - dmg.dmgTactique = RdDBonus.dmgBonus(rollData.tactique); + dmg.dmgTactique = RdDBonus.dmgBonus(rollData.ajustements?.tactique); dmg.dmgParticuliere = RdDBonus._dmgParticuliere(rollData); - dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.surpriseDefenseur); + dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris); dmg.dmgActor = rollData.selectedCarac ? RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac.label, dmg.dmgArme) : 0; dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere; dmg.mortalite = RdDBonus._calculMortalite(rollData, isCauchemar) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index ae860ea9..427030de 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -222,7 +222,7 @@ export class RdDCombat { ui.notifications.warn("Action automatisée impossible, le jet de l'attaquant a été perdu (suite à un raffraichissement?)") return; } - const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value; + const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId']?.value; const armeParadeId = event.currentTarget.attributes['data-armeid']?.value; @@ -323,7 +323,7 @@ export class RdDCombat { /* -------------------------------------------- */ static isEchec(rollData) { - switch (rollData.surprise) { + switch (rollData.ajustements.surprise.used) { case 'totale': return true; } return rollData.rolled.isEchec; @@ -331,7 +331,7 @@ export class RdDCombat { /* -------------------------------------------- */ static isEchecTotal(rollData) { - if (!rollData.attackerRoll && rollData.surprise) { + if (!rollData.attackerRoll && rollData.ajustements.surprise.used) { return rollData.rolled.isEchec; } return rollData.rolled.isETotal; @@ -339,7 +339,7 @@ export class RdDCombat { /* -------------------------------------------- */ static isParticuliere(rollData) { - if (!rollData.attackerRoll && rollData.surprise) { + if (!rollData.attackerRoll && rollData.ajustements.surprise.used) { return false; } return rollData.rolled.isPart; @@ -347,7 +347,7 @@ export class RdDCombat { /* -------------------------------------------- */ static isReussite(rollData) { - switch (rollData.surprise) { + switch (rollData.ajustements.surprise.used) { case 'totale': return false; } return rollData.rolled.isSuccess; @@ -414,7 +414,7 @@ export class RdDCombat { const isMeleeDiffNegative = rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0; ChatMessage.create({ whisper: ChatMessage.getWhisperRecipients(this.attacker.name), - content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', { + content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-particuliere.html', { attackerId: this.attackerId, defenderTokenId: this.defenderTokenId, isFinesse: isMeleeDiffNegative, diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 2de31f6a..e24ff8e9 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -49,10 +49,7 @@ export class RdDRoll extends Dialog { surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, surencMalusValue: actor.getSurenc(), useMalusSurenc: false, - use: { - surenc: false, - encTotal: false, - }, + use: { libre:true, conditions: true, surenc: false, encTotal: false, }, isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), useMalusEncTotal: false, encTotal: actor.getEncTotal(), @@ -245,23 +242,7 @@ export class RdDRoll extends Dialog { /* -------------------------------------------- */ _computeFinalLevel(rollData) { - 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); - const malusEncTotal = (rollData.useMalusEncTotal) ? -rollData.encTotal : 0; - const ajustementChance = RdDResolutionTable.isAjustementAstrologique(rollData) ? rollData.ajustementAstrologique : 0; - // Gestion malus armure - const malusArmureValue = this._computeMalusArmure(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; - - let ajust = RollDataAjustements.sum(rollData.ajustements); - return ajust; - //return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusSurenc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique; + return RollDataAjustements.sum(rollData.ajustements); } /* -------------------------------------------- */ diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index b9788a21..e98568dd 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -83,7 +83,7 @@ Sonné : - +
  • Etat Général : diff --git a/templates/actor-humanoide-sheet.html b/templates/actor-humanoide-sheet.html index d58d71ef..eb441bc3 100644 --- a/templates/actor-humanoide-sheet.html +++ b/templates/actor-humanoide-sheet.html @@ -83,7 +83,7 @@ Sonné : - +
  • Etat Général : diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index 5bd5e70a..5b56c11e 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -17,7 +17,7 @@ {{else}} - {{#select diffLibre}} {{#each difficultesLibres as |key|}} @@ -26,7 +26,7 @@ {{/if}} - {{#select diffConditions}} {{#each ajustementsConditions as |key|}} @@ -45,7 +45,7 @@ {{else}} - @@ -54,8 +54,8 @@ {{/if}} - {{#if surpriseDefenseur}} - + {{#if ajustements.attaqueDefenseurSurpris}} + {{/if}} {{/if}}