mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 22:46:12 +01:00
update command to use new dice roll.
This commit is contained in:
parent
c2669a8de6
commit
d25212d9d7
5 changed files with 87 additions and 76 deletions
|
|
@ -1,6 +1,10 @@
|
|||
export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
||||
async renderHTML() {
|
||||
if(this.system.messageTemplate) this.content = await foundry.applications.handlebars.renderTemplate(this.system.messageTemplate, this.system);
|
||||
if (this.system.messageTemplate)
|
||||
this.content = await foundry.applications.handlebars.renderTemplate(
|
||||
this.system.messageTemplate,
|
||||
this.system
|
||||
);
|
||||
|
||||
/* We can change to fully implementing the renderHTML function if needed, instead of augmenting it. */
|
||||
const html = await super.renderHTML();
|
||||
|
|
@ -14,7 +18,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
break;
|
||||
case -1:
|
||||
html.classList.add('fear');
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
html.classList.add('critical');
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import DHDamageRoll from '../data/chat-message/damageRoll.mjs';
|
||||
import D20RollDialog from '../dialogs/d20RollDialog.mjs';
|
||||
import DamageDialog from '../dialogs/damageDialog.mjs';
|
||||
import { setDiceSoNiceForDualityRoll } from '../helpers/utils.mjs';
|
||||
|
||||
/*
|
||||
- Damage & other resources roll
|
||||
|
|
@ -54,7 +55,6 @@ export class DHRoll extends Roll {
|
|||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
console.log(config);
|
||||
for (const hook of config.hooks) {
|
||||
if (Hooks.call(`${SYSTEM.id}.postRoll${hook.capitalize()}`, config, message) === false) return null;
|
||||
}
|
||||
|
|
@ -95,7 +95,8 @@ export class DHRoll extends Roll {
|
|||
}
|
||||
|
||||
static applyKeybindings(config) {
|
||||
config.dialog.configure ??= !(config.event.shiftKey || config.event.altKey || config.event.ctrlKey);
|
||||
if (config.event)
|
||||
config.dialog.configure ??= !(config.event.shiftKey || config.event.altKey || config.event.ctrlKey);
|
||||
}
|
||||
|
||||
constructFormula(config) {
|
||||
|
|
@ -161,12 +162,20 @@ export class D20Roll extends DHRoll {
|
|||
}
|
||||
|
||||
static applyKeybindings(config) {
|
||||
const keys = {
|
||||
normal: config.event.shiftKey || config.event.altKey || config.event.ctrlKey,
|
||||
advantage: config.event.altKey,
|
||||
disadvantage: config.event.ctrlKey
|
||||
let keys = {
|
||||
normal: true,
|
||||
advantage: false,
|
||||
disadvantage: false
|
||||
};
|
||||
|
||||
if (config.event) {
|
||||
keys = {
|
||||
normal: config.event.shiftKey || config.event.altKey || config.event.ctrlKey,
|
||||
advantage: config.event.altKey,
|
||||
disadvantage: config.event.ctrlKey
|
||||
};
|
||||
}
|
||||
|
||||
// Should the roll configuration dialog be displayed?
|
||||
config.dialog.configure ??= !Object.values(keys).some(k => k);
|
||||
|
||||
|
|
@ -372,12 +381,23 @@ export class DualityRoll extends D20Roll {
|
|||
}
|
||||
|
||||
applyBaseBonus() {
|
||||
this.options.roll.modifiers = [
|
||||
{
|
||||
label: 'HI',
|
||||
value: Roll.replaceFormulaData(`@traits.${this.options.roll.trait}.total`, this.data)
|
||||
}
|
||||
];
|
||||
if (this.options.roll.trait) {
|
||||
this.options.roll.modifiers = [
|
||||
{
|
||||
label: `DAGGERHEART.Abilities.${this.options.roll.trait}.name`,
|
||||
value: Roll.replaceFormulaData(`@traits.${this.options.roll.trait}.total`, this.data)
|
||||
}
|
||||
];
|
||||
} else {
|
||||
this.options.roll.modifiers = [];
|
||||
}
|
||||
}
|
||||
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
if (config.evaluate !== false) await roll.evaluate();
|
||||
const advantageState = this.hasAdvantage ? true : this.hasDisadvantage ? false : null;
|
||||
setDiceSoNiceForDualityRoll(roll, advantageState);
|
||||
this.postEvaluate(roll, config);
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import CostSelectionDialog from '../../applications/costSelectionDialog.mjs';
|
||||
import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs';
|
||||
import DhpActor from '../../documents/actor.mjs';
|
||||
//import DhpActor from '../../documents/actor.mjs';
|
||||
import D20RollDialog from '../../dialogs/d20RollDialog.mjs';
|
||||
|
||||
const fields = foundry.data.fields;
|
||||
|
|
@ -129,13 +129,13 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
return this.parent.parent;
|
||||
}
|
||||
|
||||
get actor() {
|
||||
return this.item instanceof DhpActor
|
||||
? this.item
|
||||
: this.item?.parent instanceof DhpActor
|
||||
? this.item.parent
|
||||
: this.item?.actor;
|
||||
}
|
||||
// get actor() {
|
||||
// return this.item instanceof DhpActor
|
||||
// ? this.item
|
||||
// : this.item?.parent instanceof DhpActor
|
||||
// ? this.item.parent
|
||||
// : this.item?.actor;
|
||||
// }
|
||||
|
||||
get chatTemplate() {
|
||||
return 'systems/daggerheart/templates/chat/duality-roll.hbs';
|
||||
|
|
@ -402,11 +402,18 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
hasCost(costs) {
|
||||
const realCosts = this.getRealCosts(costs),
|
||||
hasFearCost = realCosts.findIndex(c => c.type === 'fear');
|
||||
if(hasFearCost > -1) {
|
||||
if (hasFearCost > -1) {
|
||||
const fearCost = realCosts.splice(hasFearCost, 1);
|
||||
if(!game.user.isGM || fearCost[0].total > game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.Fear)) return false;
|
||||
if (
|
||||
!game.user.isGM ||
|
||||
fearCost[0].total > game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.Fear)
|
||||
)
|
||||
return false;
|
||||
}
|
||||
return realCosts.reduce((a, c) => a && this.actor.system.resources[c.type]?.value >= (c.total ?? c.value), true);
|
||||
return realCosts.reduce(
|
||||
(a, c) => a && this.actor.system.resources[c.type]?.value >= (c.total ?? c.value),
|
||||
true
|
||||
);
|
||||
}
|
||||
/* COST */
|
||||
|
||||
|
|
@ -498,19 +505,25 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
|||
|
||||
/* SAVE */
|
||||
async rollSave(target, event, message) {
|
||||
if(!target?.actor) return;
|
||||
return target.actor.diceRoll({
|
||||
event,
|
||||
title: 'Roll Save',
|
||||
roll: {
|
||||
trait: this.save.trait,
|
||||
difficulty: this.save.difficulty,
|
||||
type: "reaction"
|
||||
},
|
||||
data: target.actor.getRollData()
|
||||
}).then(async (result) => {
|
||||
if(result) this.updateChatMessage(message, target.id, {result: result.roll.total, success: result.roll.success});
|
||||
})
|
||||
if (!target?.actor) return;
|
||||
return target.actor
|
||||
.diceRoll({
|
||||
event,
|
||||
title: 'Roll Save',
|
||||
roll: {
|
||||
trait: this.save.trait,
|
||||
difficulty: this.save.difficulty,
|
||||
type: 'reaction'
|
||||
},
|
||||
data: target.actor.getRollData()
|
||||
})
|
||||
.then(async result => {
|
||||
if (result)
|
||||
this.updateChatMessage(message, target.id, {
|
||||
result: result.roll.total,
|
||||
success: result.roll.success
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async updateChatMessage(message, targetId, changes, chain = true) {
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ export const getCommandTarget = () => {
|
|||
|
||||
export const setDiceSoNiceForDualityRoll = (rollResult, advantageState) => {
|
||||
const diceSoNicePresets = getDiceSoNicePresets();
|
||||
rollResult.dice[0].options.appearance = diceSoNicePresets.hope;
|
||||
rollResult.dice[1].options.appearance = diceSoNicePresets.fear;
|
||||
rollResult.dice[0].options = { appearance: diceSoNicePresets.hope };
|
||||
rollResult.dice[1].options = { appearance: diceSoNicePresets.fear }; //diceSoNicePresets.fear;
|
||||
if (rollResult.dice[2]) {
|
||||
if (advantageState === true) {
|
||||
rollResult.dice[2].options.appearance = diceSoNicePresets.advantage;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue