Merged with main

This commit is contained in:
WBHarry 2026-01-26 14:36:58 +01:00
commit 286944d2e6
207 changed files with 4909 additions and 1073 deletions

View file

@ -1,5 +1,6 @@
export { default as AttributionDialog } from './attributionDialog.mjs';
export { default as BeastformDialog } from './beastformDialog.mjs';
export { default as CharacterResetDialog } from './characterResetDialog.mjs';
export { default as d20RollDialog } from './d20RollDialog.mjs';
export { default as DamageDialog } from './damageDialog.mjs';
export { default as DamageReductionDialog } from './damageReductionDialog.mjs';
@ -14,3 +15,4 @@ export { default as ResourceDiceDialog } from './resourceDiceDialog.mjs';
export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs';
export { default as GroupRollDialog } from './group-roll-dialog.mjs';
export { default as TagTeamDialog } from './tagTeamDialog.mjs';
export { default as RiskItAllDialog } from './riskItAllDialog.mjs';

View file

@ -0,0 +1,105 @@
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
export default class CharacterResetDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(actor, options = {}) {
super(options);
this.actor = actor;
this.data = {
delete: {
class: { keep: false, label: 'TYPES.Item.class' },
subclass: { keep: false, label: 'TYPES.Item.subclass' },
ancestry: { keep: false, label: 'TYPES.Item.ancestry' },
community: { keep: false, label: 'TYPES.Item.community' }
},
optional: {
portrait: { keep: true, label: 'DAGGERHEART.GENERAL.portrait' },
name: { keep: true, label: 'Name' },
biography: { keep: true, label: 'DAGGERHEART.GENERAL.Tabs.biography' },
inventory: { keep: true, label: 'DAGGERHEART.GENERAL.inventory' }
}
};
}
static DEFAULT_OPTIONS = {
tag: 'form',
classes: ['daggerheart', 'dialog', 'dh-style', 'views', 'character-reset'],
window: {
icon: 'fa-solid fa-arrow-rotate-left',
title: 'DAGGERHEART.APPLICATIONS.CharacterReset.title'
},
actions: {
finishSelection: this.#finishSelection
},
form: {
handler: this.updateData,
submitOnChange: true,
submitOnClose: false
}
};
/** @override */
static PARTS = {
resourceDice: {
id: 'resourceDice',
template: 'systems/daggerheart/templates/dialogs/characterReset.hbs'
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.data = this.data;
return context;
}
static async updateData(event, _, formData) {
const { data } = foundry.utils.expandObject(formData.object);
this.data = foundry.utils.mergeObject(this.data, data);
this.render();
}
static getUpdateData() {
const update = {};
if (!this.data.optional.portrait) update.if(!this.data.optional.biography);
if (!this.data.optional.inventory) return update;
}
static async #finishSelection() {
const update = {};
if (!this.data.optional.name.keep) {
const defaultName = game.system.api.documents.DhpActor.defaultName({ type: 'character' });
foundry.utils.setProperty(update, 'name', defaultName);
foundry.utils.setProperty(update, 'prototypeToken.name', defaultName);
}
if (!this.data.optional.portrait.keep) {
foundry.utils.setProperty(update, 'img', this.actor.schema.fields.img.initial(this.actor));
foundry.utils.setProperty(update, 'prototypeToken.==texture', {});
foundry.utils.setProperty(update, 'prototypeToken.==ring', {});
}
if (this.data.optional.biography.keep)
foundry.utils.setProperty(update, 'system.biography', this.actor.system.biography);
if (this.data.optional.inventory.keep) foundry.utils.setProperty(update, 'system.gold', this.actor.system.gold);
const { system, ...rest } = update;
await this.actor.update({
...rest,
'==system': system ?? {}
});
const inventoryItemTypes = ['weapon', 'armor', 'consumable', 'loot'];
await this.actor.deleteEmbeddedDocuments(
'Item',
this.actor.items
.filter(x => !inventoryItemTypes.includes(x.type) || !this.data.optional.inventory.keep)
.map(x => x.id)
);
this.close();
}
}

View file

@ -10,6 +10,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.config = config;
this.config.experiences = [];
this.reactionOverride = config.actionType === 'reaction';
this.selectedEffects = this.config.bonusEffects;
if (config.source?.action) {
this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent;
@ -35,6 +36,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
selectExperience: this.selectExperience,
toggleReaction: this.toggleReaction,
toggleTagTeamRoll: this.toggleTagTeamRoll,
toggleSelectedEffect: this.toggleSelectedEffect,
submitRoll: this.submitRoll
},
form: {
@ -76,6 +78,9 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
icon
}));
context.hasSelectedEffects = Boolean(this.selectedEffects && Object.keys(this.selectedEffects).length);
context.selectedEffects = this.selectedEffects;
this.config.costs ??= [];
if (this.config.costs?.length) {
const updatedCosts = game.system.api.fields.ActionFields.CostField.calcCosts.call(
@ -104,11 +109,17 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.roll = this.roll;
context.rollType = this.roll?.constructor.name;
context.rallyDie = this.roll.rallyChoices;
const experiences = this.config.data?.system?.experiences || {};
const actorExperiences = this.config.data?.system?.experiences || {};
const companionExperiences = this.config.roll.companionRoll
? (this.config.data?.companion?.system.experiences ?? {})
: null;
const experiences = companionExperiences ?? actorExperiences;
context.experiences = Object.keys(experiences).map(id => ({
id,
...experiences[id]
}));
context.selectedExperiences = this.config.experiences;
context.advantage = this.config.roll?.advantage;
context.disadvantage = this.config.roll?.disadvantage;
@ -118,7 +129,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.formula = this.roll.constructFormula(this.config);
if (this.actor?.system?.traits) context.abilities = this.getTraitModifiers();
context.showReaction = !this.config.roll?.type && context.rollType === 'DualityRoll';
context.showReaction = !this.config.skips?.reaction && context.rollType === 'DualityRoll';
context.reactionOverride = this.reactionOverride;
}
@ -208,6 +219,11 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.render();
}
static toggleSelectedEffect(_event, button) {
this.selectedEffects[button.dataset.key].selected = !this.selectedEffects[button.dataset.key].selected;
this.render();
}
static async submitRoll() {
await this.close({ submitted: true });
}

