mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-23 07:53:39 +02:00
Fixed crit damage
This commit is contained in:
parent
42144acfe4
commit
98a28ac7b9
8 changed files with 46 additions and 35 deletions
|
|
@ -108,7 +108,9 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
partContext.traitOptions = CONFIG.DH.ACTOR.abilities;
|
||||
|
||||
const selectedRoll = Object.values(this.party.system.tagTeam.members).find(member => member.selected);
|
||||
const critSelected = !selectedRoll ? undefined : (selectedRoll?.rollData?.options?.isCritical ?? false);
|
||||
const critSelected = !selectedRoll
|
||||
? undefined
|
||||
: (selectedRoll?.rollData?.options?.roll?.isCritical ?? false);
|
||||
|
||||
partContext.members = {};
|
||||
for (const actorId in this.party.system.tagTeam.members) {
|
||||
|
|
@ -153,7 +155,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
damage: damage,
|
||||
critDamage: critHitPointsDamage,
|
||||
useCritDamage:
|
||||
critSelected || (critSelected === undefined && data.rollData?.options?.isCritical)
|
||||
critSelected || (critSelected === undefined && data.rollData?.options?.roll?.isCritical)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +392,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
});
|
||||
}
|
||||
|
||||
static async #makeDamageRoll(_, button) {
|
||||
static async #makeDamageRoll(event, button) {
|
||||
const { memberKey } = button.dataset;
|
||||
const actor = game.actors.find(x => x.id === memberKey);
|
||||
if (!actor) return;
|
||||
|
|
@ -399,6 +401,9 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
const action = await foundry.utils.fromUuid(memberData.rollChoice);
|
||||
const config = {
|
||||
...memberData.rollData.options,
|
||||
dialog: {
|
||||
configure: !event.shiftKey
|
||||
},
|
||||
skips: {
|
||||
createMessage: true,
|
||||
resources: true,
|
||||
|
|
@ -409,7 +414,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
await action.workflow.get('damage').execute(config, null, true);
|
||||
if (!config.damage) return;
|
||||
|
||||
const damage = config.isCritical ? await this.getNonCriticalDamage(config, actor) : config.damage;
|
||||
// const damage = config.roll.isCritical ? await this.getNonCriticalDamage(config, actor) : config.damage;
|
||||
|
||||
const current = this.party.system.tagTeam.members[memberKey].rollData;
|
||||
await this.updatePartyData({
|
||||
|
|
@ -417,7 +422,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
...current,
|
||||
options: {
|
||||
...current.options,
|
||||
damage: damage
|
||||
damage: config.damage
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ export default class DamageField extends fields.SchemaField {
|
|||
formulas = DamageField.formatFormulas.call(this, formulas, config);
|
||||
|
||||
const damageConfig = {
|
||||
dialog: {},
|
||||
...config,
|
||||
roll: formulas,
|
||||
dialog: {},
|
||||
data: this.getRollData()
|
||||
};
|
||||
delete damageConfig.evaluate;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import DamageDialog from '../applications/dialogs/damageDialog.mjs';
|
||||
import { parseRallyDice } from '../helpers/utils.mjs';
|
||||
import { RefreshType, socketEvent } from '../systemRegistration/socket.mjs';
|
||||
import DHRoll from './dhRoll.mjs';
|
||||
|
||||
export default class DamageRoll extends DHRoll {
|
||||
|
|
|
|||
|
|
@ -528,7 +528,8 @@ export function expireActiveEffects(actor, allowedTypes = null) {
|
|||
|
||||
export async function getCritDamageBonus(formula) {
|
||||
const critRoll = new Roll(formula);
|
||||
return critRoll.dice.reduce((acc, dice) => acc + dice.faces * dice.number, 0);
|
||||
await critRoll.evaluate();
|
||||
return critRoll.dice.reduce((acc, dice) => acc + dice.faces * dice.results.filter(r => r.active).length, 0);
|
||||
}
|
||||
|
||||
export function htmlToText(html) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ export const preloadHandlebarsTemplates = async function () {
|
|||
'systems/daggerheart/templates/ui/tooltip/parts/tooltipChips.hbs',
|
||||
'systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs',
|
||||
'systems/daggerheart/templates/dialogs/downtime/activities.hbs',
|
||||
'systems/daggerheart/templates/dialogs/tagTeamDialog/parts/tagTeamDamageParts.hbs',
|
||||
'systems/daggerheart/templates/dialogs/dice-roll/costSelection.hbs',
|
||||
'systems/daggerheart/templates/ui/chat/parts/roll-part.hbs',
|
||||
'systems/daggerheart/templates/ui/chat/parts/description-part.hbs',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue