From 72dfc5470581b15e658393a0481fd0af9990c065 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 3 Jul 2025 20:54:52 +0200 Subject: [PATCH] Removed hardcoded tierlimit on beastform --- daggerheart.mjs | 1 + lang/en.json | 7 ++++++ .../applications/sheets/actors/character.mjs | 8 ++++++- module/data/action/action.mjs | 24 ++++++++++++++----- module/dialogs/beastformDialog.mjs | 3 +-- .../sheets/global/partials/inventory-item.hbs | 2 +- templates/views/action.hbs | 3 ++- templates/views/actionTypes/beastform.hbs | 12 ++++++++++ 8 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 templates/views/actionTypes/beastform.hbs diff --git a/daggerheart.mjs b/daggerheart.mjs index 47c53fe4..1b7be686 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -303,6 +303,7 @@ const preloadHandlebarsTemplates = async function () { 'systems/daggerheart/templates/views/actionTypes/cost.hbs', 'systems/daggerheart/templates/views/actionTypes/range-target.hbs', 'systems/daggerheart/templates/views/actionTypes/effect.hbs', + 'systems/daggerheart/templates/views/actionTypes/beastform.hbs', 'systems/daggerheart/templates/settings/components/settings-item-line.hbs', 'systems/daggerheart/templates/chat/parts/damage-chat.hbs', 'systems/daggerheart/templates/chat/parts/target-chat.hbs' diff --git a/lang/en.json b/lang/en.json index 3cea26a4..49f696ca 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1662,6 +1662,13 @@ "ResultBased": { "label": "Formula based on Hope/Fear result." } + }, + "Config": { + "Beastform": { + "label": "Beastform", + "exact": "Exact", + "exactPlaceholder": "Character tier is used" + } } }, "RollTypes": { diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index ec957651..10791435 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -7,6 +7,8 @@ import { abilities } from '../../../config/actorConfig.mjs'; import DhCharacterlevelUp from '../../levelup/characterLevelup.mjs'; import DhCharacterCreation from '../../characterCreation.mjs'; import FilterMenu from '../../ux/filter-menu.mjs'; +import { DhBeastformAction } from '../../../data/action/action.mjs'; +import DHActionConfig from '../../config/Action.mjs'; const { ActorSheetV2 } = foundry.applications.sheets; const { TextEditor } = foundry.applications.ux; @@ -751,7 +753,11 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) { const item = this.getItem(event); if (!item) return; - item.sheet.render(true); + if (item.sheet) { + item.sheet.render(true); + } else { + await new DHActionConfig(item).render(true); + } } editItem(event) { diff --git a/module/data/action/action.mjs b/module/data/action/action.mjs index ea1d17f4..bf06a10c 100644 --- a/module/data/action/action.mjs +++ b/module/data/action/action.mjs @@ -107,6 +107,11 @@ export class DHBaseAction extends foundry.abstract.DataModel { }), value: new fields.EmbeddedDataField(DHActionDiceData), valueAlt: new fields.EmbeddedDataField(DHActionDiceData) + }), + beastform: new fields.SchemaField({ + tierAccess: new fields.SchemaField({ + exact: new fields.NumberField({ integer: true, nullable: true, initial: null }) + }) }) }, extraSchemas = {}; @@ -271,6 +276,8 @@ export class DHBaseAction extends foundry.abstract.DataModel { } if (this instanceof DhBeastformAction) { + config.beastform = this.prepareBeastformConfig(); + const abort = await this.handleActiveTransformations(); if (abort) return; @@ -770,13 +777,18 @@ export class DHMacroAction extends DHBaseAction { } export class DhBeastformAction extends DHBaseAction { - static defineSchema() { + static extraSchemas = ['beastform']; + + prepareBeastformConfig(config) { + const settingsTier = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers).tiers; + const actorLevel = this.actor.system.levelData.level.current; + const actorTier = + Object.values(settingsTier).find( + tier => actorLevel >= tier.levels.start && actorLevel <= tier.levels.end + ) ?? 1; + return { - ...super.defineSchema(), - tierAccess: new fields.SchemaField({ - exact: new fields.NumberField({ integer: true, nullable: true, initial: null }), - characterBased: new fields.BooleanField({ initial: true }) - }) + tierLimit: this.beastform.tierAccess.exact ?? actorTier }; } diff --git a/module/dialogs/beastformDialog.mjs b/module/dialogs/beastformDialog.mjs index 4bb606ef..d9c5d4b4 100644 --- a/module/dialogs/beastformDialog.mjs +++ b/module/dialogs/beastformDialog.mjs @@ -44,10 +44,9 @@ export default class BeastformDialog extends HandlebarsApplicationMixin(Applicat const context = await super._prepareContext(_options); context.configData = this.configData; - const tierLimit = 2; context.beastformTiers = game.items.reduce((acc, x) => { const tier = tiers[x.system.tier]; - if (x.type !== 'beastform' || tier.value > tierLimit) return acc; + if (x.type !== 'beastform' || tier.value > context.configData.beastform.tierLimit) return acc; if (!acc[tier.value]) acc[tier.value] = { label: game.i18n.localize(tier.label), values: {} }; acc[tier.value].values[x.uuid] = { selected: this.selected == x.uuid, value: x }; diff --git a/templates/sheets/global/partials/inventory-item.hbs b/templates/sheets/global/partials/inventory-item.hbs index 9b1c392b..a774b332 100644 --- a/templates/sheets/global/partials/inventory-item.hbs +++ b/templates/sheets/global/partials/inventory-item.hbs @@ -1,4 +1,4 @@ -
  • +
  • {{#if isCompanion}} diff --git a/templates/views/action.hbs b/templates/views/action.hbs index 9a3a25b4..711094a5 100644 --- a/templates/views/action.hbs +++ b/templates/views/action.hbs @@ -44,7 +44,8 @@ {{#if fields.healing}}{{> 'systems/daggerheart/templates/views/actionTypes/healing.hbs' fields=fields.healing.fields source=source.healing}}{{/if}} {{#if fields.resource}}{{> 'systems/daggerheart/templates/views/actionTypes/resource.hbs' fields=fields.resource.fields source=source.resource}}{{/if}} {{#if fields.documentUUID}}{{> 'systems/daggerheart/templates/views/actionTypes/uuid.hbs' fields=fields.documentUUID source=source.documentUUID}}{{/if}} - {{#if fields.effects}}{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs' fields=fields.effects.element.fields source=source.effects}}{{/if}} + {{#if fields.effects}}{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs' fields=fields.effects.element.fields source=source.effects}}{{/if}} + {{#if fields.beastform}}{{> 'systems/daggerheart/templates/views/actionTypes/beastform.hbs' fields=fields.effects.element.fields source=source.beastform}}{{/if}}
    \ No newline at end of file diff --git a/templates/views/actionTypes/beastform.hbs b/templates/views/actionTypes/beastform.hbs new file mode 100644 index 00000000..fa692927 --- /dev/null +++ b/templates/views/actionTypes/beastform.hbs @@ -0,0 +1,12 @@ +
    + +
    {{localize "DAGGERHEART.Actions.Config.Beastform.label"}}
    +
    + +
    + {{formGroup + @root.fields.beastform.fields.tierAccess.fields.exact value=@root.source.beastform.tierAccess.exact name="beastform.tierAccess.exact" + placeholder=(localize "DAGGERHEART.Actions.Config.Beastform.exactPlaceholder") label="DAGGERHEART.Actions.Config.Beastform.exact" localize=true + }} +
    +
    \ No newline at end of file