View file

@ -6,6 +6,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
this.roll = roll;
this.config = config;
this.selectedEffects = this.config.bonusEffects;
}
static DEFAULT_OPTIONS = {
@ -20,6 +21,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
icon: 'fa-solid fa-dice'
},
actions: {
toggleSelectedEffect: this.toggleSelectedEffect,
submitRoll: this.submitRoll
},
form: {
@ -57,6 +59,9 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
icon
}));
context.modifiers = this.config.modifiers;
context.hasSelectedEffects = Boolean(Object.keys(this.selectedEffects).length);
context.selectedEffects = this.selectedEffects;
return context;
}
@ -69,6 +74,11 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
this.render();
}
static toggleSelectedEffect(_event, button) {
this.selectedEffects[button.dataset.key].selected = !this.selectedEffects[button.dataset.key].selected;
this.render();
}
static async submitRoll() {
await this.close({ submitted: true });
}

View file

@ -1,11 +1,16 @@
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
import { enrichedFateRoll } from '../../enrichers/FateRollEnricher.mjs';
import { enrichedDualityRoll } from '../../enrichers/DualityRollEnricher.mjs';
export default class DhpDeathMove extends HandlebarsApplicationMixin(ApplicationV2) {
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(actor) {
super({});
this.actor = actor;
this.selectedMove = null;
this.showRiskItAllButton = false;
this.riskItAllButtonLabel = '';
this.riskItAllHope = 0;
}
get title() {
@ -38,6 +43,111 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
return context;
}
async handleAvoidDeath() {
const target = this.actor.uuid;
const config = await enrichedFateRoll({
target,
title: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.avoidDeath.name'),
label: `${game.i18n.localize('DAGGERHEART.GENERAL.hope')} ${game.i18n.localize('DAGGERHEART.GENERAL.fateRoll')}`,
fateType: 'Hope'
});
if (!config.roll.fate) return;
let returnMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.avoidScar');
if (config.roll.fate.value <= this.actor.system.levelData.level.current) {
const newScarAmount = this.actor.system.scars + 1;
await this.actor.update({
system: {
scars: newScarAmount
}
});
if (newScarAmount >= this.actor.system.resources.hope.max) {
await this.actor.setDeathMoveDefeated(CONFIG.DH.GENERAL.defeatedConditionChoices.dead.id);
return game.i18n.format('DAGGERHEART.UI.Chat.deathMove.journeysEnd', { scars: newScarAmount });
}
returnMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.gainScar');
}
await this.actor.setDeathMoveDefeated(CONFIG.DH.GENERAL.defeatedConditionChoices.unconscious.id);
return returnMessage;
}
async handleRiskItAll() {
const config = await enrichedDualityRoll({
reaction: true,
traitValue: null,
target: this.actor,
difficulty: null,
title: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.riskItAll.name'),
label: game.i18n.localize('DAGGERHEART.GENERAL.dualityDice'),
actionType: null,
advantage: null,
grantResources: false,
customConfig: { skips: { resources: true, reaction: true } }
});
if (!config.roll.result) return;
const clearAllStressAndHitpointsUpdates = [
{ key: 'hitPoints', clear: true },
{ key: 'stress', clear: true }
];
let chatMessage = '';
if (config.roll.isCritical) {
config.resourceUpdates.addResources(clearAllStressAndHitpointsUpdates);
chatMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.riskItAllCritical');
}
if (config.roll.result.duality == 1) {
if (
config.roll.hope.value >=
this.actor.system.resources.hitPoints.value + this.actor.system.resources.stress.value
) {
config.resourceUpdates.addResources(clearAllStressAndHitpointsUpdates);
chatMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.riskItAllSuccessWithEnoughHope');
} else {
chatMessage = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllSuccess', {
hope: config.roll.hope.value
});
this.showRiskItAllButton = true;
this.riskItAllHope = config.roll.hope.value;
this.riskItAllButtonLabel = game.i18n.format('DAGGERHEART.UI.Chat.deathMove.riskItAllDialogButton');
}
}
if (config.roll.result.duality == -1) {
await this.actor.setDeathMoveDefeated(CONFIG.DH.GENERAL.defeatedConditionChoices.dead.id);
chatMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.riskItAllFailure');
}
await config.resourceUpdates.updateResources();
return chatMessage;
}
async handleBlazeOfGlory() {
this.actor.createEmbeddedDocuments('ActiveEffect', [
{
name: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.name'),
description: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.description'),
img: CONFIG.DH.GENERAL.deathMoves.blazeOfGlory.img,
changes: [
{
key: 'system.rules.roll.guaranteedCritical',
mode: 2,
value: 'true'
}
]
}
]);
await this.actor.setDeathMoveDefeated(CONFIG.DH.GENERAL.defeatedConditionChoices.dead.id);
return game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.blazeOfGlory');
}
static selectMove(_, button) {
const move = button.dataset.move;
this.selectedMove = CONFIG.DH.GENERAL.deathMoves[move];
@ -46,23 +156,49 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
}
static async takeMove() {
this.close();
let result = '';
if (CONFIG.DH.GENERAL.deathMoves.blazeOfGlory === this.selectedMove) {
result = await this.handleBlazeOfGlory();
}
if (CONFIG.DH.GENERAL.deathMoves.avoidDeath === this.selectedMove) {
result = await this.handleAvoidDeath();
}
if (CONFIG.DH.GENERAL.deathMoves.riskItAll === this.selectedMove) {
result = await this.handleRiskItAll();
}
if (!result) return;
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
.expandRollMessage?.desc;
const cls = getDocumentClass('ChatMessage');
const msg = {
user: game.user.id,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/deathMove.hbs',
{
player: this.actor.name,
actor: { name: this.actor.name, img: this.actor.img },
actor: this.actor,
actorId: this.actor._id,
author: game.users.get(game.user.id),
title: game.i18n.localize(this.selectedMove.name),
img: this.selectedMove.img,
description: game.i18n.localize(this.selectedMove.description)
description: game.i18n.localize(this.selectedMove.description),
result: result,
open: autoExpandDescription ? 'open' : '',
chevron: autoExpandDescription ? 'fa-chevron-up' : 'fa-chevron-down',
showRiskItAllButton: this.showRiskItAllButton,
riskItAllButtonLabel: this.riskItAllButtonLabel,
riskItAllHope: this.riskItAllHope
}
),
title: game.i18n.localize(
'DAGGERHEART.UI.Chat.deathMove.title'
),
title: game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.title'),
speaker: cls.getSpeaker(),
flags: {
daggerheart: {
@ -72,7 +208,5 @@ export default class DhpDeathMove extends HandlebarsApplicationMixin(Application
};
cls.create(msg);
this.close();
}
}

View file

@ -93,27 +93,29 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
}
getRefreshables() {
const actionItems = this.actor.items.filter(x => this.actor.system.isItemAvailable(x)).reduce((acc, x) => {
if (x.system.actions) {
const recoverable = x.system.actions.reduce((acc, action) => {
if (refreshIsAllowed([this.shortrest ? 'shortRest' : 'longRest'], action.uses.recovery)) {
acc.push({
title: x.name,
name: action.name,
uuid: action.uuid
});
const actionItems = this.actor.items
.filter(x => this.actor.system.isItemAvailable(x))
.reduce((acc, x) => {
if (x.system.actions) {
const recoverable = x.system.actions.reduce((acc, action) => {
if (refreshIsAllowed([this.shortrest ? 'shortRest' : 'longRest'], action.uses.recovery)) {
acc.push({
title: x.name,
name: action.name,
uuid: action.uuid
});
}
return acc;
}, []);
if (recoverable) {
acc.push(...recoverable);
}
return acc;
}, []);
if (recoverable) {
acc.push(...recoverable);
}
}
return acc;
}, []);
return acc;
}, []);
const resourceItems = this.actor.items.reduce((acc, x) => {
if (
x.system.resource &&
@ -189,7 +191,8 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
}));
});
});
const characters = game.actors.filter(x => x.type === 'character')
const characters = game.actors
.filter(x => x.type === 'character')
.filter(x => x.testUserPermission(game.user, 'LIMITED'))
.filter(x => x.uuid !== this.actor.uuid);

View file

@ -0,0 +1,94 @@
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class RiskItAllDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(actor, resourceValue) {
super({});
this.actor = actor;
this.resourceValue = resourceValue;
this.choices = {
hitPoints: 0,
stress: 0
};
}
get title() {
return game.i18n.format('DAGGERHEART.APPLICATIONS.RiskItAllDialog.title', { name: this.actor.name });
}
static DEFAULT_OPTIONS = {
classes: ['daggerheart', 'dh-style', 'dialog', 'views', 'risk-it-all'],
position: { width: 280, height: 'auto' },
window: { icon: 'fa-solid fa-dice fa-xl' },
actions: {
finish: RiskItAllDialog.#finish
}
};
static PARTS = {
application: {
id: 'risk-it-all',
template: 'systems/daggerheart/templates/dialogs/riskItAllDialog.hbs'
}
};
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
for (const input of htmlElement.querySelectorAll('.resource-container input'))
input.addEventListener('change', this.updateChoice.bind(this));
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.resourceValue = this.resourceValue;
context.maxHitPointsValue = Math.min(this.resourceValue, this.actor.system.resources.hitPoints.max);
context.maxStressValue = Math.min(this.resourceValue, this.actor.system.resources.stress.max);
context.remainingResource = this.resourceValue - this.choices.hitPoints - this.choices.stress;
context.unfinished = context.remainingResource !== 0;
context.choices = this.choices;
context.final = {
hitPoints: {
value: this.actor.system.resources.hitPoints.value - this.choices.hitPoints,
max: this.actor.system.resources.hitPoints.max
},
stress: {
value: this.actor.system.resources.stress.value - this.choices.stress,
max: this.actor.system.resources.stress.max
}
};
context;
return context;
}
updateChoice(event) {
let value = Number.parseInt(event.target.value);
const choiceKey = event.target.dataset.choice;
const actorValue = this.actor.system.resources[choiceKey].value;
const remaining = this.resourceValue - this.choices.hitPoints - this.choices.stress;
const changeAmount = value - this.choices[choiceKey];
/* If trying to increase beyond remaining resource points, just increase to max available */
if (remaining - changeAmount < 0) value = this.choices[choiceKey] + remaining;
else if (actorValue - value < 0) value = actorValue;
this.choices[choiceKey] = value;
this.render();
}
static async #finish() {
const resourceUpdate = Object.keys(this.choices).reduce((acc, resourceKey) => {
const value = this.actor.system.resources[resourceKey].value - this.choices[resourceKey];
acc[resourceKey] = { value };
return acc;
}, {});
await this.actor.update({
'system.resources': resourceUpdate
});
this.close();
}
}

View file

