diff --git a/module/rdd-bonus.js b/module/rdd-bonus.js index c8fe7668..1207dcb2 100644 --- a/module/rdd-bonus.js +++ b/module/rdd-bonus.js @@ -32,7 +32,7 @@ export class RdDBonus { let dmg = { total: 0 }; if (rollData.arme && rollData.arme.name.toLowerCase() == "esquive") { // Specific case management - ui.notifications.warn("Calcul de bonus dégats sur eswquive"); + ui.notifications.warn("Calcul de bonus dégats sur esquive !"); } else { dmg.dmgArme = RdDBonus._dmgArme(rollData); dmg.penetration = RdDBonus._peneration(rollData); @@ -74,9 +74,15 @@ export class RdDBonus { /* -------------------------------------------- */ static _dmgArme(rollData) { - return rollData.arme == undefined ? 0 : (rollData.arme.data.dommagesReels ?? Number(rollData.arme.data.dommages ?? 0)); + let dmg1 = 0; + if ( rollData.arme) { + dmg1 = rollData.arme.data.dommagesReels ?? Number(rollData.arme.data.dommages ?? 0); + dmg1 += (rollData.arme.data.magique) ? rollData.arme.data.ecaille_efficacite : 0; + } + return dmg1; } + /* -------------------------------------------- */ static _peneration(rollData) { return parseInt(rollData.arme?.data.penetration ?? 0); } diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 98556587..e1808d6a 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -756,21 +756,43 @@ export class RdDCombat { defenderRoll.show = defenderRoll.show || {} const dmg = attackerRoll.dmg.dmgArme + attackerRoll.dmg.dmgActor; - let resistance = Misc.toInt(defenderRoll.arme.data.resistance); + let arme = defenderRoll.arme; let msg = ""; - // Jet de résistance de l'arme de parade (p.132) - let resistRoll = await RdDResolutionTable.rollData({ - caracValue: resistance, - finalLevel: - dmg, - showDice: false - }); - if (resistRoll.rolled.isSuccess) { // Perte de résistance - defenderRoll.show.deteriorationArme = 'resiste'; + if ( arme.data.magique ) { + defenderRoll.show.deteriorationArme = 'resiste'; // Par défaut + if (arme.data.resistance_magique == undefined) arme.data.resistance_magique = 0; // Quick fix + if ( dmg > arme.data.resistance_magique) { // Jet uniquement si dommages supérieur à résistance magique (cf. 274) + let resistance = Misc.toInt(arme.data.resistance); + // Jet de résistance de l'arme de parade (p.132) + let resistRoll = await RdDResolutionTable.rollData({ + caracValue: resistance, + finalLevel: - dmg, + showDice: false + }); + if ( !resistRoll.rolled.isSuccess) { + let perteResistance = ( dmg - arme.data.resistance_magique) + resistance -= perteResistance; + defenderRoll.show.deteriorationArme = resistance <= 0 ? 'brise': 'perte'; + defenderRoll.show.perteResistance = perteResistance; + this.defender.updateEmbeddedEntity("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance }); + } + } } else { - resistance -= dmg; - defenderRoll.show.deteriorationArme = resistance <= 0 ? 'brise': 'perte'; - defenderRoll.show.perteResistance = dmg; - this.defender.updateEmbeddedEntity("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance }); + let resistance = Misc.toInt(arme.data.resistance); + // Jet de résistance de l'arme de parade (p.132) + let resistRoll = await RdDResolutionTable.rollData({ + caracValue: resistance, + finalLevel: - dmg, + showDice: false + }); + if (resistRoll.rolled.isSuccess) { // Perte de résistance + defenderRoll.show.deteriorationArme = 'resiste'; + } else { + resistance -= dmg; + defenderRoll.show.deteriorationArme = resistance <= 0 ? 'brise': 'perte'; + defenderRoll.show.perteResistance = dmg; + this.defender.updateEmbeddedEntity("OwnedItem", { _id: defenderRoll.arme._id, 'data.resistance': resistance }); + } } // Si l'arme de parade n'est pas un bouclier, jet de désarmement (p.132) if (ReglesOptionelles.isUsing('defenseurDesarme') && resistance > 0 && RdDItemArme.getCategorieParade(defenderRoll.arme) != 'boucliers') { diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 53033711..6a931db8 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -191,6 +191,7 @@ export class RdDRoll extends Dialog { }); } + /* -------------------------------------------- */ async updateRollResult() { let rollData = this.rollData; @@ -235,6 +236,7 @@ export class RdDRoll extends Dialog { } + /* -------------------------------------------- */ async buildAjustements(rollData){ const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData); return html; @@ -244,7 +246,6 @@ export class RdDRoll extends Dialog { _computeFinalLevel(rollData) { return RollDataAjustements.sum(rollData.ajustements); } - /* -------------------------------------------- */ _computeDiffCompetence(rollData) { if (rollData.competence) { @@ -265,6 +266,7 @@ export class RdDRoll extends Dialog { return diffLibre; } + /* -------------------------------------------- */ _computeMalusArmure(rollData) { let malusArmureValue = 0; if (rollData.malusArmureValue && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) { diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index e432fec1..32c8837f 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -93,6 +93,12 @@ export const referenceAjustements = { getLabel: (rollData, actor) => Misc.getFractionHtml(rollData.diviseurSignificative), getDescr: (rollData, actor) => rollData.diviseurSignificative > 1 ? `Facteur significative ×${Misc.getFractionHtml(rollData.diviseurSignificative)}` : '' }, + isEcaille: { + isVisible: (rollData, actor) => rollData.arme && rollData.arme.data.magique && Number(rollData.arme.data.ecaille_efficacite) > 0, + isUsed: (rollData, actor) => rollData.arme && rollData.arme.data.magique && Number(rollData.arme.data.ecaille_efficacite) > 0, + getLabel: (rollData, actor) => "Ecaille d'Efficacité: ", + getValue: (rollData, actor) => (rollData.arme && rollData.arme.data.magique && Number(rollData.arme.data.ecaille_efficacite) > 0) ? rollData.arme.data.ecaille_efficacite : 0, + }, finesse: { isUsed: (rollData, actor) => RdDBonus.isDefenseAttaqueFinesse(rollData), getDescr: (rollData, actor) => 'Attaque particulière en finesse', diff --git a/system.json b/system.json index c773a057..e2a08005 100644 --- a/system.json +++ b/system.json @@ -2,11 +2,11 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.3.5", + "version": "1.3.6", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", - "templateVersion": 85, + "templateVersion": 86, "author": "LeRatierBretonnien", "authors": [ { diff --git a/template.json b/template.json index b7e9b81f..d687c6ef 100644 --- a/template.json +++ b/template.json @@ -595,12 +595,15 @@ "competence": "", "cout": 0, "portee_courte": 0, + "magique": false, + "ecaille_efficacite": 0, + "resistance_magique": 0, "portee_moyenne": 0, "portee_extreme": 0, "rapide": false, "deuxmains": false, "unemain": false - }, + }, "munition": { "description": "", "quantite": 1, diff --git a/templates/dialog-roll-ajustements.html b/templates/dialog-roll-ajustements.html index e555db73..b249f046 100644 --- a/templates/dialog-roll-ajustements.html +++ b/templates/dialog-roll-ajustements.html @@ -21,4 +21,5 @@ Significative requise ×{{{ajustements.facteurSign.label}}}! {{/if}} + \ No newline at end of file diff --git a/templates/item-arme-sheet.html b/templates/item-arme-sheet.html index 3e41f4b7..0fd1743e 100644 --- a/templates/item-arme-sheet.html +++ b/templates/item-arme-sheet.html @@ -72,6 +72,18 @@ +