Corrected downtime buttons and actions

This commit is contained in:
WBHarry 2025-07-20 00:48:50 +02:00
parent 4b82169fbf
commit 82be5ecd0d
4 changed files with 35 additions and 21 deletions

View file

@ -297,15 +297,16 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
await actor.useAction(action);
};
actionUseButton = async (_, message) => {
actionUseButton = async (event, message) => {
const { moveIndex, actionIndex } = event.currentTarget.dataset;
const parent = await foundry.utils.fromUuid(message.system.actor);
const actionType = Object.values(message.system.moves)[0].actions[0];
const cls = CONFIG.DH.ACTIONS.actionTypes[actionType.type];
const actionType = message.system.moves[moveIndex].actions[actionIndex];
const cls = game.system.api.models.actions.actionsTypes[actionType.type];
const action = new cls(
{ ...actionType, _id: foundry.utils.randomID(), name: game.i18n.localize(actionType.name) },
{ parent: parent }
{ parent: parent.system }
);
action.use();
action.use(event);
};
}

View file

@ -145,11 +145,11 @@ export const defaultRestOptions = {
img: 'icons/magic/life/cross-worn-green.webp',
actionType: 'action',
healing: {
type: 'health',
applyTo: healingTypes.hitPoints.id,
value: {
custom: {
enabled: true,
formula: '1d4 + 1' // should be 1d4 + {tier}. How to use the roll param?
formula: '1d4 + @tier'
}
}
}
@ -169,11 +169,11 @@ export const defaultRestOptions = {
img: 'icons/magic/perception/eye-ringed-green.webp',
actionType: 'action',
healing: {
type: 'stress',
applyTo: healingTypes.stress.id,
value: {
custom: {
enabled: true,
formula: '1d4 + 1' // should be 1d4 + {tier}. How to use the roll param?
formula: '1d4 + @tier'
}
}
}
@ -186,7 +186,23 @@ export const defaultRestOptions = {
icon: 'fa-solid fa-hammer',
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
description: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.description'),
actions: []
actions: [
{
type: 'healing',
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.name'),
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
actionType: 'action',
healing: {
applyTo: healingTypes.armorStack.id,
value: {
custom: {
enabled: true,
formula: '1d4 + @tier'
}
}
}
}
]
},
prepare: {
id: 'prepare',

View file

@ -21,13 +21,8 @@
width: 80px;
}
.downtime-refresh-container {
margin-top: @fullMargin;
.action-use-button {
width: 100%;
.refresh-title {
font-weight: bold;
}
}
}

View file

@ -2,10 +2,12 @@
<h2 class="downtime-title-container">
<div>{{title}}</div>
</h2>
{{#each moves}}
<strong>{{this.name}}</strong>
<img class="downtime-image" src="{{this.img}}" />
<div>{{{this.description}}}</div>
{{#if (gt this.actions.length 0)}}<button class="action-use-button">{{localize "Action"}}</button>{{/if}}
{{#each moves as | move index |}}
<strong>{{move.name}}</strong>
<img class="downtime-image" src="{{move.img}}" />
<div>{{{move.description}}}</div>
{{#each move.actions as | action index |}}
<button class="action-use-button" data-move-index="{{@../key}}" data-action-index="{{index}}">{{localize action.name}}</button>
{{/each}}
{{/each}}
</div>