@ -5,7 +5,8 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
classes: ['daggerheart'],
actions: {
combat: DHTokenHUD.#onToggleCombat,
togglePartyTokens: DHTokenHUD.#togglePartyTokens
togglePartyTokens: DHTokenHUD.#togglePartyTokens,
toggleCompanions: DHTokenHUD.#toggleCompanions
}
};
@ -26,7 +27,7 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
context.partyOnCanvas =
this.actor.type === 'party' &&
this.actor.system.partyMembers.some(member => member.getActiveTokens().length > 0);
context.icons.toggleParty = 'systems/daggerheart/assets/icons/arrow-dunk.png';
context.icons.toggleClowncar = 'systems/daggerheart/assets/icons/arrow-dunk.png';
context.actorType = this.actor.type;
context.usesEffects = this.actor.type !== 'party';
context.canToggleCombat = DHTokenHUD.#nonCombatTypes.includes(this.actor.type)
@ -56,6 +57,9 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
}, {})
: null;
context.hasCompanion = this.actor.system.companion;
context.companionOnCanvas = context.hasCompanion && this.actor.system.companion.getActiveTokens().length > 0;
return context;
}
@ -101,8 +105,24 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
: 'DAGGERHEART.APPLICATIONS.HUD.tokenHUD.depositPartyTokens'
);
await this.toggleClowncar(this.actor.system.partyMembers);
}
static async #toggleCompanions(_, button) {
const icon = button.querySelector('img');
icon.classList.toggle('flipped');
button.dataset.tooltip = game.i18n.localize(
icon.classList.contains('flipped')
? 'DAGGERHEART.APPLICATIONS.HUD.tokenHUD.retrieveCompanionTokens'
: 'DAGGERHEART.APPLICATIONS.HUD.tokenHUD.depositCompanionTokens'
);
await this.toggleClowncar([this.actor.system.companion]);
}
async toggleClowncar(actors) {
const animationDuration = 500;
const activeTokens = this.actor.system.partyMembers.flatMap(member => member.getActiveTokens());
const activeTokens = actors.flatMap(member => member.getActiveTokens());
const { x: actorX, y: actorY } = this.document;
if (activeTokens.length > 0) {
for (let token of activeTokens) {
@ -114,14 +134,15 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
}
} else {
const activeScene = game.scenes.find(x => x.id === game.user.viewedScene);
const partyTokenData = [];
for (let member of this.actor.system.partyMembers) {
const tokenData = [];
for (let member of actors) {
const data = await member.getTokenDocument();
partyTokenData.push(data.toObject());
tokenData.push(data.toObject());
}
const newTokens = await activeScene.createEmbeddedDocuments(
'Token',
partyTokenData.map(tokenData => ({
tokenData.map(tokenData => ({
...tokenData,
alpha: 0,
x: actorX,

View file

@ -1,6 +1,6 @@
import BaseLevelUp from './levelup.mjs';
import { defaultCompanionTier, LevelOptionType } from '../../data/levelTier.mjs';
import { DhLevelup } from '../../data/levelup.mjs';
import { DhCompanionLevelup as DhLevelup } from '../../data/companionLevelup.mjs';
import { diceTypes, range } from '../../config/generalConfig.mjs';
export default class DhCompanionLevelUp extends BaseLevelUp {
@ -9,7 +9,9 @@ export default class DhCompanionLevelUp extends BaseLevelUp {
this.levelTiers = this.addBonusChoices(defaultCompanionTier);
const playerLevelupData = actor.system.levelData;
this.levelup = new DhLevelup(DhLevelup.initializeData(this.levelTiers, playerLevelupData));
this.levelup = new DhLevelup(
DhLevelup.initializeData(this.levelTiers, playerLevelupData, actor.system.levelupChoicesLeft)
);
}
async _preparePartContext(partId, context) {

View file

@ -70,7 +70,10 @@ export default class DhlevelUpViewMode extends HandlebarsApplicationMixin(Applic
return checkbox;
});
let label = game.i18n.localize(option.label);
let label =
optionKey === 'domainCard'
? game.i18n.format(option.label, { maxLevel: tier.levels.end })
: game.i18n.localize(option.label);
return {
label: label,
checkboxGroups: chunkify(checkboxes, option.minCost, chunkedBoxes => {

View file

@ -5,10 +5,7 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
super(options);
Hooks.on(socketEvent.Refresh, ({ refreshType }) => {
if (refreshType === RefreshType.Scene) {
this.daggerheartFlag = new game.system.api.data.scenes.DHScene(this.document.flags.daggerheart);
this.render();
}
if (refreshType === RefreshType.Scene) this.render();
});
}
@ -42,7 +39,9 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
async _preRender(context, options) {
await super._preFirstRender(context, options);
this.daggerheartFlag = new game.system.api.data.scenes.DHScene(this.document.flags.daggerheart);
if (!options.internalRefresh)
this.daggerheartFlag = new game.system.api.data.scenes.DHScene(this.document.flags.daggerheart);
}
_attachPartListeners(partId, htmlElement, options) {
@ -52,7 +51,7 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
case 'dh':
htmlElement.querySelector('#rangeMeasurementSetting')?.addEventListener('change', async event => {
this.daggerheartFlag.updateSource({ rangeMeasurement: { setting: event.target.value } });
this.render();
this.render({ internalRefresh: true });
});
const dragArea = htmlElement.querySelector('.scene-environments');
@ -66,10 +65,17 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
const item = await foundry.utils.fromUuid(data.uuid);
if (item instanceof game.system.api.documents.DhpActor && item.type === 'environment') {
let sceneUuid = data.uuid;
if (item.pack) {
const inWorldActor = await game.system.api.documents.DhpActor.create([item.toObject()]);
if (!inWorldActor.length) return;
sceneUuid = inWorldActor[0].uuid;
}
await this.daggerheartFlag.updateSource({
sceneEnvironments: [...this.daggerheartFlag.sceneEnvironments, data.uuid]
sceneEnvironments: [...this.daggerheartFlag.sceneEnvironments, sceneUuid]
});
this.render();
this.render({ internalRefresh: true });
}
}
@ -92,12 +98,16 @@ export default class DhSceneConfigSettings extends foundry.applications.sheets.S
(_, index) => index !== Number.parseInt(button.dataset.index)
)
});
this.render();
this.render({ internalRefresh: true });
}
/** @override */
async _processSubmitData(event, form, submitData, options) {
submitData.flags.daggerheart = this.daggerheartFlag.toObject();
submitData.flags.daggerheart.sceneEnvironments = submitData.flags.daggerheart.sceneEnvironments.filter(x =>
foundry.utils.fromUuidSync(x)
);
for (const key of Object.keys(this.document._source.flags.daggerheart?.sceneEnvironments ?? {})) {
if (!submitData.flags.daggerheart.sceneEnvironments[key]) {
submitData.flags.daggerheart.sceneEnvironments[`-=${key}`] = null;

View file

@ -36,7 +36,8 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
addItem: this.addItem,
editItem: this.editItem,
removeItem: this.removeItem,
resetMoves: this.resetMoves,
resetDowntimeMoves: this.resetDowntimeMoves,
resetItemFeatures: this.resetItemFeatures,
addDomain: this.addDomain,
toggleSelectedDomain: this.toggleSelectedDomain,
deleteDomain: this.deleteDomain,
@ -232,7 +233,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
static async resetMoves(_, target) {
static async resetDowntimeMoves(_, target) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.SETTINGS.Homebrew.resetMovesTitle', {
@ -266,7 +267,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
...move,
name: game.i18n.localize(move.name),
description: game.i18n.localize(move.description),
actions: move.actions.reduce((acc, key) => {
actions: Object.keys(move.actions).reduce((acc, key) => {
const action = move.actions[key];
acc[key] = {
...action,
@ -293,6 +294,31 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
static async resetItemFeatures(_, target) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.SETTINGS.Homebrew.resetItemFeaturesTitle', {
type: game.i18n.localize(`DAGGERHEART.GENERAL.${target.dataset.type}`)
})
},
content: game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.resetMovesText')
});
if (!confirmed) return;
await this.settings.updateSource({
[`itemFeatures.${target.dataset.type}`]: Object.keys(
this.settings.itemFeatures[target.dataset.type]
).reduce((acc, key) => {
acc[`-=${key}`] = null;
return acc;
}, {})
});
this.render();
}
static async addDomain(event) {
event.preventDefault();
const content = new foundry.data.fields.StringField({

View file

@ -31,6 +31,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
editEffect: this.editEffect,
addDamage: this.addDamage,
removeDamage: this.removeDamage,
editDoc: this.editDoc,
addTrigger: this.addTrigger,
removeTrigger: this.removeTrigger,
expandTrigger: this.expandTrigger
@ -39,7 +40,8 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
handler: this.updateForm,
submitOnChange: true,
closeOnSubmit: false
}
},
dragDrop: [{ dragSelector: null, dropSelector: '#summon-drop-zone', handlers: ['_onDrop'] }]
};
static PARTS = {
@ -101,7 +103,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
}
};
static CLEAN_ARRAYS = ['damage.parts', 'cost', 'effects'];
static CLEAN_ARRAYS = ['damage.parts', 'cost', 'effects', 'summon'];
_getTabs(tabs) {
for (const v of Object.values(tabs)) {
@ -112,9 +114,25 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
return tabs;
}
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
htmlElement.querySelectorAll('.summon-count-wrapper input').forEach(element => {
element.addEventListener('change', this.updateSummonCount.bind(this));
});
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options, 'action');
context.source = this.action.toObject(true);
context.action = this.action;
context.summons = [];
for (const summon of context.source.summon ?? []) {
const actor = await foundry.utils.fromUuid(summon.actorUUID);
context.summons.push({ actor, count: summon.count });
}
context.openSection = this.openSection;
context.tabs = this._getTabs(this.constructor.TABS);
context.config = CONFIG.DH;
@ -207,8 +225,9 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
}
static async updateForm(event, _, formData) {
const submitData = this._prepareSubmitData(event, formData),
data = foundry.utils.mergeObject(this.action.toObject(), submitData);
const submitData = this._prepareSubmitData(event, formData);
const data = foundry.utils.mergeObject(this.action.toObject(), submitData);
this.action = await this.action.update(data);
this.sheetUpdate?.(this.action);
@ -227,12 +246,26 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
static removeElement(event, button) {
event.stopPropagation();
const data = this.action.toObject(),
key = event.target.closest('[data-key]').dataset.key,
index = button.dataset.index;
key = event.target.closest('[data-key]').dataset.key;
// Prefer explicit index, otherwise find by uuid
let index = button?.dataset.index;
if (index === undefined || index === null || index === '') {
const uuid = button?.dataset.uuid ?? button?.dataset.itemUuid;
index = data[key].findIndex(e => (e?.actorUUID ?? e?.uuid) === uuid);
if (index === -1) return;
} else index = Number(index);
data[key].splice(index, 1);
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
static async editDoc(_event, target) {
const element = target.closest('[data-item-uuid]');
const doc = (await foundry.utils.fromUuid(element.dataset.itemUuid)) ?? null;
if (doc) return doc.sheet.render({ force: true });
}
static addDamage(_event) {
if (!this.action.damage.parts) return;
const data = this.action.toObject(),
@ -304,6 +337,15 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
}
}
updateSummonCount(event) {
event.stopPropagation();
const wrapper = event.target.closest('.summon-count-wrapper');
const index = wrapper.dataset.index;
const data = this.action.toObject();
data.summon[index].count = event.target.value;
this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(data) });
}
/** Specific implementation in extending classes **/
static async addEffect(_event) {}
static removeEffect(_event, _button) {}
@ -313,4 +355,29 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
this.tabGroups.primary = 'base';
await super.close(options);
}
async _onDrop(event) {
const data = foundry.applications.ux.TextEditor.getDragEventData(event);
const item = await foundry.utils.fromUuid(data.uuid);
if (!(item instanceof game.system.api.documents.DhpActor)) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.summon.invalidDrop'));
return;
}
const actionData = this.action.toObject();
let countvalue = 1;
for (const entry of actionData.summon) {
if (entry.actorUUID === data.uuid) {
entry.count += 1;
countvalue = entry.count;
await this.constructor.updateForm.bind(this)(null, null, {
object: foundry.utils.flattenObject(actionData)
});
return;
}
}
actionData.summon.push({ actorUUID: data.uuid, count: countvalue });
await this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(actionData) });
}
}

View file

@ -1,3 +1,4 @@
export * as actors from './actors/_module.mjs';
export * as api from './api/_modules.mjs';
export * as items from './items/_module.mjs';
export * as rollTables from './rollTables/_module.mjs';

View file

@ -31,7 +31,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
dropSelector: null
}
],
]
};
static PARTS = {
@ -185,7 +185,6 @@ export default class AdversarySheet extends DHBaseActorSheet {
super._onDragStart(event);
}
/* -------------------------------------------- */
/* Application Clicks Actions */
/* -------------------------------------------- */

View file

@ -1,5 +1,5 @@
import DHBaseActorSheet from '../api/base-actor.mjs';
import DhpDeathMove from '../../dialogs/deathMove.mjs';
import DhDeathMove from '../../dialogs/deathMove.mjs';
import { abilities } from '../../../config/actorConfig.mjs';
import { CharacterLevelup, LevelupViewMode } from '../../levelup/_module.mjs';
import DhCharacterCreation from '../../characterCreation/characterCreation.mjs';
@ -27,6 +27,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
makeDeathMove: CharacterSheet.#makeDeathMove,
levelManagement: CharacterSheet.#levelManagement,
viewLevelups: CharacterSheet.#viewLevelups,
resetCharacter: CharacterSheet.#resetCharacter,
toggleEquipItem: CharacterSheet.#toggleEquipItem,
toggleResourceDice: CharacterSheet.#toggleResourceDice,
handleResourceDice: CharacterSheet.#handleResourceDice,
@ -42,6 +43,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
icon: 'fa-solid fa-angles-up',
label: 'DAGGERHEART.ACTORS.Character.viewLevelups',
action: 'viewLevelups'
},
{
icon: 'fa-solid fa-arrow-rotate-left',
label: 'DAGGERHEART.ACTORS.Character.resetCharacter',
action: 'resetCharacter'
}
]
},
@ -224,13 +230,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
async _preparePartContext(partId, context, options) {
context = await super._preparePartContext(partId, context, options);
switch (partId) {
case 'header':
const { playerCanEditSheet, levelupAuto } = game.settings.get(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.Automation
);
context.showSettings = game.user.isGM || !levelupAuto || (levelupAuto && playerCanEditSheet);
break;
case 'loadout':
await this._prepareLoadoutContext(context, options);
break;
@ -679,12 +678,19 @@ export default class CharacterSheet extends DHBaseActorSheet {
new LevelupViewMode(this.document).render({ force: true });
}
/**
* Resets the character data and removes all embedded documents.
*/
static async #resetCharacter() {
new game.system.api.applications.dialogs.CharacterResetDialog(this.document).render({ force: true });
}
/**
* Opens the Death Move interface for the character.
* @type {ApplicationClickAction}
*/
static async #makeDeathMove() {
await new DhpDeathMove(this.document).render({ force: true });
await new DhDeathMove(this.document).render({ force: true });
}
/**
@ -725,8 +731,10 @@ export default class CharacterSheet extends DHBaseActorSheet {
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: abilityLabel
}),
effects: await game.system.api.data.actions.actionsTypes.base.getEffects(this.document),
roll: {
trait: button.dataset.attribute
trait: button.dataset.attribute,
type: 'trait'
},
hasRoll: true,
actionType: 'action',
@ -736,11 +744,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
})
};
const result = await this.document.diceRoll(config);
if (!result) return;
/* This could be avoided by baking config.costs into config.resourceUpdates. Didn't feel like messing with it at the time */
const costResources = result.costs
.filter(x => x.enabled)
.map(cost => ({ ...cost, value: -cost.value, total: -cost.total }));
const costResources =
result.costs?.filter(x => x.enabled).map(cost => ({ ...cost, value: -cost.value, total: -cost.total })) ||
{};
config.resourceUpdates.addResources(costResources);
await config.resourceUpdates.updateResources();
}
@ -840,7 +849,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
static async #toggleVault(_event, button) {
const doc = await getDocFromElement(button);
const { available } = this.document.system.loadoutSlot;
if (doc.system.inVault && !available) {
if (doc.system.inVault && !available && !doc.system.loadoutIgnore) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached'));
}
@ -971,6 +980,18 @@ export default class CharacterSheet extends DHBaseActorSheet {
return this._onSidebarDrop(event, item);
}
const setupCriticalItemTypes = ['class', 'subclass', 'ancestry', 'community'];
if (this.document.system.needsCharacterSetup && setupCriticalItemTypes.includes(item.type)) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.localize('DAGGERHEART.APPLICATIONS.CharacterCreation.setupSkipTitle')
},
content: game.i18n.localize('DAGGERHEART.APPLICATIONS.CharacterCreation.setupSkipContent')
});
if (!confirmed) return;
}
if (this.document.uuid === item.parent?.uuid) {
return super._onDropItem(event, item);
}

View file

@ -38,15 +38,6 @@ export default class DhCompanionSheet extends DHBaseActorSheet {
}
};
/** @inheritDoc */
async _onRender(context, options) {
await super._onRender(context, options);
this.element
.querySelector('.level-value')
?.addEventListener('change', event => this.document.updateLevel(Number(event.currentTarget.value)));
}
/* -------------------------------------------- */
/* Application Clicks Actions */
/* -------------------------------------------- */
@ -71,10 +62,10 @@ export default class DhCompanionSheet extends DHBaseActorSheet {
title: `${game.i18n.localize('DAGGERHEART.GENERAL.Roll.action')}: ${this.actor.name}`,
headerTitle: `Companion ${game.i18n.localize('DAGGERHEART.GENERAL.Roll.action')}`,
roll: {
trait: partner.system.spellcastModifierTrait?.key
trait: partner.system.spellcastModifierTrait?.key,
companionRoll: true
},
hasRoll: true,
data: partner.getRollData()
hasRoll: true
};
const result = await partner.diceRoll(config);

View file

@ -505,6 +505,10 @@ export default function DHApplicationMixin(Base) {
const doc = await getDocFromElement(target),
action = doc?.system?.attack ?? doc;
const config = action.prepareConfig(event);
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(
this.document,
doc
);
config.hasRoll = false;
return action && action.workflow.get('damage').execute(config, null, true);
}
@ -629,7 +633,7 @@ export default function DHApplicationMixin(Base) {
{
relativeTo: isAction ? doc.parent : doc,
rollData: doc.getRollData?.(),
secrets: isAction ? doc.parent.isOwner : doc.isOwner
secrets: isAction ? doc.parent.parent.isOwner : doc.isOwner
}
);
}

