mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-11 19:45:57 +01:00
add buttons to card
This commit is contained in:
parent
ee4a5d17a6
commit
32a0e909fc
6 changed files with 107 additions and 9 deletions
22
lang/en.json
22
lang/en.json
|
|
@ -1261,7 +1261,11 @@
|
||||||
"fear": {
|
"fear": {
|
||||||
"name": "Fear",
|
"name": "Fear",
|
||||||
"hint": "The Fear pool of the GM."
|
"hint": "The Fear pool of the GM."
|
||||||
}
|
},
|
||||||
|
"hope": "Hope",
|
||||||
|
"hitPoints": "Hit Points",
|
||||||
|
"stress": "Stress",
|
||||||
|
"armorStack": "Armor Marks"
|
||||||
},
|
},
|
||||||
"VariantRules": {
|
"VariantRules": {
|
||||||
"FIELDS": {
|
"FIELDS": {
|
||||||
|
|
@ -1313,7 +1317,13 @@
|
||||||
"communityTitle": "Community Card",
|
"communityTitle": "Community Card",
|
||||||
"subclassFeatureTitle": "Subclass Feature"
|
"subclassFeatureTitle": "Subclass Feature"
|
||||||
},
|
},
|
||||||
"featureTitle": "Class Feature"
|
"featureTitle": "Class Feature",
|
||||||
|
"refundResources": {
|
||||||
|
"button": "Refund Resources",
|
||||||
|
"refunded": "Resources Refunded",
|
||||||
|
"confirmTitle": "Refund Resources",
|
||||||
|
"confirmText": "Are you sure you want to refund the following resources?"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Notifications": {
|
"Notifications": {
|
||||||
"adversaryMissing": "The linked adversary doesn't exist in the world.",
|
"adversaryMissing": "The linked adversary doesn't exist in the world.",
|
||||||
|
|
@ -1353,7 +1363,13 @@
|
||||||
"damageAlreadyNone": "The damage has already been reduced to none",
|
"damageAlreadyNone": "The damage has already been reduced to none",
|
||||||
"noAvailableArmorMarks": "You have no more available armor marks",
|
"noAvailableArmorMarks": "You have no more available armor marks",
|
||||||
"notEnoughStress": "You don't have enough stress",
|
"notEnoughStress": "You don't have enough stress",
|
||||||
"damageIgnore": "{character} did not take damage"
|
"damageIgnore": "{character} did not take damage",
|
||||||
|
"actorNotFound": "Actor not found",
|
||||||
|
"noPermissionToRefund": "You don't have permission to refund resources for this actor",
|
||||||
|
"resourcesAlreadyRefunded": "Resources have already been refunded for this action",
|
||||||
|
"noResourcesToRefund": "No resources were spent that can be refunded",
|
||||||
|
"resourcesRefunded": "Resources have been successfully refunded",
|
||||||
|
"refundFailed": "Failed to refund resources"
|
||||||
},
|
},
|
||||||
"Tooltip": {
|
"Tooltip": {
|
||||||
"openItemWorld": "Open Item World",
|
"openItemWorld": "Open Item World",
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
html.querySelectorAll('.action-use-button').forEach(element =>
|
html.querySelectorAll('.action-use-button').forEach(element =>
|
||||||
element.addEventListener('click', event => this.actionUseButton.call(this, event, data.message))
|
element.addEventListener('click', event => this.actionUseButton.call(this, event, data.message))
|
||||||
);
|
);
|
||||||
|
html.querySelectorAll('.refund-resources-button').forEach(element =>
|
||||||
|
element.addEventListener('click', event => this.onRefundResources.call(this, event, data.message))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
setupHooks() {
|
setupHooks() {
|
||||||
|
|
@ -295,4 +298,76 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
|
|
||||||
action.use();
|
action.use();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle refunding resources spent during an action
|
||||||
|
* @param {MouseEvent} event
|
||||||
|
* @param {object} message
|
||||||
|
*/
|
||||||
|
onRefundResources = async (event, message) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
// Get the actor who performed the action
|
||||||
|
const actor = await this.getActor(message.system.source.actor);
|
||||||
|
if (!actor) {
|
||||||
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.Notification.Warn.ActorNotFound'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if user has permission to refund resources
|
||||||
|
if (!actor.isOwner && !game.user.isGM) {
|
||||||
|
ui.notifications.warn(game.i18n.localize('DAGGERHEART.Notification.Warn.NoPermissionToRefund'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if resources were already refunded
|
||||||
|
if (message.system.resourcesRefunded) {
|
||||||
|
ui.notifications.info(game.i18n.localize('DAGGERHEART.Notification.Info.ResourcesAlreadyRefunded'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the resources that were spent (stored in the message)
|
||||||
|
const spentResources = message.system.spentResources;
|
||||||
|
if (!spentResources || spentResources.length === 0) {
|
||||||
|
ui.notifications.info(game.i18n.localize('DAGGERHEART.Notification.Info.NoResourcesToRefund'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirm refund with user
|
||||||
|
const confirm = await foundry.applications.api.DialogV2.confirm({
|
||||||
|
window: { title: game.i18n.localize('DAGGERHEART.Chat.RefundResources.ConfirmTitle') },
|
||||||
|
content: `<p>${game.i18n.localize('DAGGERHEART.Chat.RefundResources.ConfirmText')}</p>
|
||||||
|
<ul>${spentResources.map(r => `<li>${game.i18n.localize('DAGGERHEART.Resources.' + r.type)}: ${r.value}</li>`).join('')}</ul>`
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirm) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Refund the resources by inverting the values
|
||||||
|
const refundResources = spentResources.map(resource => ({
|
||||||
|
...resource,
|
||||||
|
value: -resource.value
|
||||||
|
}));
|
||||||
|
|
||||||
|
await actor.modifyResource(refundResources);
|
||||||
|
|
||||||
|
// Mark the message as refunded to prevent double refunding
|
||||||
|
const chatMessage = game.messages.get(message._id);
|
||||||
|
await chatMessage?.update({
|
||||||
|
system: { resourcesRefunded: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show success notification
|
||||||
|
ui.notifications.info(game.i18n.localize('DAGGERHEART.Notification.Info.ResourcesRefunded'));
|
||||||
|
|
||||||
|
// Disable the refund button visually
|
||||||
|
const button = event.currentTarget;
|
||||||
|
button.disabled = true;
|
||||||
|
button.textContent = game.i18n.localize('DAGGERHEART.Chat.RefundResources.Refunded');
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error refunding resources:', error);
|
||||||
|
ui.notifications.error(game.i18n.localize('DAGGERHEART.Notification.Error.RefundFailed'));
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,11 @@ export default class DHItem extends foundry.documents.Item {
|
||||||
img: this.img,
|
img: this.img,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
description: this.system.description,
|
description: this.system.description,
|
||||||
actions: []
|
actions: this.system.actions ?? [],
|
||||||
|
source: {
|
||||||
|
actor: this.actor?.uuid ?? this.actor?.id ?? null,
|
||||||
|
item: this.id
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const msg = new cls({
|
const msg = new cls({
|
||||||
type: 'abilityUse',
|
type: 'abilityUse',
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@
|
||||||
"rollup": "^4.40.0"
|
"rollup": "^4.40.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "concurrently \"rollup -c --watch\" \"node ../../../../FoundryDev/main.js --dataPath=../../../ --noupnp\" \"gulp\"",
|
"dev": "concurrently \"rollup -c --watch\" \"gulp\"",
|
||||||
"start-test": "node ./resources/app/main.js --dataPath=./ && rollup -c --watch && gulp",
|
"start": "concurrently \"rollup -c --watch\" \"node \\\"C:/Program Files/Foundry Virtual Tabletop V12/resources/app/main.js\\\" --dataPath=\\\"C:/Program Files/Foundry Virtual Tabletop V12/resources/app\\\" --noupnp\" \"gulp\"",
|
||||||
|
"start-test": "node \"C:/Program Files/Foundry Virtual Tabletop V12/resources/app/main.js\" --dataPath=\"C:/Program Files/Foundry Virtual Tabletop V12/resources/app\" && rollup -c --watch && gulp",
|
||||||
"build": "npm run rollup && npm run gulp",
|
"build": "npm run rollup && npm run gulp",
|
||||||
"rollup": "rollup -c",
|
"rollup": "rollup -c",
|
||||||
"gulp": "gulp less",
|
"gulp": "gulp less",
|
||||||
|
|
|
||||||
|
|
@ -4069,10 +4069,11 @@ body.theme-light.application.daggerheart .character-sidebar-sheet .experience-va
|
||||||
.application.sheet.daggerheart.actor.dh-style.character .window-content {
|
.application.sheet.daggerheart.actor.dh-style.character .window-content {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 275px 1fr;
|
grid-template-columns: 275px 1fr;
|
||||||
grid-template-rows: 283px 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
gap: 15px 0;
|
gap: 15px 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
.application.sheet.daggerheart.actor.dh-style.character .window-content .character-sidebar-sheet {
|
.application.sheet.daggerheart.actor.dh-style.character .window-content .character-sidebar-sheet {
|
||||||
grid-row: 1 / span 2;
|
grid-row: 1 / span 2;
|
||||||
|
|
@ -4313,7 +4314,7 @@ body.theme-light.application.daggerheart .character-sidebar-sheet .experience-va
|
||||||
.application.sheet.daggerheart.actor.dh-style.adversary .window-content {
|
.application.sheet.daggerheart.actor.dh-style.adversary .window-content {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 275px 1fr;
|
grid-template-columns: 275px 1fr;
|
||||||
grid-template-rows: 283px 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
gap: 15px 0;
|
gap: 15px 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
<img class="image" src="{{action.img}}" />
|
<img class="image" src="{{action.img}}" />
|
||||||
<span>{{action.name}}</span>
|
<span>{{action.name}}</span>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
<button class="action-use-button" data-index="{{index}}" type="button">Use</button>
|
||||||
<a data-action="removeAction"><i class="fa-solid fa-trash"></i></a>
|
<a data-action="removeAction"><i class="fa-solid fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue