mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[feature] Action UsesButton (#662)
* Added a button to spend/restore uses of an action * Fixed some compendium Uses on actions * Went over all item compendia and fixed some Uses on actions * Fixed folder order in Subclass compendium
This commit is contained in:
parent
ead2f6b8f3
commit
a1a3ccc461
70 changed files with 471 additions and 358 deletions
|
|
@ -38,7 +38,9 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
};
|
||||
|
||||
get title() {
|
||||
return game.i18n.localize(`DAGGERHEART.EFFECTS.ApplyLocations.${this.config.hasHealing ? 'healing' : 'damage'}Roll.name`);
|
||||
return game.i18n.localize(
|
||||
`DAGGERHEART.EFFECTS.ApplyLocations.${this.config.hasHealing ? 'healing' : 'damage'}Roll.name`
|
||||
);
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
|
|
|
|||
|
|
@ -233,7 +233,11 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
|||
const feature = await foundry.utils.fromUuid(data.uuid);
|
||||
const increasing =
|
||||
feature.system.resource.progression === CONFIG.DH.ITEM.itemResourceProgression.increasing.id;
|
||||
const resetValue = increasing ? 0 : (feature.system.resource.max ?? 0);
|
||||
const resetValue = increasing
|
||||
? 0
|
||||
: feature.system.resource.max
|
||||
? Roll.replaceFormulaData(feature.system.resource.max, this.actor)
|
||||
: 0;
|
||||
await feature.update({ 'system.resource.value': resetValue });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
},
|
||||
actions: {
|
||||
openSettings: DHBaseActorSheet.#openSettings,
|
||||
sendExpToChat: DHBaseActorSheet.#sendExpToChat
|
||||
sendExpToChat: DHBaseActorSheet.#sendExpToChat,
|
||||
increaseActionUses: event => DHBaseActorSheet.#modifyActionUses(event, true)
|
||||
},
|
||||
contextMenus: [
|
||||
{
|
||||
|
|
@ -70,6 +71,15 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
return context;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
htmlElement.querySelectorAll('.item-button .action-uses-button').forEach(element => {
|
||||
element.addEventListener('contextmenu', DHBaseActorSheet.#modifyActionUses);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare render context for the Effect part.
|
||||
* @param {ApplicationRenderContext} context
|
||||
|
|
@ -154,6 +164,20 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
cls.create(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static async #modifyActionUses(event, increase) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
const actionId = event.target.dataset.itemUuid;
|
||||
const action = await foundry.utils.fromUuid(actionId);
|
||||
|
||||
const newValue = (action.uses.value ?? 0) + (increase ? 1 : -1);
|
||||
await action.update({ 'uses.value': Math.min(Math.max(newValue, 0), action.uses.max ?? 0) });
|
||||
this.render();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Drag/Drop */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -164,6 +164,12 @@ export function ActionMixin(Base) {
|
|||
return foundry.utils.getProperty(this.parent, this.systemPath) instanceof Collection;
|
||||
}
|
||||
|
||||
get remainingUses() {
|
||||
if (!this.uses) return null;
|
||||
|
||||
return Math.max((this.uses.max ?? 0) - (this.uses.value ?? 0), 0);
|
||||
}
|
||||
|
||||
static async create(data, operation = {}) {
|
||||
const { parent, renderSheet } = operation;
|
||||
let { type } = data;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@ export default class DamageRoll extends DHRoll {
|
|||
static DefaultDialog = DamageDialog;
|
||||
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
if (config.evaluate !== false)
|
||||
for (const roll of config.roll) await roll.roll.evaluate();
|
||||
|
||||
if (config.evaluate !== false) for (const roll of config.roll) await roll.roll.evaluate();
|
||||
|
||||
roll._evaluated = true;
|
||||
const parts = config.roll.map(r => this.postEvaluate(r));
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ export default class DamageRoll extends DHRoll {
|
|||
if (config.source?.message) {
|
||||
const chatMessage = ui.chat.collection.get(config.source.message);
|
||||
chatMessage.update({ 'system.damage': config.damage });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static unifyDamageRoll(rolls) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue