From 05026d454b89cc3800aa3755850bea022047f4aa Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Mon, 10 Apr 2023 14:11:47 +0200 Subject: [PATCH] Add attaque dos+plusieurs --- modules/heritiers-actor.js | 51 ++++-------------------------- modules/heritiers-roll-dialog.js | 7 ++++ modules/heritiers-utility.js | 11 +++++++ system.json | 4 +-- templates/roll-dialog-generic.html | 17 ++++++++-- 5 files changed, 42 insertions(+), 48 deletions(-) diff --git a/modules/heritiers-actor.js b/modules/heritiers-actor.js index dec0a5c..55ba9b8 100644 --- a/modules/heritiers-actor.js +++ b/modules/heritiers-actor.js @@ -600,9 +600,10 @@ export class HeritiersActor extends Actor { async rollAttaqueArme(armeId) { let arme = this.items.get(armeId) if (arme) { + arme = duplicate(arme) + arme.system.isMelee = HeritiersUtility.isArmeMelee(arme) let competenceName = "Tir" let key = "prec" - arme.system.isMelee = HeritiersUtility.isArmeMelee(arme) if ( arme.system.isMelee) { competenceName = "Mêlée" key = "agi" @@ -610,11 +611,12 @@ export class HeritiersActor extends Actor { let rollData = this.getCommonRollData(undefined, competenceName) rollData.carac = this.system.caracteristiques[key] rollData.caracKey = key - rollData.arme = duplicate(arme) + rollData.arme = arme rollData.mode = "arme" if (rollData.defenderTokenId && arme.system.isMelee ) { rollData.cacheDifficulte = true } + console.log(">>>> ARME", rollData) let rollDialog = await HeritiersRollDialog.create(this, rollData) rollDialog.render(true) } @@ -626,6 +628,7 @@ export class HeritiersActor extends Actor { if (arme) { let key = "for" let competenceName = "Mêlée" + arme.system.isMelee = HeritiersUtility.isArmeMelee(arme) let rollData = this.getCommonRollData(undefined, competenceName) rollData.carac = this.system.caracteristiques[key] rollData.caracKey = key @@ -641,6 +644,7 @@ export class HeritiersActor extends Actor { let arme = this.items.get(armeId) if (arme) { let key = "agi" + arme.system.isMelee = HeritiersUtility.isArmeMelee(arme) let pireCompetence = this.getPireCompetence("Mêlée", "Mouvement") let rollData = this.getCommonRollData(undefined, pireCompetence.name) rollData.carac = this.system.caracteristiques[key] @@ -657,6 +661,7 @@ export class HeritiersActor extends Actor { let arme = this.items.get(armeId) if (arme) { let competenceName = "Mêlée" + //arme.system.isMelee = HeritiersUtility.isArmeMelee(arme) let rollData = this.getCommonRollData(undefined, competenceName) rollData.carac = this.system.caracteristiques["agi"] rollData.caracKey = "agi" @@ -688,46 +693,4 @@ export class HeritiersActor extends Actor { } } - /* -------------------------------------------- */ - async rollArmeOffensif(armeId) { - let arme = this.items.get(armeId) - if (arme.type == "arme") { - arme = this.prepareArme(arme) - } - let rollData = this.getCommonRollData(arme.system.attrKey, arme.system.competence._id) - rollData.arme = arme - HeritiersUtility.updateWithTarget(rollData) - console.log("ARME!", rollData) - let rollDialog = await HeritiersRollDialog.create(this, rollData) - rollDialog.render(true) - } - - /* -------------------------------------------- */ - async rollArmeDegats(armeId, targetVigueur = undefined) { - let arme = this.items.get(armeId) - if (arme.type == "arme") { - arme = this.prepareArme(arme) - } - console.log("DEGATS", arme) - let roll = new Roll("1d10+" + arme.system.totalDegats).roll({ async: false }) - await HeritiersUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode")); - let nbEtatPerdus = 0 - if (targetVigueur) { - nbEtatPerdus = Math.floor(roll.total / targetVigueur) - } - let rollData = { - arme: arme, - finalResult: roll.total, - alias: this.name, - actorImg: this.img, - actorId: this.id, - actionImg: arme.img, - targetVigueur: targetVigueur, - nbEtatPerdus: nbEtatPerdus - } - HeritiersUtility.createChatWithRollMode(rollData.alias, { - content: await renderTemplate(`systems/fvtt-les-heritiers/templates/chat-degats-result.html`, rollData) - }) - - } } diff --git a/modules/heritiers-roll-dialog.js b/modules/heritiers-roll-dialog.js index e8f5ebf..98366e3 100644 --- a/modules/heritiers-roll-dialog.js +++ b/modules/heritiers-roll-dialog.js @@ -110,8 +110,15 @@ export class HeritiersRollDialog extends Dialog { html.find('#bonus-malus-context').change((event) => { this.rollData.bonusMalusContext = Number(event.currentTarget.value) }) + html.find('#bonus-attaque-plusieurs').change((event) => { + this.rollData.bonusAttaquePlusieurs = Number(event.currentTarget.value) + }) html.find('#useSpecialite').change((event) => { this.rollData.useSpecialite = event.currentTarget.checked }) + html.find('#attaqueDos').change((event) => { + this.rollData.attaqueDos = event.currentTarget.checked + }) + } } \ No newline at end of file diff --git a/modules/heritiers-utility.js b/modules/heritiers-utility.js index 8b9f3f1..511d510 100644 --- a/modules/heritiers-utility.js +++ b/modules/heritiers-utility.js @@ -417,6 +417,15 @@ export class HeritiersUtility { } rollData.diceFormula += `+${ruleMalus}` + let bonusAttaque = rollData.bonusAttaquePlusieurs + if (rollData.attaqueDos) { + bonusAttaque = 2 + if (rollData.bonusAttaquePlusieurs) { + bonusAttaque = 3 // Valeur max, cf règle page 197 + } + } + rollData.diceFormula += `+${bonusAttaque}` + let myRoll = new Roll(rollData.diceFormula).roll({ async: false }) await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) rollData.roll = myRoll @@ -566,6 +575,8 @@ export class HeritiersUtility { rollMode: game.settings.get("core", "rollMode"), sdList: game.system.lesheritiers.config.seuilsDifficulte, sdValue: -1, + bonusAttaquePlusieurs: 0, + attaqueDos: false, bonusMalusContext: 0, rulesMalus : [] } diff --git a/system.json b/system.json index ace267a..9fcbcf4 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "fvtt-les-heritiers", "description": "Les Héritiers pour FoundryVTT", - "version": "10.0.36", + "version": "10.0.37", "authors": [ { "name": "Uberwald/LeRatierBretonnien", @@ -19,7 +19,7 @@ "gridUnits": "m", "license": "LICENSE.txt", "manifest": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/raw/branch/master/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.36.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.0.37.zip", "languages": [ { "lang": "fr", diff --git a/templates/roll-dialog-generic.html b/templates/roll-dialog-generic.html index 04bf036..0b6c18c 100644 --- a/templates/roll-dialog-generic.html +++ b/templates/roll-dialog-generic.html @@ -73,10 +73,23 @@ {{/each}} + {{#if (and arme arme.system.isMelee)}}
- Malus de Santé - {{pvMalus}} + Attaque à plusieurs +
+
+ Attaque dans le dos ? + +
+ {{/if}}
Bonus/Malus