diff --git a/lang/en.json b/lang/en.json index 68ab0a12..3f8c4321 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1801,7 +1801,9 @@ "label": "Long Rest: Bonus Long Rest Moves", "hint": "The number of extra Long Rest Moves the character can take during a Long Rest." } - } + }, + "target": "Target", + "targetSelf": "Self" }, "maxLoadout": { "label": "Max Loadout Cards Bonus" diff --git a/module/applications/dialogs/downtime.mjs b/module/applications/dialogs/downtime.mjs index 3d5b7f0f..f03524f0 100644 --- a/module/applications/dialogs/downtime.mjs +++ b/module/applications/dialogs/downtime.mjs @@ -181,12 +181,17 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV .filter(x => category.moves[x].selected) .flatMap(key => { const move = category.moves[key]; + const needsTarget = move.actions.filter(x => x.target?.type && x.target.type !== 'self').length > 0; return [...Array(move.selected).keys()].map(_ => ({ ...move, - movePath: `${categoryKey}.moves.${key}` + movePath: `${categoryKey}.moves.${key}`, + needsTarget: needsTarget })); }); }); + const characters = game.actors.filter(x => x.type === 'character') + .filter(x => x.testUserPermission(game.user, 'LIMITED')) + .filter(x => x.uuid !== this.actor.uuid); const cls = getDocumentClass('ChatMessage'); const msg = { @@ -206,7 +211,9 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV `DAGGERHEART.APPLICATIONS.Downtime.${this.shortrest ? 'shortRest' : 'longRest'}.title` ), actor: { name: this.actor.name, img: this.actor.img }, - moves: moves + moves: moves, + characters: characters, + selfId: this.actor.uuid } ), flags: { diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 45d9c0b3..fc3208f1 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -134,7 +134,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo async actionUseButton(event, message) { const { moveIndex, actionIndex, movePath } = event.currentTarget.dataset; + const targetUuid = event.currentTarget.closest('.action-use-button-parent').querySelector('select')?.value; const parent = await foundry.utils.fromUuid(message.system.actor); + const actionType = message.system.moves[moveIndex].actions[actionIndex]; const cls = game.system.api.models.actions.actionsTypes[actionType.type]; const action = new cls( @@ -146,7 +148,8 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo type: CONFIG.DH.ITEM.originItemType.restMove, itemPath: movePath, actionIndex: actionIndex - } + }, + targetUuid: targetUuid }, { parent: parent.system } ); diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index 2c2b1316..3c755234 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -232,7 +232,7 @@ export const defaultRestOptions = { actionType: 'action', chatDisplay: false, target: { - type: 'self' + type: 'friendly' }, damage: { parts: [ @@ -298,7 +298,7 @@ export const defaultRestOptions = { actionType: 'action', chatDisplay: false, target: { - type: 'self' + type: 'friendly' }, damage: { parts: [ @@ -341,7 +341,7 @@ export const defaultRestOptions = { actionType: 'action', chatDisplay: false, target: { - type: 'self' + type: 'friendly' }, damage: { parts: [ @@ -350,7 +350,7 @@ export const defaultRestOptions = { value: { custom: { enabled: true, - formula: '@system.resources.hitPoints.max' + formula: '100' } } } @@ -407,7 +407,7 @@ export const defaultRestOptions = { actionType: 'action', chatDisplay: false, target: { - type: 'self' + type: 'friendly' }, damage: { parts: [ @@ -416,7 +416,7 @@ export const defaultRestOptions = { value: { custom: { enabled: true, - formula: '@system.armorScore' + formula: '100' } } } diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index 6c7b8c59..18a09904 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -33,7 +33,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel initial: 'action', nullable: false, required: true - }) + }), + targetUuid: new fields.StringField({ initial: undefined }) }; this.extraSchemas.forEach(s => { @@ -241,7 +242,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel selectedRollMode: game.settings.get('core', 'rollMode'), data: this.getRollData(), evaluate: this.hasRoll, - resourceUpdates: new ResourceUpdateMap(this.actor) + resourceUpdates: new ResourceUpdateMap(this.actor), + targetUuid: this.targetUuid }; DHBaseAction.applyKeybindings(config); diff --git a/module/data/fields/action/targetField.mjs b/module/data/fields/action/targetField.mjs index 73766118..3a4f12df 100644 --- a/module/data/fields/action/targetField.mjs +++ b/module/data/fields/action/targetField.mjs @@ -25,9 +25,12 @@ export default class TargetField extends fields.SchemaField { config.hasTarget = true; let targets; // If the Action is configured as self-targeted, set targets as the owner. Probably better way than to fallback to getDependentTokens - if (this.target?.type === CONFIG.DH.GENERAL.targetTypes.self.id) + if (this.target?.type === CONFIG.DH.GENERAL.targetTypes.self.id) { targets = [this.actor.token ?? this.actor.prototypeToken]; - else { + } else if (config.targetUuid) { + const actor = fromUuidSync(config.targetUuid); + targets = [actor.token ?? actor.prototypeToken]; + } else { targets = Array.from(game.user.targets); if (this.target.type !== CONFIG.DH.GENERAL.targetTypes.any.id) { targets = targets.filter(target => TargetField.isTargetFriendly(this.actor, target, this.target.type)); diff --git a/styles/less/ui/chat/downtime.less b/styles/less/ui/chat/downtime.less index 5496a2a3..a99bde33 100644 --- a/styles/less/ui/chat/downtime.less +++ b/styles/less/ui/chat/downtime.less @@ -99,12 +99,35 @@ } } + .action-use-button-parent { + width: 100%; + + .action-use-target { + display:flex; + align-items: center; + justify-content: space-between; + gap: 4px; + width: 100%; + padding: 4px 8px 10px 40px; + font-size: var(--font-size-12); + + label { + font-weight: bold; + } + + select { + flex: 1; + } + } + } + .action-use-button { width: -webkit-fill-available; margin: 0 8px; font-weight: 600; height: 40px; } + } } } diff --git a/templates/ui/chat/downtime.hbs b/templates/ui/chat/downtime.hbs index ef1f44c4..373724dc 100644 --- a/templates/ui/chat/downtime.hbs +++ b/templates/ui/chat/downtime.hbs @@ -15,9 +15,22 @@ {{#each move.actions as | action index |}} - +
+ + {{#if move.needsTarget}} +
+ + +
+ {{/if}} +
{{/each}} {{/each}}