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) {
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)
})
}
}

View File

@ -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
})
}
}

View File

@ -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 : []
}

View File

@ -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",

View File

@ -73,10 +73,23 @@
</div>
{{/each}}
{{#if (and arme arme.system.isMelee)}}
<div class="flexrow">
<span class="roll-dialog-label">Malus de Santé</span>
<span class="small-label roll-dialog-label">{{pvMalus}}</span>
<span class="roll-dialog-label">Attaque à plusieurs </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 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">
<span class="roll-dialog-label">Bonus/Malus </span>