From ad205f4669ce89121d47865301f9f861fe0d8e9d Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 29 Dec 2021 20:33:59 +0100 Subject: [PATCH] Attack process path --- lang/en.json | 6 +++++- lang/fr.json | 4 ++++ module/controllers/bol-rolls.js | 22 +++++++++++++++++++--- system.json | 2 +- templates/dialogs/weapon-roll-dialog.hbs | 20 ++++++++++++++++++++ templates/roll/roll-dialog-weapon.hbs | 4 ++-- 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/lang/en.json b/lang/en.json index c6fbfa6..ed8bbeb 100644 --- a/lang/en.json +++ b/lang/en.json @@ -94,7 +94,11 @@ "BOL.ui.misc" : "Divers", "BOL.ui.noWeaponName" : "Unknown Weapon", "BOL.ui.targetDefence": "Defence", - + "BOL.ui.applyShieldMalus": "Apply Small Shield Malus", + "BOL.ui.shieldMalus": "Shield Malus", + "BOL.ui.defenseScore": "Defense Score", + "BOL.ui.defender": "Defender", + "BOL.featureCategory.origins": "Origines", "BOL.featureCategory.races": "Races", "BOL.featureCategory.careers": "Carrières", diff --git a/lang/fr.json b/lang/fr.json index 9a150e9..a7c195c 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -96,6 +96,10 @@ "BOL.ui.speed" : "Vitesse", "BOL.ui.noWeaponName" : "Arme Inconnue", "BOL.ui.targetDefence": "Défense", + "BOL.ui.applyShieldMalus": "Appliquer le Malus de Petit Bouclier", + "BOL.ui.shieldMalus": "Malus de Bouclier", + "BOL.ui.defenseScore": "Score de Defense", + "BOL.ui.defender": "Défenseur", "BOL.featureCategory.origins": "Origines", "BOL.featureCategory.races": "Races", diff --git a/module/controllers/bol-rolls.js b/module/controllers/bol-rolls.js index cee4274..b5f11b9 100644 --- a/module/controllers/bol-rolls.js +++ b/module/controllers/bol-rolls.js @@ -69,7 +69,7 @@ export class BoLRoll { boons:actorData.features.boons, flaws:actorData.features.flaws }; - console.log(dialogData.careers); + const rollOptionContent = await renderTemplate(rollOptionTpl, dialogData); let d = new Dialog({ title: label, @@ -118,8 +118,17 @@ export class BoLRoll { careers: attackDef.attackerData.features.careers, boons: attackDef.attackerData.features.boons, flaws: attackDef.attackerData.features.flaws, - defence: (attackDef.defender) ? attackDef.defender.defenseValue : 0, }; + if ( attackDef.defender) { + dialogData.defence = attackDef.defender.defenseValue, + dialogData.shieldBlock = 'none' + let shields = attackDef.defender.shields + for( let shield of shields) { + dialogData.shieldBlock = (shield.data.properties.blocking.blockingAll) ? 'blockall' : 'blockone'; + dialogData.shieldAttackMalus = (shield.data.properties.blocking.malus)? shield.data.properties.blocking.malus : 1; + dialogData.applyShieldMalus = false + } + } const rollOptionContent = await renderTemplate(rollOptionTpl, dialogData); let d = new Dialog({ title: attackDef.label, @@ -139,13 +148,20 @@ export class BoLRoll { const apt = html.find('#apt').val(); const adv = html.find('#adv').val(); const mod = html.find('#mod').val() || 0; + + let shieldMalus = 0; + const applyShieldMalus = html.find('#applyShieldMalus').val() || false; + if (applyShieldMalus || dialogData.shieldBlock =='blockall') { + shieldMalus = dialogData.shieldAttackMalus; + } + let careers = html.find('#career').val(); const career = (careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i))); const isMalus = adv < 0; const dicePool = (isMalus) ? 2 - parseInt(adv) : 2 + parseInt(adv); const attrValue = eval(`attackDef.attacker.data.data.attributes.${attr}.value`); const aptValue = eval(`attackDef.attacker.data.data.aptitudes.${apt}.value`); - const modifiers = parseInt(attrValue) + parseInt(aptValue) + parseInt(mod) + parseInt(career) - dialogData.defence; + const modifiers = parseInt(attrValue) + parseInt(aptValue) + parseInt(mod) + parseInt(career) - dialogData.defence - shieldMalus; const formula = (isMalus) ? dicePool + "d6kl2 + " + modifiers : dicePool + "d6kh2 + " + modifiers; attackDef.formula = formula; let r = new BoLAttackRoll(attackDef); diff --git a/system.json b/system.json index 1192c7d..d5fefc5 100644 --- a/system.json +++ b/system.json @@ -9,7 +9,7 @@ "flags": {}, "version": "0.8.9.0", "minimumCoreVersion": "0.8.6", - "compatibleCoreVersion": "0.8.9", + "compatibleCoreVersion": "9", "scripts": [], "esmodules": [ "module/bol.js" diff --git a/templates/dialogs/weapon-roll-dialog.hbs b/templates/dialogs/weapon-roll-dialog.hbs index c66e99a..036168e 100644 --- a/templates/dialogs/weapon-roll-dialog.hbs +++ b/templates/dialogs/weapon-roll-dialog.hbs @@ -55,6 +55,26 @@
{{defence}}
+ {{#if (eq shieldBlock 'blockall')}} +
+
+ +
+
{{shieldAttackMalus}}
+
+ {{/if}} + {{#if (eq shieldBlock 'blockone')}} +
+
+ +
+
+ +
+
+ {{/if}} {{#if careers.items}}
diff --git a/templates/roll/roll-dialog-weapon.hbs b/templates/roll/roll-dialog-weapon.hbs index 5e19670..b9278d2 100644 --- a/templates/roll/roll-dialog-weapon.hbs +++ b/templates/roll/roll-dialog-weapon.hbs @@ -1,11 +1,11 @@
{{#if defender}}
- +
- +
{{/if}}