View file

@ -0,0 +1 @@
export { default as RollTableSheet } from './rollTable.mjs';

View file

@ -0,0 +1,191 @@
export default class DhRollTableSheet extends foundry.applications.sheets.RollTableSheet {
static DEFAULT_OPTIONS = {
...super.DEFAULT_OPTIONS,
actions: {
changeMode: DhRollTableSheet.#onChangeMode,
drawResult: DhRollTableSheet.#onDrawResult,
resetResults: DhRollTableSheet.#onResetResults,
addFormula: DhRollTableSheet.#addFormula,
removeFormula: DhRollTableSheet.#removeFormula
}
};
static buildParts() {
const { footer, header, sheet, results, ...parts } = super.PARTS;
return {
sheet: {
...sheet,
template: 'systems/daggerheart/templates/sheets/rollTable/sheet.hbs'
},
header: { template: 'systems/daggerheart/templates/sheets/rollTable/header.hbs' },
...parts,
results: {
template: 'systems/daggerheart/templates/sheets/rollTable/results.hbs',
templates: ['templates/sheets/roll-table/result-details.hbs'],
scrollable: ['table[data-results] tbody']
},
summary: { template: 'systems/daggerheart/templates/sheets/rollTable/summary.hbs' },
footer
};
}
static PARTS = DhRollTableSheet.buildParts();
async _preRender(context, options) {
await super._preRender(context, options);
if (!options.internalRefresh)
this.daggerheartFlag = new game.system.api.data.DhRollTable(this.document.flags.daggerheart);
}
/* root PART has a blank element on _attachPartListeners, so it cannot be used to set the eventListeners for the view mode */
async _onRender(context, options) {
super._onRender(context, options);
for (const element of this.element.querySelectorAll('.system-update-field'))
element.addEventListener('change', this.updateSystemField.bind(this));
}
async _preparePartContext(partId, context, options) {
context = await super._preparePartContext(partId, context, options);
switch (partId) {
case 'sheet':
context.altFormula = this.daggerheartFlag.altFormula;
context.usesAltFormula = Object.keys(this.daggerheartFlag.altFormula).length > 0;
context.altFormulaOptions = {
'': { name: this.daggerheartFlag.formulaName },
...this.daggerheartFlag.altFormula
};
context.activeAltFormula = this.daggerheartFlag.activeAltFormula;
context.selectedFormula = this.daggerheartFlag.getActiveFormula(this.document.formula);
context.results = this.getExtendedResults(context.results);
break;
case 'header':
context.altFormula = this.daggerheartFlag.altFormula;
context.usesAltFormula = Object.keys(this.daggerheartFlag.altFormula).length > 0;
context.altFormulaOptions = {
'': { name: this.daggerheartFlag.formulaName },
...this.daggerheartFlag.altFormula
};
context.activeAltFormula = this.daggerheartFlag.activeAltFormula;
break;
case 'summary':
context.systemFields = this.daggerheartFlag.schema.fields;
context.altFormula = this.daggerheartFlag.altFormula;
context.formulaName = this.daggerheartFlag.formulaName;
break;
case 'results':
context.results = this.getExtendedResults(context.results);
break;
}
return context;
}
getExtendedResults(results) {
const bodyDarkMode = document.body.classList.contains('theme-dark');
const elementLightMode = this.element.classList.contains('theme-light');
const elementDarkMode = this.element.classList.contains('theme-dark');
const isDarkMode = elementDarkMode || (!elementLightMode && bodyDarkMode);
return results.map(x => ({
...x,
displayImg: isDarkMode && x.img === 'icons/svg/d20-black.svg' ? 'icons/svg/d20.svg' : x.img
}));
}
/* -------------------------------------------- */
/* Flag SystemData update methods */
/* -------------------------------------------- */
async updateSystemField(event) {
const { dataset, value } = event.target;
await this.daggerheartFlag.updateSource({ [dataset.path]: value });
this.render({ internalRefresh: true });
}
getSystemFlagUpdate() {
const deleteUpdate = Object.keys(this.document._source.flags.daggerheart?.altFormula ?? {}).reduce(
(acc, formulaKey) => {
if (!this.daggerheartFlag.altFormula[formulaKey]) acc.altFormula[`-=${formulaKey}`] = null;
return acc;
},
{ altFormula: {} }
);
return { ['flags.daggerheart']: foundry.utils.mergeObject(this.daggerheartFlag.toObject(), deleteUpdate) };
}
static async #addFormula() {
await this.daggerheartFlag.updateSource({
[`altFormula.${foundry.utils.randomID()}`]: game.system.api.data.DhRollTable.getDefaultFormula()
});
this.render({ internalRefresh: true });
}
static async #removeFormula(_event, target) {
await this.daggerheartFlag.updateSource({
[`altFormula.-=${target.dataset.key}`]: null
});
this.render({ internalRefresh: true });
}
/* -------------------------------------------- */
/* Extended RollTable methods */
/* -------------------------------------------- */
/**
* Alternate between view and edit modes.
* @this {RollTableSheet}
* @type {ApplicationClickAction}
*/
static async #onChangeMode() {
this.mode = this.isEditMode ? 'view' : 'edit';
await this.document.update(this.getSystemFlagUpdate());
await this.render({ internalRefresh: true });
}
/** @inheritdoc */
async _processSubmitData(event, form, submitData, options) {
/* RollTable sends an empty dummy event when swapping from view/edit first time */
if (Object.keys(submitData).length) {
if (!submitData.flags) submitData.flags = { daggerheart: {} };
submitData.flags.daggerheart = this.getSystemFlagUpdate();
}
super._processSubmitData(event, form, submitData, options);
}
/** @inheritdoc */
static async #onResetResults() {
await this.document.update(this.getSystemFlagUpdate());
await this.document.resetResults();
}
/**
* Roll and draw a TableResult.
* @this {RollTableSheet}
* @type {ApplicationClickAction}
*/
static async #onDrawResult(_event, button) {
if (this.form) await this.submit({ operation: { render: false } });
button.disabled = true;
const table = this.document;
await this.document.update(this.getSystemFlagUpdate());
/* Sending in the currently selectd activeFormula to table.roll to use as the formula */
const selectedFormula = this.daggerheartFlag.getActiveFormula(this.document.formula);
const tableRoll = await table.roll({ selectedFormula });
const draws = table.getResultsForRoll(tableRoll.roll.total);
if (draws.length > 0) {
if (game.settings.get('core', 'animateRollTable')) await this._animateRoll(draws);
await table.draw(tableRoll);
}
// Reenable the button if drawing with replacement since the draw won't trigger a sheet re-render
if (table.replacement) button.disabled = false;
}
}

