Gestion des maladresses
This commit is contained in:
@@ -9,6 +9,9 @@ import { EMPOIGNADE } from "../item/arme.js"
|
||||
import { RdDTextEditor } from "../apps/rdd-text-roll-editor.js"
|
||||
import { RollTypeCuisine } from "./roll-type-cuisine.mjs"
|
||||
import { RollTypeMeditation } from "./roll-type-meditation.mjs"
|
||||
import { PART_DEFENSE } from "./roll-part-defense.mjs"
|
||||
import { PART_ATTAQUE } from "./roll-part-attaque.mjs"
|
||||
import { RdDRollTables } from "../rdd-rolltables.js"
|
||||
|
||||
export default class ChatRollResult {
|
||||
static init() {
|
||||
@@ -21,6 +24,7 @@ export default class ChatRollResult {
|
||||
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-maladresse': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-maladresse.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',
|
||||
@@ -49,7 +53,7 @@ export default class ChatRollResult {
|
||||
roll.show.chance = this.isAppelChancePossible(roll)
|
||||
roll.show.encaissement = this.isShowEncaissement(roll)
|
||||
roll.show.recul = this.getRecul(roll)
|
||||
//roll.show.particuliere = roll.show.particuliere ?? []
|
||||
roll.show.maladresse = this.getMaladresse(roll)
|
||||
}
|
||||
|
||||
isAppelChancePossible(roll) {
|
||||
@@ -66,6 +70,23 @@ export default class ChatRollResult {
|
||||
return false
|
||||
}
|
||||
|
||||
getMaladresse(roll) {
|
||||
switch (roll.type.current) {
|
||||
case ROLL_TYPE_DEFENSE:
|
||||
if (roll.rolled.isETotal) {
|
||||
const arme = roll.current[PART_DEFENSE].arme
|
||||
return arme ? 'avec-arme' : 'sans-arme'
|
||||
}
|
||||
break
|
||||
case ROLL_TYPE_ATTAQUE:
|
||||
if (roll.rolled.isETotal || (roll.rolled.isEchec && roll.active.surprise == 'demi')) {
|
||||
const arme = roll.current[PART_ATTAQUE].arme
|
||||
return arme.system.baseInit > 4 ? 'avec-arme' : 'sans-arme'
|
||||
}
|
||||
break
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
getRecul(roll, defender = roll.active.actor, attacker = roll.opponent?.actor) {
|
||||
switch (roll.type.current) {
|
||||
@@ -115,6 +136,7 @@ export default class ChatRollResult {
|
||||
$(html).on("click", '.faire-gouter', event => this.onClickFaireGouter(event))
|
||||
$(html).on("click", '.monter-tmr-normale', event => this.onClickMonteeTMR(event, 'normal'))
|
||||
$(html).on("click", '.monter-tmr-rapide', event => this.onClickMonteeTMR(event, 'rapide'))
|
||||
$(html).on("click", '.tirer-maladresse', event => this.onClickTirerMaladresse(event))
|
||||
|
||||
}
|
||||
|
||||
@@ -247,4 +269,13 @@ export default class ChatRollResult {
|
||||
await this.updateChatMessage(chatMessage, savedRoll)
|
||||
}
|
||||
}
|
||||
async onClickTirerMaladresse(event) {
|
||||
const chatMessage = ChatUtility.getChatMessage(event)
|
||||
const typeMaladresse = event.currentTarget.attributes['data-maladresse'].value
|
||||
const savedRoll = this.loadChatMessageRoll(chatMessage)
|
||||
await RdDRollTables.getMaladresse({ arme: typeMaladresse == 'avec-arme' })
|
||||
savedRoll.type.maladresse = true
|
||||
savedRoll.type.retry = true
|
||||
await this.updateChatMessage(chatMessage, savedRoll)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user