diff --git a/lang/en.json b/lang/en.json index 40868a6e..ce29377a 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2085,6 +2085,10 @@ "base": "Base Thresholds", "major": "Major Threshold", "severe": "Severe Threshold" + }, + "switch": { + "title": "Armor Swap", + "content": "Reset Marked Armor Slots ?" } }, "Beastform": { diff --git a/module/applications/dialogs/damageReductionDialog.mjs b/module/applications/dialogs/damageReductionDialog.mjs index b64149c0..7863f41b 100644 --- a/module/applications/dialogs/damageReductionDialog.mjs +++ b/module/applications/dialogs/damageReductionDialog.mjs @@ -20,7 +20,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap ); const canApplyArmor = damageType.every(t => actor.system.armorApplicableDamageTypes[t] === true); - const availableArmor = actor.system.armorScore - actor.system.armor.system.marks.value; + const availableArmor = actor.system.resources.armor.max - actor.system.resources.armor.value; const maxArmorMarks = canApplyArmor ? availableArmor : 0; const armor = [...Array(maxArmorMarks).keys()].reduce((acc, _) => { @@ -116,7 +116,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap const { selectedArmorMarks, selectedStressMarks, stressReductions, currentMarks, currentDamage } = this.getDamageInfo(); - context.armorScore = this.actor.system.armorScore; + context.armorScore = this.actor.system.resources.armor.max; context.armorMarks = currentMarks; context.basicMarksUsed = selectedArmorMarks.length === this.actor.system.rules.damageReduction.maxArmorMarked.value; @@ -165,7 +165,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap ? Object.values(this.availableStressReductions).filter(red => red.selected) : []; const currentMarks = - this.actor.system.armor.system.marks.value + selectedArmorMarks.length + selectedStressMarks.length; + this.actor.system.resources.armor.value + selectedArmorMarks.length + selectedStressMarks.length; const armorMarkReduction = selectedArmorMarks.length * this.actor.system.rules.damageReduction.increasePerArmorMark; @@ -207,7 +207,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap } if (this.rulesOn) { - if (!currentMark.selected && currentMarks === this.actor.system.armorScore) { + if (!currentMark.selected && currentMarks === this.actor.system.resources.armor.max) { ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noAvailableArmorMarks')); return; } diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 5bc6828b..0e013a97 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -134,11 +134,6 @@ export default class CharacterSheet extends DHBaseActorSheet { element.addEventListener('change', this.updateItemQuantity.bind(this)); element.addEventListener('click', e => e.stopPropagation()); }); - - // Add listener for armor marks input - htmlElement.querySelectorAll('.armor-marks-input').forEach(element => { - element.addEventListener('change', this.updateArmorMarks.bind(this)); - }); } /** @inheritDoc */ @@ -581,15 +576,6 @@ export default class CharacterSheet extends DHBaseActorSheet { this.render(); } - async updateArmorMarks(event) { - const armor = this.document.system.armor; - if (!armor) return; - - const maxMarks = this.document.system.armorScore; - const value = Math.min(Math.max(Number(event.currentTarget.value), 0), maxMarks); - await armor.update({ 'system.marks.value': value }); - } - /* -------------------------------------------- */ /* Application Clicks Actions */ /* -------------------------------------------- */ @@ -702,6 +688,19 @@ export default class CharacterSheet extends DHBaseActorSheet { } await item.update({ 'system.equipped': true }); + + if(this.document.system.resources.armor.value > 0) { + const confirmed = await foundry.applications.api.DialogV2.confirm({ + window: { + title: game.i18n.localize('DAGGERHEART.ITEMS.Armor.switch.title') + }, + content: game.i18n.localize('DAGGERHEART.ITEMS.Armor.switch.content') + }); + + if (confirmed) + await this.document.update({'system.resources.armor.value': 0}); + } + break; case 'weapon': if (this.document.effects.find(x => !x.disabled && x.type === 'beastform')) { diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index ddcc5bf5..af576025 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -35,7 +35,14 @@ export default class DhCharacter extends BaseDataActor { 'DAGGERHEART.ACTORS.Character.maxHPBonus' ), stress: resourceField(6, 0, 'DAGGERHEART.GENERAL.stress', true), - hope: resourceField(6, 2, 'DAGGERHEART.GENERAL.hope') + hope: resourceField(6, 2, 'DAGGERHEART.GENERAL.hope'), + armor: resourceField( + 0, + 0, + '', + true, + '' + ) }), traits: new fields.SchemaField({ agility: attributeField('DAGGERHEART.CONFIG.Traits.agility.name'), @@ -631,11 +638,8 @@ 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 ?? 0, - max: this.armorScore, - isReversed: true - }; + this.resources.armor.max = this.armorScore; + if(this.resources.armor.value > this.resources.armor.max) this.resources.armor.value = this.resources.armor.max; 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/chat-message/actorRoll.mjs b/module/data/chat-message/actorRoll.mjs index b6512fbd..91f44edc 100644 --- a/module/data/chat-message/actorRoll.mjs +++ b/module/data/chat-message/actorRoll.mjs @@ -55,9 +55,14 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel { } get action() { - const actionItem = this.actionItem; - if (!actionItem || !this.source.action) return null; - return actionItem.system.actionsList?.find(a => a.id === this.source.action); + const actionActor = this.actionActor, + actionItem = this.actionItem; + if (!this.source.action) return null; + if(actionItem) + return actionItem.system.actionsList?.find(a => a.id === this.source.action); + else if(actionActor?.system.attack?._id === this.source.action) + return actionActor.system.attack + return null; } get targetMode() { diff --git a/module/data/item/base.mjs b/module/data/item/base.mjs index 11be0a52..3a10a41a 100644 --- a/module/data/item/base.mjs +++ b/module/data/item/base.mjs @@ -187,14 +187,6 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel { if (allowed === false) return false; addLinkedItemsDiff(changed.system?.features, this.features, options); - - const autoSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation); - const armorChanged = - changed.system?.marks?.value !== undefined && changed.system.marks.value !== this.marks.value; - if (armorChanged && autoSettings.resourceScrollTexts && this.parent.parent?.type === 'character') { - const armorData = getScrollTextData(this.parent.parent.system.resources, changed.system.marks, 'armor'); - options.scrollingTextData = [armorData]; - } } _onUpdate(changed, options, userId) { diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 79e71549..4dcd44fb 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -514,8 +514,7 @@ export default class DhpActor extends Actor { const availableStress = this.system.resources.stress.max - this.system.resources.stress.value; const canUseArmor = - this.system.armor && - this.system.armor.system.marks.value < this.system.armorScore && + this.system.resources.armor.value < this.system.resources.armor.max && type.every(t => this.system.armorApplicableDamageTypes[t] === true); const canUseStress = Object.keys(stressDamageReduction).reduce((acc, x) => { const rule = stressDamageReduction[x]; @@ -558,7 +557,6 @@ export default class DhpActor extends Actor { if ( this.type === 'character' && !isDirect && - this.system.armor && this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes) ) { const armorSlotResult = await this.owner.query( @@ -682,14 +680,6 @@ export default class DhpActor extends Actor { game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear) + r.value ); break; - case 'armor': - if (this.system.armor?.system?.marks) { - updates.armor.resources['system.marks.value'] = Math.max( - Math.min(this.system.armor.system.marks.value + r.value, this.system.armorScore), - 0 - ); - } - break; default: if (this.system.resources?.[r.key]) { updates.actor.resources[`system.resources.${r.key}.value`] = Math.max( diff --git a/module/documents/token.mjs b/module/documents/token.mjs index 6d080f31..8544ebe8 100644 --- a/module/documents/token.mjs +++ b/module/documents/token.mjs @@ -9,13 +9,6 @@ export default class DHToken extends TokenDocument { const barGroup = game.i18n.localize('TOKEN.BarAttributes'); const valueGroup = game.i18n.localize('TOKEN.BarValues'); - const bars = attributes.bar.map(v => { - const a = v.join('.'); - const modelLabel = model ? game.i18n.localize(model.schema.getField(`${a}.value`).label) : null; - return { group: barGroup, value: a, label: modelLabel ? modelLabel : a }; - }); - bars.sort((a, b) => a.label.compare(b.label)); - const invalidAttributes = [ 'gold', 'levelData', @@ -29,8 +22,21 @@ export default class DHToken extends TokenDocument { 'description', 'impulses', 'tier', - 'type' + 'type', + 'resources.armor' ]; + + const bars = attributes.bar.reduce((acc, v) => { + const a = v.join('.'); + if (invalidAttributes.some(x => a.startsWith(x))) return acc; + + const modelLabel = model ? game.i18n.localize(model.schema.getField(`${a}.value`).label) : null; + acc.push({ group: barGroup, value: a, label: modelLabel ? modelLabel : a }); + + return acc; + }, []); + bars.sort((a, b) => a.label.compare(b.label)); + const values = attributes.value.reduce((acc, v) => { const a = v.join('.'); if (invalidAttributes.some(x => a.startsWith(x))) return acc; diff --git a/src/packs/domains/domainCard_Vitality_sWUlSPOJEaXyQLCj.json b/src/packs/domains/domainCard_Vitality_sWUlSPOJEaXyQLCj.json index 6d85b5b5..9b9579ec 100644 --- a/src/packs/domains/domainCard_Vitality_sWUlSPOJEaXyQLCj.json +++ b/src/packs/domains/domainCard_Vitality_sWUlSPOJEaXyQLCj.json @@ -85,7 +85,7 @@ }, "changes": [ { - "key": "system.resources.hitPoints", + "key": "system.resources.hitPoints.max", "mode": 2, "value": "1", "priority": null diff --git a/templates/sheets/actors/character/sidebar.hbs b/templates/sheets/actors/character/sidebar.hbs index e2a4da80..04cb4048 100644 --- a/templates/sheets/actors/character/sidebar.hbs +++ b/templates/sheets/actors/character/sidebar.hbs @@ -62,26 +62,10 @@ - {{!-- {{#if document.system.armor.system.marks}} -
--}} {{#if document.system.resources.armor.max}}