This commit is contained in:
WBHarry 2025-11-17 09:51:16 +01:00
parent a3ca96bee6
commit 80012b474a
11 changed files with 39 additions and 30 deletions

View file

@ -141,8 +141,8 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
...actionType,
_id: foundry.utils.randomID(),
name: game.i18n.localize(actionType.name),
itemSource: {
type: CONFIG.DH.ITEM.itemSourceType.restMove,
originItem: {
type: CONFIG.DH.ITEM.originItemType.restMove,
itemPath: movePath,
actionIndex: actionIndex
}

View file

@ -1548,7 +1548,7 @@ export const beastformTypes = {
}
};
export const itemSourceType = {
export const originItemType = {
itemCollection: 'itemCollection',
restMove: 'restMove'
};

View file

@ -1,7 +1,7 @@
import DhpActor from '../../documents/actor.mjs';
import D20RollDialog from '../../applications/dialogs/d20RollDialog.mjs';
import { ActionMixin } from '../fields/actionField.mjs';
import { itemSourceField } from '../chat-message/actorRoll.mjs';
import { originItemField } from '../chat-message/actorRoll.mjs';
const fields = foundry.data.fields;
@ -26,7 +26,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
description: new fields.HTMLField(),
img: new fields.FilePathField({ initial: undefined, categories: ['IMAGE'], base64: false }),
chatDisplay: new fields.BooleanField({ initial: true, label: 'DAGGERHEART.ACTIONS.Config.displayInChat' }),
itemSource: itemSourceField(),
originItem: originItemField(),
actionType: new fields.StringField({
choices: CONFIG.DH.ITEM.actionTypes,
initial: 'action',
@ -217,7 +217,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
title: `${this.item instanceof CONFIG.Actor.documentClass ? '' : `${this.item.name}: `}${game.i18n.localize(this.name)}`,
source: {
item: this.item._id,
itemSource: this.itemSource,
originItem: this.originItem,
action: this._id,
actor: this.actor.uuid
},

View file

@ -17,11 +17,11 @@ const targetsField = () =>
})
);
export const itemSourceField = () =>
export const originItemField = () =>
new fields.SchemaField({
type: new fields.StringField({
choices: CONFIG.DH.ITEM.itemSourceType,
initial: CONFIG.DH.ITEM.itemSourceType.itemCollection
choices: CONFIG.DH.ITEM.originItemType,
initial: CONFIG.DH.ITEM.originItemType.itemCollection
}),
itemPath: new fields.StringField(),
actionIndex: new fields.StringField()
@ -45,7 +45,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
source: new fields.SchemaField({
actor: new fields.StringField(),
item: new fields.StringField(),
itemSource: itemSourceField(),
originItem: originItemField(),
action: new fields.StringField()
}),
damage: new fields.ObjectField(),
@ -59,15 +59,15 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
return fromUuidSync(this.source.actor);
}
get itemAction() {
get actionItem() {
const actionActor = this.actionActor;
if (!actionActor || !this.source.item) return null;
switch (this.source.itemSource.type) {
case CONFIG.DH.ITEM.itemSourceType.restMove:
switch (this.source.originItem.type) {
case CONFIG.DH.ITEM.originItemType.restMove:
const restMoves = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves;
return Array.from(foundry.utils.getProperty(restMoves, `${this.source.itemSource.itemPath}`).actions)[
this.source.itemSource.actionIndex
return Array.from(foundry.utils.getProperty(restMoves, `${this.source.originItem.itemPath}`).actions)[
this.source.originItem.actionIndex
];
default:
const item = actionActor.items.get(this.source.item);
@ -76,8 +76,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
}
get action() {
const actionActor = this.actionActor,
itemAction = this.itemAction;
const { actionActor, actionItem: itemAction } = this;
if (!this.source.action) return null;
if (itemAction) return itemAction;
else if (actionActor?.system.attack?._id === this.source.action) return actionActor.system.attack;

View file

@ -98,7 +98,9 @@ export default class DamageField extends fields.SchemaField {
});
}
const token = game.scenes.find(x => x.active).tokens.find(x => x.id === target.id);
const token = target.id
? game.scenes.find(x => x.active).tokens.find(x => x.id === target.id)
: actor.prototypeToken;
if (config.hasHealing)
damagePromises.push(
actor.takeHealing(config.damage).then(updates => targetDamage.push({ token, updates }))

View file

@ -26,7 +26,7 @@ export default class TargetField extends fields.SchemaField {
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)
targets = [this.actor.token ?? this.actor.getDependentTokens()[0]];
targets = [this.actor.token ?? this.actor.prototypeToken];
else {
targets = Array.from(game.user.targets);
if (this.target.type !== CONFIG.DH.GENERAL.targetTypes.any.id) {

View file

@ -145,9 +145,11 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
});
html.querySelectorAll('.token-target-container').forEach(element => {
element.addEventListener('pointerover', this.hoverTarget);
element.addEventListener('pointerout', this.unhoverTarget);
element.addEventListener('click', this.clickTarget);
if (element.dataset.token) {
element.addEventListener('pointerover', this.hoverTarget);
element.addEventListener('pointerout', this.unhoverTarget);
element.addEventListener('click', this.clickTarget);
}
});
}

View file

@ -28,12 +28,15 @@
display: flex;
flex-direction: column;
gap: 2px;
cursor: pointer;
transition: all 0.3s ease;
border-radius: 6px;
&:hover {
background: @golden-10;
&.clickable {
cursor: pointer;
&:hover {
background: @golden-10;
}
}
header {

View file

@ -90,11 +90,14 @@
background: transparent;
transition: all 0.3s ease;
padding: 5px;
cursor: pointer;
transition: all 0.3s ease;
&:hover {
background: @golden-10;
&.clickable {
cursor: pointer;
&:hover {
background: @golden-10;
}
}
img {

View file

@ -1,6 +1,6 @@
<ul class="daggerheart chat damage-summary">
{{#each targets}}
<li class="token-target-container" data-token="{{this.token.id}}">
<li class="token-target-container {{#if this.token.id}}clickable{{/if}}" data-token="{{this.token.id}}">
<header>
<img src="{{this.token.texture.src}}" />
<h2 class="actor-name">{{this.token.name}}</h2>

View file

@ -23,7 +23,7 @@
</div>
<div class="targets-container">
{{#each targets}}
<div class="token-target-container" data-token="{{this.id}}">
<div class="token-target-container {{#if this.id}}clickable{{/if}}" data-token="{{this.id}}">
<img src="{{this.texture.src}}" />
<h2 class="title">{{this.name}}</h2>
</div>