View file

@ -25,7 +25,7 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
/** @override */
static DEFAULT_OPTIONS = {
classes: ['dh-style'],
classes: ['dh-style', 'directory'],
window: {
title: 'SIDEBAR.TabSettings'
},

View file

@ -81,6 +81,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
html.querySelectorAll('.group-roll-header-expand-section').forEach(element =>
element.addEventListener('click', this.groupRollExpandSection)
);
html.querySelectorAll('.risk-it-all-button').forEach(element =>
element.addEventListener('click', event => this.riskItAllClearStressAndHitPoints(event, data))
);
};
setupHooks() {
@ -92,6 +95,21 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
super.close(options);
}
/** Ensure the chat theme inherits the interface theme */
_replaceHTML(result, content, options) {
const themedElement = result.log?.querySelector('.chat-log');
themedElement?.classList.remove('themed', 'theme-light', 'theme-dark');
super._replaceHTML(result, content, options);
}
/** Remove chat log theme from notifications area */
async _onFirstRender(result, content) {
await super._onFirstRender(result, content);
document
.querySelector('#chat-notifications .chat-log')
?.classList.remove('themed', 'theme-light', 'theme-dark');
}
async onRollSimple(event, message) {
const buttonType = event.target.dataset.type ?? 'damage',
total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0),
@ -135,7 +153,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
async actionUseButton(event, message) {
const { moveIndex, actionIndex, movePath } = event.currentTarget.dataset;
const targetUuid = event.currentTarget.closest('.action-use-button-parent').querySelector('select')?.value;
const parent = await foundry.utils.fromUuid(targetUuid || message.system.actor)
const parent = await foundry.utils.fromUuid(targetUuid || message.system.actor);
const actionType = message.system.moves[moveIndex].actions[actionIndex];
const cls = game.system.api.models.actions.actionsTypes[actionType.type];
@ -370,4 +388,10 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
});
event.target.closest('.group-roll-section').querySelector('.group-roll-content').classList.toggle('closed');
}
async riskItAllClearStressAndHitPoints(event, data) {
const resourceValue = event.target.dataset.resourceValue;
const actor = game.actors.get(event.target.dataset.actorId);
new game.system.api.applications.dialogs.RiskItAllDialog(actor, resourceValue).render({ force: true });
}
}

