mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-05 20:34:15 +02:00
[Fix] Base Attack Context Menu (#1961)
* Fixed Adversary standard attack context menu * Fixed Character base attack context menu * Fixed Companion base attack context menu
This commit is contained in:
parent
bcf274f1d0
commit
3c36c5747d
5 changed files with 72 additions and 2 deletions
|
|
@ -31,6 +31,16 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
||||||
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
||||||
dropSelector: null
|
dropSelector: null
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
contextMenus: [
|
||||||
|
{
|
||||||
|
handler: DHBaseActorSheet.getBaseAttackContextOptions,
|
||||||
|
selector: '[data-item-uuid][data-type="attack"]',
|
||||||
|
options: {
|
||||||
|
parentClassHooks: false,
|
||||||
|
fixed: true
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,14 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
fixed: true
|
fixed: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
handler: DHBaseActorSheet.getBaseAttackContextOptions,
|
||||||
|
selector: '[data-item-uuid][data-type="attack"]',
|
||||||
|
options: {
|
||||||
|
parentClassHooks: false,
|
||||||
|
fixed: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
handler: CharacterSheet.#getDomainCardContextOptions,
|
handler: CharacterSheet.#getDomainCardContextOptions,
|
||||||
selector: '[data-item-uuid][data-type="domainCard"]',
|
selector: '[data-item-uuid][data-type="domainCard"]',
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,17 @@ export default class DhCompanionSheet extends DHBaseActorSheet {
|
||||||
toggleStress: DhCompanionSheet.#toggleStress,
|
toggleStress: DhCompanionSheet.#toggleStress,
|
||||||
actionRoll: DhCompanionSheet.#actionRoll,
|
actionRoll: DhCompanionSheet.#actionRoll,
|
||||||
levelManagement: DhCompanionSheet.#levelManagement
|
levelManagement: DhCompanionSheet.#levelManagement
|
||||||
}
|
},
|
||||||
|
contextMenus: [
|
||||||
|
{
|
||||||
|
handler: DHBaseActorSheet.getBaseAttackContextOptions,
|
||||||
|
selector: '[data-item-uuid][data-type="attack"]',
|
||||||
|
options: {
|
||||||
|
parentClassHooks: false,
|
||||||
|
fixed: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
static PARTS = {
|
static PARTS = {
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,43 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
||||||
return this._getContextMenuCommonOptions.call(this, { usable: true, toChat: true });
|
return this._getContextMenuCommonOptions.call(this, { usable: true, toChat: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the set of ContextMenu options for the base attack.
|
||||||
|
* @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} - The Array of context options passed to the ContextMenu instance
|
||||||
|
* @this {CharacterSheet}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
static getBaseAttackContextOptions() {
|
||||||
|
/**@type {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} */
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: 'DAGGERHEART.CONFIG.RollTypes.attack.name',
|
||||||
|
icon: 'fa-solid fa-burst',
|
||||||
|
onClick: async (event, target) => (await getDocFromElement(target)).use(event)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'DAGGERHEART.GENERAL.damage',
|
||||||
|
icon: 'fa-solid fa-explosion',
|
||||||
|
onClick: async (event, target) => {
|
||||||
|
const doc = await getDocFromElement(target),
|
||||||
|
action = doc?.system?.attack ?? doc;
|
||||||
|
const config = action.prepareConfig(event);
|
||||||
|
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(
|
||||||
|
this.document,
|
||||||
|
doc
|
||||||
|
);
|
||||||
|
config.hasRoll = false;
|
||||||
|
return action && action.workflow.get('damage').execute(config, null, true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'DAGGERHEART.APPLICATIONS.ContextMenu.sendToChat',
|
||||||
|
icon: 'fa-solid fa-message',
|
||||||
|
onClick: async (_, target) => (await getDocFromElement(target)).toChat(this.document.uuid)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Application Listener Actions */
|
/* Application Listener Actions */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,12 @@ export default class DHAttackAction extends DHDamageAction {
|
||||||
const useAltDamage = this.actor?.effects?.find(x => x.type === 'horde')?.active;
|
const useAltDamage = this.actor?.effects?.find(x => x.type === 'horde')?.active;
|
||||||
for (const { value, valueAlt, type } of damage.parts) {
|
for (const { value, valueAlt, type } of damage.parts) {
|
||||||
const usedValue = useAltDamage ? valueAlt : value;
|
const usedValue = useAltDamage ? valueAlt : value;
|
||||||
const str = Roll.replaceFormulaData(usedValue.getFormula(), this.actor?.getRollData() ?? {});
|
const damageString = Roll.replaceFormulaData(usedValue.getFormula(), this.actor?.getRollData() ?? {});
|
||||||
|
const str = damageString
|
||||||
|
? damageString
|
||||||
|
: game.i18n.format('DAGGERHEART.GENERAL.missingX', {
|
||||||
|
x: game.i18n.localize('DAGGERHEART.GENERAL.damage')
|
||||||
|
});
|
||||||
|
|
||||||
const icons = Array.from(type)
|
const icons = Array.from(type)
|
||||||
.map(t => CONFIG.DH.GENERAL.damageTypes[t]?.icon)
|
.map(t => CONFIG.DH.GENERAL.damageTypes[t]?.icon)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue