forked from public/foundryvtt-reve-de-dragon
Avancement messages défense & oeuvres
This commit is contained in:
59
module/roll/chat-roll-result.mjs
Normal file
59
module/roll/chat-roll-result.mjs
Normal file
@@ -0,0 +1,59 @@
|
||||
import { ChatUtility } from "../chat-utility.js"
|
||||
import RollDialog from "./roll-dialog.mjs"
|
||||
import { RdDCarac } from "../rdd-carac.js";
|
||||
|
||||
export class ChatRollResult {
|
||||
|
||||
static onReady() {
|
||||
foundry.applications.handlebars.loadTemplates({
|
||||
'partial-appel-chance': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-appel-chance.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) {
|
||||
roll.show = roll.show || {};
|
||||
roll.show.chance = this.isAppelChancePossible(roll)
|
||||
roll.show.encaissement = this.isShowEncaissement(roll)
|
||||
roll.show.recul = this.isShowReculChoc(roll)
|
||||
|
||||
const chatMessage = await ChatUtility.createChatWithRollMode(
|
||||
{
|
||||
content: await this.buildRollHtml(roll)
|
||||
},
|
||||
roll.active.actor,
|
||||
roll.current?.rollmode?.key
|
||||
)
|
||||
if (roll.show.chance) {
|
||||
const save = RollDialog.saveParts(roll)
|
||||
console.log("Store message roll", save)
|
||||
ChatUtility.setMessageData(chatMessage, 'rollData', save)
|
||||
}
|
||||
return chatMessage
|
||||
}
|
||||
|
||||
isAppelChancePossible(roll) {
|
||||
return roll.active.actor.isPersonnage() &&
|
||||
roll.rolled.isEchec &&
|
||||
RdDCarac.isActionPhysique(roll.current.carac?.key)
|
||||
}
|
||||
|
||||
isShowEncaissement(roll) {
|
||||
return roll.rolled.isEchec &&
|
||||
roll.attackerRoll?.dmg.mortalite != 'empoignade'
|
||||
}
|
||||
|
||||
isShowReculChoc(roll) {
|
||||
return roll.rolled.isEchec &&
|
||||
roll.attackerRoll &&
|
||||
!roll.current.defense.isEsquive &&
|
||||
(roll.attackerRoll.particuliere == 'force' || 'charge' == attackerRoll.tactique?.key)
|
||||
}
|
||||
|
||||
async buildRollHtml(roll) {
|
||||
const template = `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${roll.type.current}.hbs`
|
||||
return await foundry.applications.handlebars.renderTemplate(template, roll)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user