Gestion attaques v2 et initiative
This commit is contained in:
@@ -16,10 +16,11 @@ export default class ChatRollResult {
|
||||
static onReady() {
|
||||
foundry.applications.handlebars.loadTemplates({
|
||||
'partial-appel-chance': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-appel-chance.hbs',
|
||||
'partial-attaque-particuliere': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-attaque-particuliere.hbs',
|
||||
'partial-encaissement': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-encaissement.hbs',
|
||||
'partial-recul-choc': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-recul-choc.hbs',
|
||||
'partial-info-appel-moral': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-info-appel-moral.hbs',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async display(roll) {
|
||||
@@ -38,12 +39,12 @@ export default class ChatRollResult {
|
||||
}
|
||||
|
||||
prepareDisplay(roll) {
|
||||
roll.done = roll.done || {}
|
||||
roll.show = roll.show || {}
|
||||
roll.done = roll.done ?? {}
|
||||
roll.show = roll.show ?? {}
|
||||
roll.show.chance = this.isAppelChancePossible(roll)
|
||||
roll.show.encaissement = this.isShowEncaissement(roll)
|
||||
roll.show.recul = this.getReculChoc(roll)
|
||||
|
||||
roll.show.recul = this.getRecul(roll)
|
||||
roll.show.particuliere = roll.show.particuliere ?? []
|
||||
}
|
||||
|
||||
isAppelChancePossible(roll) {
|
||||
@@ -57,20 +58,36 @@ export default class ChatRollResult {
|
||||
roll.attackerRoll?.dmg.mortalite != 'empoignade'
|
||||
}
|
||||
|
||||
getReculChoc(roll, defender = roll.active.actor, attacker = roll.opponent.actor) {
|
||||
const attaque = roll.attackerRoll
|
||||
if (attaque &&
|
||||
(roll.rolled.isEchec || !roll.current.defense.isEsquive) &&
|
||||
(attaque.particuliere == 'force' || 'charge' == attaque.tactique?.key)) {
|
||||
const taille = defender.system.carac.taille.value
|
||||
const impact = attacker.system.carac.force.value + roll.attackerRoll?.dmg.dmgArme
|
||||
return {
|
||||
raison: 'charge' == attaque.tactique?.key ? 'charge' : 'particulière en force',
|
||||
taille: taille,
|
||||
impact: impact,
|
||||
chances: RdDResolutionTable.computeChances(10, taille-impact).norm,
|
||||
diff: taille - impact
|
||||
}
|
||||
|
||||
getRecul(roll, defender = roll.active.actor, attacker = roll.opponent.actor) {
|
||||
switch (roll.type.current) {
|
||||
case ROLL_TYPE_DEFENSE:
|
||||
{
|
||||
const attaque = roll.attackerRoll
|
||||
if (attaque &&
|
||||
(roll.rolled.isEchec || !roll.current.defense.isEsquive) &&
|
||||
(attaque.particuliere == 'force' || 'charge' == attaque.tactique?.key)) {
|
||||
const taille = defender.system.carac.taille.value
|
||||
const impact = attacker.system.carac.force.value + roll.attackerRoll?.dmg.dmgArme
|
||||
return {
|
||||
raison: 'charge' == attaque.tactique?.key ? 'charge' : 'particulière en force',
|
||||
taille: taille,
|
||||
impact: impact,
|
||||
chances: RdDResolutionTable.computeChances(10, taille - impact).norm,
|
||||
diff: taille - impact
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case ROLL_TYPE_ATTAQUE:
|
||||
{
|
||||
const attaque = roll
|
||||
if (attaque.particuliere == 'force' || 'charge' == attaque.tactique?.key) {
|
||||
return {
|
||||
raison: 'charge' == attaque.tactique?.key ? 'charge' : 'particulière en force',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
@@ -85,6 +102,7 @@ export default class ChatRollResult {
|
||||
$(html).on("click", '.appel-destinee', event => this.onClickAppelDestinee(event))
|
||||
$(html).on("click", '.encaissement', event => this.onClickEncaissement(event))
|
||||
$(html).on("click", '.resister-recul', event => this.onClickRecul(event))
|
||||
$(html).on("click", '.choix-particuliere', event => this.onClickChoixParticuliere(event))
|
||||
|
||||
}
|
||||
|
||||
@@ -178,4 +196,13 @@ export default class ChatRollResult {
|
||||
await this.updateChatMessage(chatMessage, savedRoll)
|
||||
}
|
||||
|
||||
async onClickChoixParticuliere(event) {
|
||||
const choix = event.currentTarget.attributes['data-particuliere'].value
|
||||
const chatMessage = ChatUtility.getChatMessage(event)
|
||||
const savedRoll = ChatUtility.getMessageData(chatMessage, 'rollData')
|
||||
savedRoll.particuliere = choix
|
||||
savedRoll.particulieres = [RDD_CONFIG.particuliere[choix]]
|
||||
await this.updateChatMessage(chatMessage, savedRoll)
|
||||
await this.getCombat(savedRoll)?.onAttaqueV2(savedRoll, callbacks)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user