View file

@ -42,8 +42,8 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
this.combats
.find(x => x.active)
?.system?.extendedBattleToggles?.reduce((acc, toggle) => (acc ?? 0) + toggle.category, null) ?? null;
const maxBP = CONFIG.DH.ENCOUNTER.BaseBPPerEncounter(context.characters.length) + modifierBP;
const currentBP = AdversaryBPPerEncounter(context.adversaries, context.characters);
const maxBP = CONFIG.DH.ENCOUNTER.BaseBPPerEncounter(context.allCharacters.length) + modifierBP;
const currentBP = AdversaryBPPerEncounter(context.adversaries, context.allCharacters);
Object.assign(context, {
fear: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear),
@ -73,9 +73,8 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
Object.assign(context, {
actionTokens: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).actionTokens,
adversaries,
characters: characters
?.filter(x => !x.isNPC)
.filter(x => !spotlightQueueEnabled || x.system.spotlight.requestOrderIndex == 0),
allCharacters: characters,
characters: characters.filter(x => !spotlightQueueEnabled || x.system.spotlight.requestOrderIndex == 0),
spotlightRequests
});
}

View file

@ -76,6 +76,8 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
};
toggleHidden(token, focused) {
if (!this.element) return;
const effects = DhEffectsDisplay.getTokenEffects(focused ? token : null);
this.element.hidden = effects.length === 0;

View file

@ -230,6 +230,14 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
result.flatMap(r => r),
'name'
);
/* If any noticeable slowdown occurs, consider replacing with enriching description on clicking to expand descriptions */
for (const item of this.items) {
item.system.enrichedDescription =
(await item.system.getEnrichedDescription?.()) ??
(await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.description));
}
this.fieldFilter = this._createFieldFilter();
if (this.presets?.filter) {

View file

@ -31,7 +31,7 @@ export default class DhSceneNavigation extends foundry.applications.ui.SceneNavi
const environments = daggerheartInfo.sceneEnvironments.filter(
x => x && x.testUserPermission(game.user, 'LIMITED')
);
const hasEnvironments = environments.length > 0;
const hasEnvironments = environments.length > 0 && x.isView;
return {
...x,
hasEnvironments,