Gestion des attaques ciblées

This commit is contained in:
LeRatierBretonnien 2023-04-11 13:26:51 +02:00
parent 05026d454b
commit 577eccbbd3
7 changed files with 120 additions and 9 deletions

View File

@ -70,6 +70,16 @@ export class HeritiersActor extends Actor {
return armes return armes
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getOtherMeleeWeapons(excludeArme) {
let armes = []
for (let arme of this.items) {
if ( HeritiersUtility.isArmeMelee(arme) && arme.id != excludeArme._id) {
armes.push(this.prepareArme(arme))
}
}
return armes
}
/* -------------------------------------------- */
getMonnaies() { getMonnaies() {
return this.items.filter(it => it.type == "monnaie") return this.items.filter(it => it.type == "monnaie")
} }
@ -613,6 +623,7 @@ export class HeritiersActor extends Actor {
rollData.caracKey = key rollData.caracKey = key
rollData.arme = arme rollData.arme = arme
rollData.mode = "arme" rollData.mode = "arme"
rollData.armes = this.getOtherMeleeWeapons(arme)
if (rollData.defenderTokenId && arme.system.isMelee ) { if (rollData.defenderTokenId && arme.system.isMelee ) {
rollData.cacheDifficulte = true rollData.cacheDifficulte = true
} }
@ -634,6 +645,7 @@ export class HeritiersActor extends Actor {
rollData.caracKey = key rollData.caracKey = key
rollData.arme = duplicate(arme) rollData.arme = duplicate(arme)
rollData.mode = "attaquebrutale" rollData.mode = "attaquebrutale"
rollData.armes = this.getOtherMeleeWeapons(arme)
rollData.rulesMalus.push({ name: "Attaque brutale", value: -2 } ) rollData.rulesMalus.push({ name: "Attaque brutale", value: -2 } )
let rollDialog = await HeritiersRollDialog.create(this, rollData) let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true) rollDialog.render(true)
@ -650,6 +662,7 @@ export class HeritiersActor extends Actor {
rollData.carac = this.system.caracteristiques[key] rollData.carac = this.system.caracteristiques[key]
rollData.caracKey = key rollData.caracKey = key
rollData.arme = duplicate(arme) rollData.arme = duplicate(arme)
rollData.armes = this.getOtherMeleeWeapons(arme)
rollData.mode = "attaquecharge" rollData.mode = "attaquecharge"
let rollDialog = await HeritiersRollDialog.create(this, rollData) let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true) rollDialog.render(true)

View File

@ -93,6 +93,13 @@ export const HERITIERS_CONFIG = {
"30": "Divine" "30": "Divine"
}, },
attaqueCible: {
"none": "Aucune",
"membre": "Membre",
"main": "Main",
"tete": "Tête/Coeur"
},
categorieArme : { categorieArme : {
"trait": "Arme de trait", "trait": "Arme de trait",
"poing": "Arme de poing", "poing": "Arme de poing",

View File

@ -5,7 +5,7 @@ export class HeritiersRollDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async create(actor, rollData) { static async create(actor, rollData) {
let options = { classes: ["HeritiersDialog"], width: 320, height: 'fit-content', 'z-index': 99999 }; let options = { classes: ["HeritiersDialog"], width: 420, height: 'fit-content', 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-les-heritiers/templates/roll-dialog-generic.html', rollData); let html = await renderTemplate('systems/fvtt-les-heritiers/templates/roll-dialog-generic.html', rollData);
return new HeritiersRollDialog(actor, rollData, html, options); return new HeritiersRollDialog(actor, rollData, html, options);
@ -119,6 +119,12 @@ export class HeritiersRollDialog extends Dialog {
html.find('#attaqueDos').change((event) => { html.find('#attaqueDos').change((event) => {
this.rollData.attaqueDos = event.currentTarget.checked this.rollData.attaqueDos = event.currentTarget.checked
}) })
html.find('#bonus-attaque-seconde-arme').change((event) => {
this.rollData.secondeArme = String(event.currentTarget.value)
})
html.find('#attaque-cible').change((event) => {
this.rollData.attaqueCible = String(event.currentTarget.value)
})
} }
} }

View File

@ -338,14 +338,31 @@ export class HeritiersUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeArmeDegats(rollData, actor) { static computeArmeDegats(rollData, actor) {
rollData.degatsArme = rollData.arme.system.degats + rollData.marge rollData.degatsArme = rollData.arme.system.degats + rollData.marge
if (rollData.arme.system.categorie == "lourde") { if (rollData.attaqueDeuxArmes != 0 && rollData.secondeArme ) {
rollData.degatsArme += actor.system.caracteristiques.for.value let secondeArme = actor.items.get(secondeArme)
if (secondeArme) {
rollData.degatsArme += secondeArme.system.degats
rollData.degatsArme += actor.system.caracteristiques.for.value
}
} else {
if (rollData.arme.system.categorie == "lourde") {
rollData.degatsArme += actor.system.caracteristiques.for.value
}
if (rollData.arme.system.categorie == "blanche" || rollData.arme.system.categorie == "improvise") {
rollData.degatsArme += Math.max(0, actor.system.caracteristiques.for.value - 2)
}
if (rollData.mode == "attaquecharge") {
rollData.degatsArme += 3
}
} }
if (rollData.arme.system.categorie == "blanche" || rollData.arme.system.categorie == "improvise") { if (rollData.attaqueCible == "membre") {
rollData.degatsArme += Math.max(0, actor.system.caracteristiques.for.value - 2) rollData.degatsArme -= 2
} }
if (rollData.mode == "attaquecharge") { if (rollData.attaqueCible == "main") {
rollData.degatsArme += 3 rollData.degatsArme -= 3
}
if (rollData.attaqueCible == "tete") {
rollData.degatsArme *= 3
} }
} }
@ -417,6 +434,7 @@ export class HeritiersUtility {
} }
rollData.diceFormula += `+${ruleMalus}` rollData.diceFormula += `+${ruleMalus}`
// Gestion bonus attaque à plusieurs
let bonusAttaque = rollData.bonusAttaquePlusieurs let bonusAttaque = rollData.bonusAttaquePlusieurs
if (rollData.attaqueDos) { if (rollData.attaqueDos) {
bonusAttaque = 2 bonusAttaque = 2
@ -426,6 +444,24 @@ export class HeritiersUtility {
} }
rollData.diceFormula += `+${bonusAttaque}` rollData.diceFormula += `+${bonusAttaque}`
// Gestion attaque avec 2 armes
if (rollData.attaqueDeuxArmes != 0) {
rollData.diceFormula += `+${rollData.attaqueDeuxArmes}`
}
// Gestion des attaques ciblées
if (rollData.attaqueCible != "none") {
if ( rollData.attaqueCible == "membre") {
rollData.diceFormula += `-2`
}
if ( rollData.attaqueCible == "main") {
rollData.diceFormula += `-3`
}
if ( rollData.attaqueCible == "tete") {
rollData.diceFormula += `-6`
}
}
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
@ -576,8 +612,11 @@ export class HeritiersUtility {
sdList: game.system.lesheritiers.config.seuilsDifficulte, sdList: game.system.lesheritiers.config.seuilsDifficulte,
sdValue: -1, sdValue: -1,
bonusAttaquePlusieurs: 0, bonusAttaquePlusieurs: 0,
attaqueDeuxArmes: 0,
attaqueDos: false, attaqueDos: false,
bonusMalusContext: 0, bonusMalusContext: 0,
attaqueCible: "none",
config: game.system.lesheritiers.config,
rulesMalus : [] rulesMalus : []
} }
return rollData return rollData

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.37", "version": "10.1.0",
"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.37.zip", "download": "https://www.uberwald.me/gitea/public/fvtt-les-heritiers/archive/fvtt-les-heritiers-10.1.0.zip",
"languages": [ "languages": [
{ {
"lang": "fr", "lang": "fr",

View File

@ -23,6 +23,14 @@
{{#if isSuccess}} {{#if isSuccess}}
<li>Marge : {{marge}}</li> <li>Marge : {{marge}}</li>
<li>Degats de l'arme : {{degatsArme}}</li> <li>Degats de l'arme : {{degatsArme}}</li>
{{#if (eq attaqueCible "membre")}}
<li><strong>Cible un membre : La cible a -2 de malus sur ces actions avec ce membre (mouvement 2 si jambes)</strong></li>
{{/if}}
{{#if (eq attaqueCible "main")}}
<li><strong>Cible une main : La cible ne peut plus utiliser sa main</strong></li>
{{/if}}
{{#if isCriticalSuccess}} {{#if isCriticalSuccess}}
<Li>Critique : Aubaine ou +2 aux dégats ci-dessus</li> <Li>Critique : Aubaine ou +2 aux dégats ci-dessus</li>
{{/if}} {{/if}}

View File

@ -89,6 +89,44 @@
<span class="roll-dialog-label">Attaque dans le dos ?</span> <span class="roll-dialog-label">Attaque dans le dos ?</span>
<input type="checkbox" class="item-field-label-short" id="attaqueDos" {{checked attaqueDos}}/> <input type="checkbox" class="item-field-label-short" id="attaqueDos" {{checked attaqueDos}}/>
</div> </div>
<div class="flexrow">
<span class="roll-dialog-label">Attaque à deux armes </span>
<select class="roll-dialog-label" id="bonus-attaque-deux-armes" type="text" value="{{attaqueDeuxArmes}}"
data-dtype="Number">
{{#select attaqueDeuxArmes}}
<option value="0">Aucun</option>
<option value="-4">Deux armes à 1 main</option>
<option value="-2">Deux armes naturelles"</option>
<option value="-2">Avec spécialisation "Mauvaise Main"</option>
{{/select}}
</select>
</div>
<div class="flexrow">
<span class="roll-dialog-label">Seconde arme</span>
<select class="roll-dialog-label" id="bonus-attaque-seconde-arme" type="text" value="{{secondeArme}}"
data-dtype="String">
{{#select secondeArme}}
{{#each armes as |arme idx|}}
<option value="{{arme.id}}">{{arme.name}}</option>
{{/each}}
{{/select}}
</select>
</div>
{{/if}}
{{#if arme}}
<li class="flexrow item">
<label class="roll-dialog-label">Ataque ciblée : </label>
<select class="roll-dialog-label" type="text" id="attaque-cible" value="{{attaqueCible}}" data-dtype="String">
{{#select attaqueCible}}
{{#each config.attaqueCible as |categ key|}}
<option value="{{key}}">{{categ}}</option>
{{/each}}
{{/select}}
</select>
</li>
{{/if}} {{/if}}
<div class="flexrow"> <div class="flexrow">