mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
parent
f87dfe477a
commit
c7f3ec8ab3
10 changed files with 156 additions and 388 deletions
|
|
@ -31,16 +31,17 @@ export default class DamageRoll extends DHRoll {
|
|||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
const chatMessage = config.source?.message ? ui.chat.collection.get(config.source.message) : getDocumentClass('ChatMessage').applyRollMode({}, config.rollMode);
|
||||
if (game.modules.get('dice-so-nice')?.active) {
|
||||
const pool = foundry.dice.terms.PoolTerm.fromRolls(
|
||||
Object.values(config.damage).flatMap(r => r.parts.map(p => p.roll))
|
||||
),
|
||||
diceRoll = Roll.fromTerms([pool]);
|
||||
await game.dice3d.showForRoll(diceRoll, game.user, true);
|
||||
await game.dice3d.showForRoll(diceRoll, game.user, true, chatMessage.whisper, chatMessage.blind);
|
||||
}
|
||||
await super.buildPost(roll, config, message);
|
||||
if (config.source?.message) {
|
||||
const chatMessage = ui.chat.collection.get(config.source.message);
|
||||
// const chatMessage = ui.chat.collection.get(config.source.message);
|
||||
chatMessage.update({ 'system.damage': config.damage });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ export default class DHRoll extends Roll {
|
|||
|
||||
static messageType = 'adversaryRoll';
|
||||
|
||||
static CHAT_TEMPLATE = 'systems/daggerheart/templates/ui/chat/roll.hbs';
|
||||
|
||||
static DefaultDialog = D20RollDialog;
|
||||
|
||||
static async build(config = {}, message = {}) {
|
||||
|
|
@ -95,6 +97,39 @@ export default class DHRoll extends Roll {
|
|||
if(roll._evaluated) return await cls.create(msg, { rollMode: config.selectedRollMode });
|
||||
return msg;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async render({flavor, template=this.constructor.CHAT_TEMPLATE, isPrivate=false, ...options}={}) {
|
||||
if ( !this._evaluated ) return;
|
||||
const chatData = await this._prepareChatRenderContext({flavor, isPrivate, ...options});
|
||||
return foundry.applications.handlebars.renderTemplate(template, chatData);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _prepareChatRenderContext({flavor, isPrivate=false, ...options}={}) {
|
||||
if(isPrivate) {
|
||||
return {
|
||||
user: game.user.id,
|
||||
flavor: null,
|
||||
title: "???",
|
||||
roll: {
|
||||
total: "??"
|
||||
},
|
||||
hasRoll: true,
|
||||
isPrivate
|
||||
}
|
||||
} else {
|
||||
options.message.system.user = game.user.id;
|
||||
return options.message.system;
|
||||
}
|
||||
// return {
|
||||
// formula: isPrivate ? "???" : this._formula,
|
||||
// flavor: isPrivate ? null : flavor ?? this.options.flavor,
|
||||
// user: game.user.id,
|
||||
// tooltip: isPrivate ? "" : await this.getTooltip(),
|
||||
// total: isPrivate ? "?" : Math.round(this.total * 100) / 100
|
||||
// };
|
||||
}
|
||||
|
||||
static applyKeybindings(config) {
|
||||
if (config.event)
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ export default class DualityRoll extends D20Roll {
|
|||
}
|
||||
if (this.rallyFaces)
|
||||
this.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }),
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
new foundry.dice.terms.Die({ faces: this.rallyFaces })
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue