From 41046cdfcaea61d571aa8249aefadf0377161620 Mon Sep 17 00:00:00 2001 From: Dapoolp Date: Tue, 29 Jul 2025 22:23:19 +0200 Subject: [PATCH] Stuffs --- lang/en.json | 2 +- .../dialogs/damageReductionDialog.mjs | 2 +- .../sheets-configs/action-config.mjs | 2 +- module/config/generalConfig.mjs | 16 ++++++++-------- module/config/itemConfig.mjs | 2 +- module/data/action/baseAction.mjs | 10 ++++------ module/data/actor/character.mjs | 6 ++++++ module/data/fields/action/costField.mjs | 10 +++++++++- module/data/fields/action/rollField.mjs | 2 +- module/documents/actor.mjs | 11 ++++++----- module/systemRegistration/socket.mjs | 2 +- templates/actionTypes/cost.hbs | 2 +- templates/dialogs/dice-roll/costSelection.hbs | 6 +++--- 13 files changed, 43 insertions(+), 30 deletions(-) diff --git a/lang/en.json b/lang/en.json index 0d338238..9afa7a62 100755 --- a/lang/en.json +++ b/lang/en.json @@ -716,7 +716,7 @@ "name": "Hope", "abbreviation": "HO" }, - "armorStack": { + "armorSlot": { "name": "Armor Slot", "abbreviation": "AS" }, diff --git a/module/applications/dialogs/damageReductionDialog.mjs b/module/applications/dialogs/damageReductionDialog.mjs index 9049522d..e0841324 100644 --- a/module/applications/dialogs/damageReductionDialog.mjs +++ b/module/applications/dialogs/damageReductionDialog.mjs @@ -225,7 +225,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap await super.close({}); } - static async armorStackQuery({ actorId, damage, type }) { + static async armorSlotQuery({ actorId, damage, type }) { return new Promise(async (resolve, reject) => { const actor = await fromUuid(actorId); if (!actor || !actor?.isOwner) reject(); diff --git a/module/applications/sheets-configs/action-config.mjs b/module/applications/sheets-configs/action-config.mjs index 92176861..20ed4993 100644 --- a/module/applications/sheets-configs/action-config.mjs +++ b/module/applications/sheets-configs/action-config.mjs @@ -112,7 +112,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) { context.disableOption = this.disableOption.bind(this); context.isNPC = this.action.actor?.isNPC; context.baseSaveDifficulty = this.action.actor?.baseSaveDifficulty; - context.baseAttackBonus = this.action.actor?.system.attack?.damage.parts[0].value.bonus; + context.baseAttackBonus = this.action.actor?.system.attack?.roll.bonus; context.hasRoll = this.action.hasRoll; const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers; diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index 78e99eae..81d4309f 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -85,10 +85,10 @@ export const healingTypes = { label: 'DAGGERHEART.CONFIG.HealingType.hope.name', abbreviation: 'DAGGERHEART.CONFIG.HealingType.hope.abbreviation' }, - armorStack: { - id: 'armorStack', - label: 'DAGGERHEART.CONFIG.HealingType.armorStack.name', - abbreviation: 'DAGGERHEART.CONFIG.HealingType.armorStack.abbreviation' + armorSlot: { + id: 'armorSlot', + label: 'DAGGERHEART.CONFIG.HealingType.armorSlot.name', + abbreviation: 'DAGGERHEART.CONFIG.HealingType.armorSlot.abbreviation' }, fear: { id: 'fear', @@ -199,7 +199,7 @@ export const defaultRestOptions = { actionType: 'action', chatDisplay: false, healing: { - applyTo: healingTypes.armorStack.id, + applyTo: healingTypes.armorSlot.id, value: { custom: { enabled: true, @@ -287,7 +287,7 @@ export const defaultRestOptions = { actionType: 'action', chatDisplay: false, healing: { - applyTo: healingTypes.armorStack.id, + applyTo: healingTypes.armorSlot.id, value: { custom: { enabled: true, @@ -425,8 +425,8 @@ export const refreshTypes = { }; export const abilityCosts = { - hp: { - id: 'hp', + hitPoints: { + id: 'hitPoints', label: 'DAGGERHEART.CONFIG.HealingType.hitPoints.name', group: 'Global' }, diff --git a/module/config/itemConfig.mjs b/module/config/itemConfig.mjs index 851ddc32..4b2e3144 100644 --- a/module/config/itemConfig.mjs +++ b/module/config/itemConfig.mjs @@ -604,7 +604,7 @@ export const weaponFeatures = { img: 'icons/skills/melee/hand-grip-sword-strike-orange.webp', cost: [ { - type: 'armorStack', + type: 'armorSlot', value: 1 } ], diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index 649ee855..26c86d87 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -203,6 +203,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel async consume(config) { const usefulResources = foundry.utils.deepClone(this.actor.system.resources); + for (var cost of config.costs) { if (cost.keyIsID) { usefulResources[cost.key] = { @@ -223,13 +224,10 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel keyIsID: resource.keyIsID }; }); - + console.log(resources) await this.actor.modifyResource(resources); - if (config.uses?.enabled) { - const newActions = foundry.utils.getProperty(this.item.system, this.systemPath).map(x => x.toObject()); - newActions[this.index].uses.value++; - await this.item.update({ [`system.${this.systemPath}`]: newActions }); - } + if (config.uses?.enabled) + this.update({ 'uses.value': this.uses.value + 1 }); } /* */ diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index ec6e5c7c..41a62091 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -563,6 +563,12 @@ export default class DhCharacter extends BaseDataActor { this.resources.hope.value = Math.min(baseHope, this.resources.hope.max); this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait; + this.resources.armor = { + value: this.armor.system.marks.value, + max: this.armorScore, + isReversed: true + }; + this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`; } diff --git a/module/data/fields/action/costField.mjs b/module/data/fields/action/costField.mjs index 5f67f25f..4ddfb8e9 100644 --- a/module/data/fields/action/costField.mjs +++ b/module/data/fields/action/costField.mjs @@ -26,11 +26,19 @@ export default class CostField extends fields.ArrayField { } static calcCosts(costs) { + console.log(costs, CostField.getResources.call(this, costs)) + const resources = CostField.getResources.call(this, costs); return costs.map(c => { c.scale = c.scale ?? 1; c.step = c.step ?? 1; - c.total = c.value * c.scale * c.step; + c.total = c.value + ((c.scale - 1) * c.step); c.enabled = c.hasOwnProperty('enabled') ? c.enabled : true; + c.max = c.key === 'fear' + ? game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear) + : resources[c.key].isReversed + ? resources[c.key].max + : resources[c.key].value + if(c.scalable) c.maxStep = Math.floor(c.max / c.step); return c; }); } diff --git a/module/data/fields/action/rollField.mjs b/module/data/fields/action/rollField.mjs index 35f77ffe..f27938dc 100644 --- a/module/data/fields/action/rollField.mjs +++ b/module/data/fields/action/rollField.mjs @@ -72,7 +72,7 @@ export class DHActionRollData extends foundry.abstract.DataModel { if(!this.parent?.actor) return modifiers; switch (this.parent.actor.type) { case 'character': - const trait = this.useDefault || !this.trait ? this.parent.item.system.attack.roll.trait : this.trait; + const trait = this.useDefault || !this.trait ? (this.parent.item.system.attack.roll.trait ?? 'agility') : this.trait; if(this.type === CONFIG.DH.GENERAL.rollTypes.attack.id || this.type === CONFIG.DH.GENERAL.rollTypes.trait.id) modifiers.push( { diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index ec464ddb..03dabd34 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -481,7 +481,7 @@ export default class DhpActor extends Actor { this.system.armor && this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes) ) { - const armorStackResult = await this.owner.query('armorStack', { + const armorSlotResult = await this.owner.query('armorSlot', { actorId: this.uuid, damage: hpDamage.value, type: [...hpDamage.damageTypes] @@ -490,11 +490,11 @@ export default class DhpActor extends Actor { timeout: 30000 } ); - if (armorStackResult) { - const { modifiedDamage, armorSpent, stressSpent } = armorStackResult; + if (armorSlotResult) { + const { modifiedDamage, armorSpent, stressSpent } = armorSlotResult; updates.find(u => u.key === 'hitPoints').value = modifiedDamage; updates.push( - ...(armorSpent ? [{ value: armorSpent, key: 'armorStack' }] : []), + ...(armorSpent ? [{ value: armorSpent, key: 'armor' }] : []), ...(stressSpent ? [{ value: stressSpent, key: 'stress' }] : []) ); } @@ -569,6 +569,7 @@ export default class DhpActor extends Actor { armor: { target: this.system.armor, resources: {} }, items: {} }; + resources.forEach(r => { if (r.keyIsID) { updates.items[r.key] = { @@ -584,7 +585,7 @@ export default class DhpActor extends Actor { game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear) + r.value ); break; - case 'armorStack': + case 'armor': updates.armor.resources['system.marks.value'] = Math.max( Math.min(this.system.armor.system.marks.value + r.value, this.system.armorScore), 0 diff --git a/module/systemRegistration/socket.mjs b/module/systemRegistration/socket.mjs index e97fe5b0..e3885450 100644 --- a/module/systemRegistration/socket.mjs +++ b/module/systemRegistration/socket.mjs @@ -77,7 +77,7 @@ export const registerSocketHooks = () => { }; export const registerUserQueries = () => { - CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery; + CONFIG.queries.armorSlot = DamageReductionDialog.armorSlotQuery; CONFIG.queries.reactionRoll = game.system.api.models.actions.actionsTypes.base.rollSaveQuery; } diff --git a/templates/actionTypes/cost.hbs b/templates/actionTypes/cost.hbs index 116fc631..e956b284 100644 --- a/templates/actionTypes/cost.hbs +++ b/templates/actionTypes/cost.hbs @@ -6,7 +6,7 @@ {{#each source as |cost index|}}
{{formField ../fields.scalable label="Scalable" value=cost.scalable name=(concat "cost." index ".scalable") classes="checkbox"}} - {{formField ../fields.key choices=(@root.disableOption index @root.costOptions ../source) label="Resource" value=cost.key name=(concat "cost." index ".key") localize=true}} + {{formField ../fields.key choices=(@root.disableOption index @root.costOptions ../source) label="Resource" value=cost.key name=(concat "cost." index ".key") localize=true blank=false}} {{formField ../fields.value label="Amount" value=cost.value name=(concat "cost." index ".value")}} {{formField ../fields.step label="Step" value=cost.step name=(concat "cost." index ".step") disabled=(not cost.scalable)}} diff --git a/templates/dialogs/dice-roll/costSelection.hbs b/templates/dialogs/dice-roll/costSelection.hbs index d9643fc2..3ece4cbf 100644 --- a/templates/dialogs/dice-roll/costSelection.hbs +++ b/templates/dialogs/dice-roll/costSelection.hbs @@ -20,10 +20,10 @@
- {{#if scalable}} - + {{#if (and scalable (gt maxStep 1))}} + {{/if}} - + {{/each}}