Merge branch 'main' into refactor/275-actor-sheets-simplification

This commit is contained in:
joaquinpereyra98 2025-07-07 17:16:47 -03:00 committed by GitHub
commit 17a9630736
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 358 additions and 251 deletions

View file

@ -63,18 +63,6 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
const context = await super._prepareContext(_options);
context.rollConfig = this.config;
context.hasRoll = !!this.config.roll;
context.roll = this.roll;
context.rollType = this.roll?.constructor.name;
context.experiences = Object.keys(this.config.data.experiences).map(id => ({
id,
...this.config.data.experiences[id]
}));
context.selectedExperiences = this.config.experiences;
context.advantage = this.config.roll?.advantage;
context.disadvantage = this.config.roll?.disadvantage;
context.diceOptions = CONFIG.DH.GENERAL.diceTypes;
context.canRoll = true;
context.isLite = this.config.roll?.lite;
if (this.config.costs?.length) {
const updatedCosts = this.action.calcCosts(this.config.costs);
context.costs = updatedCosts;
@ -85,8 +73,22 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.uses = this.action.calcUses(this.config.uses);
context.canRoll = context.canRoll && this.action.hasUses(context.uses);
}
context.extraFormula = this.config.extraFormula;
context.formula = this.roll.constructFormula(this.config);
if(this.roll) {
context.roll = this.roll;
context.rollType = this.roll?.constructor.name;
context.experiences = Object.keys(this.config.data.experiences).map(id => ({
id,
...this.config.data.experiences[id]
}));
context.selectedExperiences = this.config.experiences;
context.advantage = this.config.roll?.advantage;
context.disadvantage = this.config.roll?.disadvantage;
context.diceOptions = CONFIG.DH.GENERAL.diceTypes;
context.canRoll = true;
context.isLite = this.config.roll?.lite;
context.extraFormula = this.config.extraFormula;
context.formula = this.roll.constructFormula(this.config);
}
return context;
}

View file

@ -108,7 +108,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
context.config = CONFIG.DH;
if (!!this.action.effects) context.effects = this.action.effects.map(e => this.action.item.effects.get(e._id));
if (this.action.damage?.hasOwnProperty('includeBase') && this.action.type === 'attack')
context.hasBaseDamage = !!this.action.parent.damage;
context.hasBaseDamage = !!this.action.parent.attack;
context.getRealIndex = this.getRealIndex.bind(this);
context.getEffectDetails = this.getEffectDetails.bind(this);
context.disableOption = this.disableOption.bind(this);

View file

@ -6,6 +6,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
static DEFAULT_OPTIONS = {
classes: ['adversary'],
position: { width: 660, height: 766 },
window: { resizable: true },
actions: {
reactionRoll: AdversarySheet.#reactionRoll,
useItem: this.useItem,

View file

@ -372,7 +372,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
li.hidden = !(menu.has(item.id) && matchesSearch);
}
}
/* -------------------------------------------- */
/* Filter Menus */
/* -------------------------------------------- */

View file

@ -37,7 +37,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
/** @inheritdoc */
static TABS = {
primary: {
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }],
tabs: [{ id: 'description' }, { id: 'settings' }, { id: 'actions' }],
initial: 'description',
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
}

View file

@ -31,13 +31,12 @@ export default class WeaponSheet extends DHBaseItemSheet {
/**@inheritdoc */
async _preparePartContext(partId, context) {
super._preparePartContext(partId, context);
switch (partId) {
case 'settings':
context.features = this.document.system.features.map(x => x.value);
context.systemFields.attack.fields = this.document.system.attack.schema.fields;
break;
}
return context;
}

View file

@ -79,7 +79,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
action =
actor.system.attack?._id === actionId
? actor.system.attack
: item?.system?.actions?.find(a => a._id === actionId);
: item.system.attack?._id === actionId
? item.system.attack
: item?.system?.actions?.find(a => a._id === actionId);
return action;
}
@ -158,7 +160,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
const targetSelection = event.target
.closest('.message-content')
.querySelector('.button-target-selection.target-selected'),
isHit = Boolean(targetSelection.dataset.targetHit);
isHit = Boolean(targetSelection?.dataset?.targetHit) ?? false;
return {
isHit,
targets: isHit

View file

@ -65,6 +65,20 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
];
}
async setCombatantSpotlight(combatantId) {
const combatant = this.viewed.combatants.get(combatantId);
const toggleTurn = this.viewed.combatants.contents
.sort(this.viewed._sortCombatants)
.map(x => x.id)
.indexOf(combatantId);
if (this.viewed.turn !== toggleTurn) Hooks.callAll(CONFIG.DH.HOOKS.spotlight, {});
await this.viewed.update({ turn: this.viewed.turn === toggleTurn ? null : toggleTurn });
await combatant.update({ 'system.spotlight.requesting': false });
}
static async requestSpotlight(_, target) {
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
const combatant = this.viewed.combatants.get(combatantId);
@ -79,17 +93,7 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
static async toggleSpotlight(_, target) {
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
const combatant = this.viewed.combatants.get(combatantId);
const toggleTurn = this.viewed.combatants.contents
.sort(this.viewed._sortCombatants)
.map(x => x.id)
.indexOf(combatantId);
if (this.viewed.turn !== toggleTurn) Hooks.callAll(CONFIG.DH.HOOKS.spotlight, {});
await this.viewed.update({ turn: this.viewed.turn === toggleTurn ? null : toggleTurn });
await combatant.update({ 'system.spotlight.requesting': false });
await this.setCombatantSpotlight(combatantId);
}
static async setActionTokens(_, target) {

View file

@ -13,7 +13,7 @@ class Countdowns extends HandlebarsApplicationMixin(ApplicationV2) {
}
get title() {
return game.i18n.format('DAGGERHEART.APPLICATIONS.Countdown.Title', {
return game.i18n.format('DAGGERHEART.APPLICATIONS.Countdown.title', {
type: game.i18n.localize(`DAGGERHEART.APPLICATIONS.Countdown.types.${this.basePath}`)
});
}

View file

@ -1,3 +1,5 @@
import { emitAsGM, GMUpdateEvent, socketEvent } from "../../systemRegistration/socket.mjs";
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
/**
@ -96,6 +98,7 @@ export default class FearTracker extends HandlebarsApplicationMixin(ApplicationV
}
static async increaseFear(event, target) {
if (!game.user.isGM) return;
let value = target.dataset.increment ?? 0,
operator = value.split('')[0] ?? null;
value = Number(value);
@ -103,8 +106,19 @@ export default class FearTracker extends HandlebarsApplicationMixin(ApplicationV
}
async updateFear(value) {
if (!game.user.isGM) return;
return emitAsGM(GMUpdateEvent.UpdateFear, game.settings.set.bind(game.settings, CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear), value);
/* if(!game.user.isGM)
await game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.GMUpdate,
data: {
action: GMUpdateEvent.UpdateFear,
update: value
}
});
else
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear, value); */
/* if (!game.user.isGM) return;
value = Math.max(0, Math.min(this.maxFear, value));
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear, value);
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear, value); */
}
}