From cbd176d5bccf5b05b8ac25783de49eb2ad2c0c38 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:15:09 +0200 Subject: [PATCH 1/5] [Bug] Fixed Manual MaxHP (#532) * Set adversary buttosn to type=button. Fixed faulty _onUpdate * Fixed --- module/data/actor/adversary.mjs | 2 +- module/data/actor/character.mjs | 2 +- templates/sheets/actors/adversary/header.hbs | 2 +- templates/sheets/actors/adversary/sidebar.hbs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module/data/actor/adversary.mjs b/module/data/actor/adversary.mjs index 5ad855ed..5b83f3c7 100644 --- a/module/data/actor/adversary.mjs +++ b/module/data/actor/adversary.mjs @@ -144,7 +144,7 @@ export default class DhpAdversary extends BaseDataActor { super._onUpdate(changes, options, userId); if (game.user.id === userId) { - if (changes.system.type) { + if (changes.system?.type) { const existingHordeEffect = this.parent.effects.find(x => x.type === 'horde'); if (changes.system.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) { if (!existingHordeEffect) diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index 83311c96..f9f6e161 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -579,7 +579,7 @@ export default class DhCharacter extends BaseDataActor { : this.levelData.level.current * 2 }; this.resources.hope.max -= Object.keys(this.scars).length; - this.resources.hitPoints.max = this.class.value?.system?.hitPoints ?? 0; + this.resources.hitPoints.max += this.class.value?.system?.hitPoints ?? 0; } prepareDerivedData() { diff --git a/templates/sheets/actors/adversary/header.hbs b/templates/sheets/actors/adversary/header.hbs index 7adc1583..d1c325f6 100644 --- a/templates/sheets/actors/adversary/header.hbs +++ b/templates/sheets/actors/adversary/header.hbs @@ -36,7 +36,7 @@
{{> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}} -
diff --git a/templates/sheets/actors/adversary/sidebar.hbs b/templates/sheets/actors/adversary/sidebar.hbs index 55f8395e..1b6d65a5 100644 --- a/templates/sheets/actors/adversary/sidebar.hbs +++ b/templates/sheets/actors/adversary/sidebar.hbs @@ -114,6 +114,6 @@
- +
\ No newline at end of file From 1df0852df3cd9b0e21f7da353653eda6d63b5d6c Mon Sep 17 00:00:00 2001 From: Dapoulp <74197441+Dapoulp@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:32:04 +0200 Subject: [PATCH 2/5] Fix healing chat label (#533) --- templates/ui/chat/parts/damage-part.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ui/chat/parts/damage-part.hbs b/templates/ui/chat/parts/damage-part.hbs index c719c38c..d717166e 100644 --- a/templates/ui/chat/parts/damage-part.hbs +++ b/templates/ui/chat/parts/damage-part.hbs @@ -1,5 +1,5 @@
-
Damage
+
{{localize (ifThen hasHealing "DAGGERHEART.ACTIONS.TYPES.healing.name" "DAGGERHEART.ACTIONS.TYPES.damage.name")}}
{{#each damage as | roll index | }} From af40f9d712e7b4a869d467f8af5b4c08770ef4e4 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:33:21 +0200 Subject: [PATCH 3/5] Fixed so Adversary features can be sent to chat. Fixed so ability-card.hbs works again (#525) --- .../sheets/api/application-mixin.mjs | 2 +- module/applications/ui/chatLog.mjs | 24 ++++++++----------- module/documents/item.mjs | 9 ++++--- .../sheets/actors/adversary/features.hbs | 12 +++++----- .../partials/inventory-fieldset-items-V2.hbs | 1 + .../global/partials/inventory-item-V2.hbs | 2 ++ templates/ui/chat/ability-use.hbs | 4 ++-- 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index 452877e6..6b1819bf 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -480,7 +480,7 @@ export default function DHApplicationMixin(Base) { */ static async #toChat(_event, target) { let doc = await getDocFromElement(target); - return doc.toChat(this.document.id); + return doc.toChat(doc.uuid); } /** diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 2e9e711e..151b1cc5 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -117,9 +117,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo async onRollAllSave(event, message) { event.stopPropagation(); if (!game.user.isGM) return; - const targets = event.target.parentElement.querySelectorAll( - '[data-token] .target-save' - ); + const targets = event.target.parentElement.querySelectorAll('[data-token] .target-save'); const actor = await this.getActor(message.system.source.actor), action = this.getAction(actor, message.system.source.item, message.system.source.action); targets.forEach(async el => { @@ -169,9 +167,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo async onRollSimple(event, message) { const buttonType = event.target.dataset.type ?? 'damage', - total = message.rolls.reduce((a,c) => a + Roll.fromJSON(c).total, 0), + total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0), damages = { - 'hitPoints': { + hitPoints: { parts: [ { applyTo: 'hitPoints', @@ -186,20 +184,18 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo if (targets.length === 0) return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); - targets.forEach(target => { - if(buttonType === 'healing') - target.actor.takeHealing(damages); - else - target.actor.takeDamage(damages); - }) + targets.forEach(target => { + if (buttonType === 'healing') target.actor.takeHealing(damages); + else target.actor.takeDamage(damages); + }); } async abilityUseButton(event, message) { event.stopPropagation(); - const action = message.system.actions[Number.parseInt(event.currentTarget.dataset.index)]; - const actor = game.actors.get(message.system.source.actor); - await actor.use(action); + const item = await foundry.utils.fromUuid(message.system.origin); + const action = item.system.actions.get(event.currentTarget.id); + await item.use(action); } async actionUseButton(event, message) { diff --git a/module/documents/item.mjs b/module/documents/item.mjs index 3c074f44..ffafa401 100644 --- a/module/documents/item.mjs +++ b/module/documents/item.mjs @@ -132,6 +132,8 @@ export default class DHItem extends foundry.documents.Item { async toChat(origin) { const cls = getDocumentClass('ChatMessage'); + const item = await foundry.utils.fromUuid(origin); + const systemData = { title: this.type === 'ancestry' @@ -148,13 +150,14 @@ export default class DHItem extends foundry.documents.Item { img: this.img, tags: this._getTags() }, - description: this.system.description, - actions: this.system.actions + actions: item.system.actions, + description: this.system.description }; + const msg = { type: 'abilityUse', user: game.user.id, - actor: game.actors.get(cls.getSpeaker().actor), + actor: item.parent, author: this.author, speaker: cls.getSpeaker(), system: systemData, diff --git a/templates/sheets/actors/adversary/features.hbs b/templates/sheets/actors/adversary/features.hbs index e5a304ef..98c1cedb 100644 --- a/templates/sheets/actors/adversary/features.hbs +++ b/templates/sheets/actors/adversary/features.hbs @@ -2,12 +2,12 @@ data-group='{{tabs.features.group}}'>
{{> 'daggerheart.inventory-items' - title=tabs.features.label - type='feature' - collection=document.system.features - hideControls=true - canCreate=true - showActions=true + title=tabs.features.label + type='feature' + collection=document.system.features + hideContextMenu=true + canCreate=true + showActions=true }}
\ No newline at end of file diff --git a/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs b/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs index 29b008bb..cc030523 100644 --- a/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs +++ b/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs @@ -55,6 +55,7 @@ Parameters: item=item type=../type hideControls=../hideControls + hideContextMenu=../hideContextMenu isActor=../isActor categoryAdversary=../categoryAdversary hideTooltip=../hideTooltip diff --git a/templates/sheets/global/partials/inventory-item-V2.hbs b/templates/sheets/global/partials/inventory-item-V2.hbs index 318e4dcb..623b880e 100644 --- a/templates/sheets/global/partials/inventory-item-V2.hbs +++ b/templates/sheets/global/partials/inventory-item-V2.hbs @@ -123,9 +123,11 @@ Parameters: {{/if}} + {{#unless hideContextMenu}} + {{/unless}} {{/if}}
{{/unless}} diff --git a/templates/ui/chat/ability-use.hbs b/templates/ui/chat/ability-use.hbs index 30c5ebb9..0db5d5c8 100644 --- a/templates/ui/chat/ability-use.hbs +++ b/templates/ui/chat/ability-use.hbs @@ -15,8 +15,8 @@
{{{description}}}
- - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.features }} \ No newline at end of file diff --git a/templates/ui/tooltip/armor.hbs b/templates/ui/tooltip/armor.hbs index 8163feff..b2e07970 100644 --- a/templates/ui/tooltip/armor.hbs +++ b/templates/ui/tooltip/armor.hbs @@ -18,20 +18,4 @@
{{item.system.baseThresholds.severe}}
- - {{#if (gt item.system.armorFeatures.length 0)}}

{{localize "DAGGERHEART.GENERAL.features"}}

{{/if}} -
- {{#each item.system.armorFeatures}} - {{#with (lookup ../config.ITEM.armorFeatures this.value) as | feature | }} -
-
-
{{localize feature.label}}
-
-
{{{localize feature.description}}}
-
- {{/with}} - {{/each}} -
- - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.customActions isAction=true label=(localize "DAGGERHEART.GENERAL.Action.plural")}} \ No newline at end of file diff --git a/templates/ui/tooltip/beastform.hbs b/templates/ui/tooltip/beastform.hbs index 3afc0c84..fb07d895 100644 --- a/templates/ui/tooltip/beastform.hbs +++ b/templates/ui/tooltip/beastform.hbs @@ -2,7 +2,4 @@

{{item.name}}

{{{description}}}
- - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipChips.hbs" chips=item.system.advantageOn label=(localize "DAGGERHEART.ITEMS.Beastform.FIELDS.advantageOn.label")}} - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.features label=(localize "DAGGERHEART.GENERAL.features")}} \ No newline at end of file diff --git a/templates/ui/tooltip/consumable.hbs b/templates/ui/tooltip/consumable.hbs index e51ec255..d39cdfa6 100644 --- a/templates/ui/tooltip/consumable.hbs +++ b/templates/ui/tooltip/consumable.hbs @@ -9,6 +9,4 @@
{{item.system.quantity}}
- - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.actions isAction=true label=(localize "DAGGERHEART.GENERAL.Action.plural") }} \ No newline at end of file diff --git a/templates/ui/tooltip/domainCard.hbs b/templates/ui/tooltip/domainCard.hbs index fabc1671..c209f29d 100644 --- a/templates/ui/tooltip/domainCard.hbs +++ b/templates/ui/tooltip/domainCard.hbs @@ -26,6 +26,4 @@
{{item.system.recallCost}}
- - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.actions isAction=true label=(localize "DAGGERHEART.GENERAL.Action.plural") }} \ No newline at end of file diff --git a/templates/ui/tooltip/feature.hbs b/templates/ui/tooltip/feature.hbs index 3e8867c1..fb07d895 100644 --- a/templates/ui/tooltip/feature.hbs +++ b/templates/ui/tooltip/feature.hbs @@ -2,7 +2,4 @@

{{item.name}}

{{{description}}}
- - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.actions isAction=true label=(localize "DAGGERHEART.GENERAL.Action.plural") }} - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.effects label=(localize "DAGGERHEART.GENERAL.Effect.plural") }} \ No newline at end of file diff --git a/templates/ui/tooltip/weapon.hbs b/templates/ui/tooltip/weapon.hbs index a8fe9c46..bf414e5c 100644 --- a/templates/ui/tooltip/weapon.hbs +++ b/templates/ui/tooltip/weapon.hbs @@ -37,20 +37,4 @@
{{{damageSymbols item.system.attack.damage.parts}}}
- - {{#if (gt item.system.weaponFeatures.length 0)}}

{{localize "DAGGERHEART.GENERAL.features"}}

{{/if}} -
- {{#each item.system.weaponFeatures}} - {{#with (lookup ../config.ITEM.weaponFeatures this.value) as | feature | }} -
-
-
{{localize feature.label}}
-
-
{{{localize feature.description}}}
-
- {{/with}} - {{/each}} -
- - {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.customActions isAction=true label=(localize "DAGGERHEART.GENERAL.Action.plural") }} \ No newline at end of file From ee5c3a93223aa5bd285a1c083e61aaebb35a92b9 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:36:21 +0200 Subject: [PATCH 5/5] [Feature] Loadout&Domains Homebrew (#529) * Removed ChatTheme from settings * 0 or blank loadoutSize now means unlimited * Added Homebrew maxDomains --- daggerheart.mjs | 11 ++------- lang/en.json | 15 ++++++------ .../settings/appearanceSettings.mjs | 7 +----- .../applications/sheets/actors/character.mjs | 9 ++++--- module/applications/sheets/items/class.mjs | 5 +++- module/config/settingsConfig.mjs | 11 --------- module/data/actor/character.mjs | 7 +++--- module/data/item/class.mjs | 10 +++++++- module/data/settings/Appearance.mjs | 17 ------------- module/data/settings/Homebrew.mjs | 7 ++++++ module/documents/actor.mjs | 24 +++++++++++++++---- module/helpers/utils.mjs | 2 +- styles/less/ui/settings/settings.less | 12 ++++++++++ templates/settings/homebrew-settings.hbs | 2 ++ 14 files changed, 74 insertions(+), 65 deletions(-) diff --git a/daggerheart.mjs b/daggerheart.mjs index 025dde3a..d0b003bc 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -8,7 +8,6 @@ import RegisterHandlebarsHelpers from './module/helpers/handlebarsHelper.mjs'; import { enricherConfig, enricherRenderSetup } from './module/enrichers/_module.mjs'; import { getCommandTarget, rollCommandToJSON } from './module/helpers/utils.mjs'; import { NarrativeCountdowns } from './module/applications/ui/countdowns.mjs'; -import { DualityRollColor } from './module/data/settings/Appearance.mjs'; import { DHRoll, DualityRoll, D20Roll, DamageRoll, DualityDie } from './module/dice/_module.mjs'; import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs'; import { registerCountdownHooks } from './module/data/countdowns.mjs'; @@ -56,8 +55,8 @@ Hooks.once('init', () => { }; CONFIG.Dice.rolls = [...CONFIG.Dice.rolls, DHRoll, DualityRoll, D20Roll, DamageRoll]; - Roll.CHAT_TEMPLATE = "systems/daggerheart/templates/ui/chat/foundryRoll.hbs"; - Roll.TOOLTIP_TEMPLATE = "systems/daggerheart/templates/ui/chat/foundryRollTooltip.hbs"; + Roll.CHAT_TEMPLATE = 'systems/daggerheart/templates/ui/chat/foundryRoll.hbs'; + Roll.TOOLTIP_TEMPLATE = 'systems/daggerheart/templates/ui/chat/foundryRollTooltip.hbs'; CONFIG.MeasuredTemplate.objectClass = placeables.DhMeasuredTemplate; const { DocumentSheetConfig } = foundry.applications.apps; @@ -162,12 +161,6 @@ Hooks.on('ready', () => { if (game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).displayFear !== 'hide') ui.resources.render({ force: true }); - document.body.classList.toggle( - 'theme-colorful', - game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).dualityColorScheme === - DualityRollColor.colorful.value - ); - registerCountdownHooks(); socketRegistration.registerSocketHooks(); registerRollDiceHooks(); diff --git a/lang/en.json b/lang/en.json index e15c9af5..be797216 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2077,12 +2077,6 @@ } } }, - "DualityRollColor": { - "options": { - "colorful": "Colorful", - "normal": "Normal" - } - }, "Homebrew": { "newDowntimeMove": "Downtime Move", "downtimeMoves": "Downtime Moves", @@ -2092,7 +2086,11 @@ "FIELDS": { "maxFear": { "label": "Max Fear" }, "traitArray": { "label": "Initial Trait Modifiers" }, - "maxLoadout": { "label": "Max Cards in Loadout" } + "maxLoadout": { + "label": "Max Cards in Loadout", + "hint": "Set to blank or 0 for unlimited maximum" + }, + "maxDomains": { "label": "Max Class Domains", "hint": "Max domains you can set on a class" } }, "currency": { "enabled": "Enable Overrides", @@ -2282,7 +2280,8 @@ "beastformToManyAdvantages": "You cannot select any more advantages.", "beastformToManyFeatures": "You cannot select any more features.", "beastformEquipWeapon": "You cannot use weapons while in a Beastform.", - "loadoutMaxReached": "You already have {max} cards in your loadout. Move atleast one to your vault before adding a new one.", + "loadoutMaxReached": "You've reached maximum loadout. Move atleast one domain card to the vault, or increase the limit in homebrew settings if desired.", + "domainMaxReached": "You've reached the maximum domains for the class. Increase the limit in homebrew settings if desired.", "insufficientResources": "You have insufficient resources", "multiclassAlreadyPresent": "You already have a class and multiclass", "subclassesAlreadyPresent": "You already have a class and multiclass subclass" diff --git a/module/applications/settings/appearanceSettings.mjs b/module/applications/settings/appearanceSettings.mjs index 533dacff..491c9799 100644 --- a/module/applications/settings/appearanceSettings.mjs +++ b/module/applications/settings/appearanceSettings.mjs @@ -1,4 +1,4 @@ -import DhAppearance, { DualityRollColor } from '../../data/settings/Appearance.mjs'; +import DhAppearance from '../../data/settings/Appearance.mjs'; const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api; @@ -96,11 +96,6 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App static async save() { await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance, this.settings.toObject()); - document.body.classList.toggle( - 'theme-colorful', - game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).dualityColorScheme === - DualityRollColor.colorful.value - ); this.close(); } diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 6e38e25d..76ca7562 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -266,9 +266,7 @@ export default class CharacterSheet extends DHBaseActorSheet { const doc = await getDocFromElement(target); const actorLoadout = doc.actor.system.loadoutSlot; if (actorLoadout.available) return doc.update({ 'system.inVault': false }); - ui.notifications.warn( - game.i18n.format('DAGGERHEART.UI.Notifications.loadoutMaxReached', { max: actorLoadout.max }) - ); + ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached')); } }, { @@ -686,6 +684,11 @@ 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) { + return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached')); + } + await doc?.update({ 'system.inVault': !doc.system.inVault }); } diff --git a/module/applications/sheets/items/class.mjs b/module/applications/sheets/items/class.mjs index 3dce0a11..192555a8 100644 --- a/module/applications/sheets/items/class.mjs +++ b/module/applications/sheets/items/class.mjs @@ -15,7 +15,10 @@ export default class ClassSheet extends DHBaseItemSheet { { selector: '.domain-input', options: () => CONFIG.DH.DOMAIN.domains, - callback: ClassSheet.#onDomainSelect + callback: ClassSheet.#onDomainSelect, + tagifyOptions: { + maxTags: () => game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxDomains + } } ], dragDrop: [ diff --git a/module/config/settingsConfig.mjs b/module/config/settingsConfig.mjs index 51197e8a..df3cb619 100644 --- a/module/config/settingsConfig.mjs +++ b/module/config/settingsConfig.mjs @@ -29,14 +29,3 @@ export const gameSettings = { LevelTiers: 'LevelTiers', Countdowns: 'Countdowns' }; - -export const DualityRollColor = { - colorful: { - value: 0, - label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.colorful' - }, - normal: { - value: 1, - label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.normal' - } -}; diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index f9f6e161..0e78e96a 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -362,13 +362,12 @@ export default class DhCharacter extends BaseDataActor { get loadoutSlot() { const loadoutCount = this.domainCards.loadout?.length ?? 0, - max = - game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxLoadout + - this.bonuses.maxLoadout; + worldSetting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxLoadout, + max = !worldSetting ? null : worldSetting + this.bonuses.maxLoadout; return { current: loadoutCount, - available: Math.max(max - loadoutCount, 0), + available: !max ? true : Math.max(max - loadoutCount, 0), max }; } diff --git a/module/data/item/class.mjs b/module/data/item/class.mjs index bca6434c..72f58b8b 100644 --- a/module/data/item/class.mjs +++ b/module/data/item/class.mjs @@ -19,7 +19,7 @@ export default class DHClass extends BaseDataItem { const fields = foundry.data.fields; return { ...super.defineSchema(), - domains: new fields.ArrayField(new fields.StringField(), { max: 2 }), + domains: new fields.ArrayField(new fields.StringField()), classItems: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }), hitPoints: new fields.NumberField({ required: true, @@ -123,6 +123,14 @@ export default class DHClass extends BaseDataItem { const allowed = await super._preUpdate(changed, options, userId); if (allowed === false) return false; + if (changed.system?.domains) { + const maxDomains = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxDomains; + if (changed.system.domains.length > maxDomains) { + ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.domainMaxReached')); + return false; + } + } + const paths = [ 'subclasses', 'characterGuide.suggestedPrimaryWeapon', diff --git a/module/data/settings/Appearance.mjs b/module/data/settings/Appearance.mjs index c59cd436..e215f956 100644 --- a/module/data/settings/Appearance.mjs +++ b/module/data/settings/Appearance.mjs @@ -10,12 +10,6 @@ export default class DhAppearance extends foundry.abstract.DataModel { initial: fearDisplay.token.value, label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.displayFear.label' }), - dualityColorScheme: new fields.StringField({ - required: true, - choices: DualityRollColor, - initial: DualityRollColor.normal.value, - label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.dualityColorScheme.label' - }), diceSoNice: new fields.SchemaField({ hope: new fields.SchemaField({ foreground: new fields.ColorField({ required: true, initial: '#ffffff' }), @@ -65,14 +59,3 @@ export default class DhAppearance extends foundry.abstract.DataModel { }; } } - -export const DualityRollColor = { - colorful: { - value: 'colorful', - label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.colorful' - }, - normal: { - value: 'normal', - label: 'DAGGERHEART.SETTINGS.DualityRollColor.options.normal' - } -}; diff --git a/module/data/settings/Homebrew.mjs b/module/data/settings/Homebrew.mjs index 29da1aa0..0251dd54 100644 --- a/module/data/settings/Homebrew.mjs +++ b/module/data/settings/Homebrew.mjs @@ -21,6 +21,13 @@ export default class DhHomebrew extends foundry.abstract.DataModel { initial: 5, label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxLoadout.label' }), + maxDomains: new fields.NumberField({ + required: true, + integer: true, + min: 1, + initial: 2, + label: 'DAGGERHEART.SETTINGS.Homebrew.FIELDS.maxDomains.label' + }), traitArray: new fields.ArrayField(new fields.NumberField({ required: true, integer: true }), { initial: () => [2, 1, 1, 0, 0, -1] }), diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index ef968b47..4dad59c7 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -318,8 +318,16 @@ export default class DhpActor extends Actor { for (var domainCard of domainCards) { if (levelupAuto) { - const item = await foundry.utils.fromUuid(domainCard.data[0]); - const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]); + const itemData = (await foundry.utils.fromUuid(domainCard.data[0])).toObject(); + const embeddedItem = await this.createEmbeddedDocuments('Item', [ + { + ...itemData, + system: { + ...itemData.system, + inVault: true + } + } + ]); selections.push({ ...domainCard, itemUuid: embeddedItem[0].uuid }); } else { selections.push({ ...domainCard }); @@ -329,8 +337,16 @@ export default class DhpActor extends Actor { const achievementDomainCards = []; if (levelupAuto) { for (var card of Object.values(level.achievements.domainCards)) { - const item = await foundry.utils.fromUuid(card.uuid); - const embeddedItem = await this.createEmbeddedDocuments('Item', [item.toObject()]); + const itemData = (await foundry.utils.fromUuid(card.uuid)).toObject(); + const embeddedItem = await this.createEmbeddedDocuments('Item', [ + { + ...itemData, + system: { + ...itemData.system, + inVault: true + } + } + ]); card.itemUuid = embeddedItem[0].uuid; achievementDomainCards.push(card); } diff --git a/module/helpers/utils.mjs b/module/helpers/utils.mjs index 34de5a5c..4de67e86 100644 --- a/module/helpers/utils.mjs +++ b/module/helpers/utils.mjs @@ -97,7 +97,7 @@ export const tagifyElement = (element, options, onChange, tagifyOptions = {}) => description: option.description }; }), - maxTags: maxTags, + maxTags: typeof maxTags === 'function' ? maxTags() : maxTags, dropdown: { mapValueTo: 'name', searchKeys: ['name'], diff --git a/styles/less/ui/settings/settings.less b/styles/less/ui/settings/settings.less index 0ba6f094..3033b4e7 100644 --- a/styles/less/ui/settings/settings.less +++ b/styles/less/ui/settings/settings.less @@ -126,4 +126,16 @@ } } } + + .settings-hint { + width: 100%; + display: flex; + justify-content: end; + + label { + width: 240px; + font-style: italic; + text-align: center; + } + } } diff --git a/templates/settings/homebrew-settings.hbs b/templates/settings/homebrew-settings.hbs index 6bfcbb9c..b70d63ad 100644 --- a/templates/settings/homebrew-settings.hbs +++ b/templates/settings/homebrew-settings.hbs @@ -3,7 +3,9 @@

{{localize 'DAGGERHEART.SETTINGS.Menu.homebrew.name'}}

{{formGroup settingFields.schema.fields.maxFear value=settingFields._source.maxFear localize=true}} + {{formGroup settingFields.schema.fields.maxDomains value=settingFields._source.maxDomains localize=true}} {{formGroup settingFields.schema.fields.maxLoadout value=settingFields._source.maxLoadout localize=true}} +

{{localize "DAGGERHEART.SETTINGS.Homebrew.FIELDS.traitArray.label"}}