Add attaque dos+plusieurs

This commit is contained in:
LeRatierBretonnien 2023-04-10 14:11:47 +02:00
parent 6497369d7f
commit 05026d454b
5 changed files with 42 additions and 48 deletions

View File

@ -600,9 +600,10 @@ export class HeritiersActor extends Actor {
async rollAttaqueArme(armeId) { async rollAttaqueArme(armeId) {
let arme = this.items.get(armeId) let arme = this.items.get(armeId)
if (arme) { if (arme) {
arme = duplicate(arme)
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
let competenceName = "Tir" let competenceName = "Tir"
let key = "prec" let key = "prec"
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
if ( arme.system.isMelee) { if ( arme.system.isMelee) {
competenceName = "Mêlée" competenceName = "Mêlée"
key = "agi" key = "agi"
@ -610,11 +611,12 @@ export class HeritiersActor extends Actor {
let rollData = this.getCommonRollData(undefined, competenceName) let rollData = this.getCommonRollData(undefined, competenceName)
rollData.carac = this.system.caracteristiques[key] rollData.carac = this.system.caracteristiques[key]
rollData.caracKey = key rollData.caracKey = key
rollData.arme = duplicate(arme) rollData.arme = arme
rollData.mode = "arme" rollData.mode = "arme"
if (rollData.defenderTokenId && arme.system.isMelee ) { if (rollData.defenderTokenId && arme.system.isMelee ) {
rollData.cacheDifficulte = true rollData.cacheDifficulte = true
} }
console.log(">>>> ARME", rollData)
let rollDialog = await HeritiersRollDialog.create(this, rollData) let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true) rollDialog.render(true)
} }
@ -626,6 +628,7 @@ export class HeritiersActor extends Actor {
if (arme) { if (arme) {
let key = "for" let key = "for"
let competenceName = "Mêlée" let competenceName = "Mêlée"
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
let rollData = this.getCommonRollData(undefined, competenceName) let rollData = this.getCommonRollData(undefined, competenceName)
rollData.carac = this.system.caracteristiques[key] rollData.carac = this.system.caracteristiques[key]
rollData.caracKey = key rollData.caracKey = key
@ -641,6 +644,7 @@ export class HeritiersActor extends Actor {
let arme = this.items.get(armeId) let arme = this.items.get(armeId)
if (arme) { if (arme) {
let key = "agi" let key = "agi"
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
let pireCompetence = this.getPireCompetence("Mêlée", "Mouvement") let pireCompetence = this.getPireCompetence("Mêlée", "Mouvement")
let rollData = this.getCommonRollData(undefined, pireCompetence.name) let rollData = this.getCommonRollData(undefined, pireCompetence.name)
rollData.carac = this.system.caracteristiques[key] rollData.carac = this.system.caracteristiques[key]
@ -657,6 +661,7 @@ export class HeritiersActor extends Actor {
let arme = this.items.get(armeId) let arme = this.items.get(armeId)
if (arme) { if (arme) {
let competenceName = "Mêlée" let competenceName = "Mêlée"
//arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
let rollData = this.getCommonRollData(undefined, competenceName) let rollData = this.getCommonRollData(undefined, competenceName)
rollData.carac = this.system.caracteristiques["agi"] rollData.carac = this.system.caracteristiques["agi"]
rollData.caracKey = "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)
})
}
} }

View File

@ -110,8 +110,15 @@ export class HeritiersRollDialog extends Dialog {
html.find('#bonus-malus-context').change((event) => { html.find('#bonus-malus-context').change((event) => {
this.rollData.bonusMalusContext = Number(event.currentTarget.value) 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) => { html.find('#useSpecialite').change((event) => {
this.rollData.useSpecialite = event.currentTarget.checked this.rollData.useSpecialite = event.currentTarget.checked
}) })
html.find('#attaqueDos').change((event) => {
this.rollData.attaqueDos = event.currentTarget.checked
})
} }
} }

View File

@ -417,6 +417,15 @@ export class HeritiersUtility {
} }
rollData.diceFormula += `+${ruleMalus}` 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 }) let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = myRoll rollData.roll = myRoll
@ -566,6 +575,8 @@ export class HeritiersUtility {
rollMode: game.settings.get("core", "rollMode"), rollMode: game.settings.get("core", "rollMode"),
sdList: game.system.lesheritiers.config.seuilsDifficulte, sdList: game.system.lesheritiers.config.seuilsDifficulte,
sdValue: -1, sdValue: -1,
bonusAttaquePlusieurs: 0,
attaqueDos: false,
bonusMalusContext: 0, bonusMalusContext: 0,
rulesMalus : [] rulesMalus : []
} }

View File

@ -1,7 +1,7 @@
{ {
"id": "fvtt-les-heritiers", "id": "fvtt-les-heritiers",
"description": "Les Héritiers pour FoundryVTT", "description": "Les Héritiers pour FoundryVTT",
"version": "10.0.36", "version": "10.0.37",
"authors": [ "authors": [
{ {
"name": "Uberwald/LeRatierBretonnien", "name": "Uberwald/LeRatierBretonnien",
@ -19,7 +19,7 @@
"gridUnits": "m", "gridUnits": "m",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/raw/branch/master/system.json", "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": [ "languages": [
{ {
"lang": "fr", "lang": "fr",

View File

@ -73,10 +73,23 @@
</div> </div>
{{/each}} {{/each}}
{{#if (and arme arme.system.isMelee)}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">Malus de Santé</span> <span class="roll-dialog-label">Attaque à plusieurs </span>
<span class="small-label roll-dialog-label">{{pvMalus}}</span> <select class="roll-dialog-label" id="bonus-attaque-plusieurs" type="text" value="{{bonusAttaquePlusieurs}}"
data-dtype="Number">
{{#select bonusAttaquePlusieurs}}
<option value="0">0</option>
<option value="1">+1</option>
<option value="2">+2</option>
{{/select}}
</select>
</div> </div>
<div class="flexrow">
<span class="roll-dialog-label">Attaque dans le dos ?</span>
<input type="checkbox" class="item-field-label-short" id="attaqueDos" {{checked attaqueDos}}/>
</div>
{{/if}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">Bonus/Malus </span> <span class="roll-dialog-label">Bonus/Malus </span>