mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
Merge branch 'main' into feature/death-moves
This commit is contained in:
commit
6ea09551fe
19 changed files with 49 additions and 173 deletions
|
|
@ -712,7 +712,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
|
||||
ability: abilityLabel
|
||||
}),
|
||||
effects: Array.from(await this.document.allApplicableEffects()),
|
||||
effects: await game.system.api.data.actions.actionsTypes.base.getEffects(this.document),
|
||||
roll: {
|
||||
trait: button.dataset.attribute,
|
||||
type: 'trait'
|
||||
|
|
|
|||
|
|
@ -505,7 +505,10 @@ export default function DHApplicationMixin(Base) {
|
|||
const doc = await getDocFromElement(target),
|
||||
action = doc?.system?.attack ?? doc;
|
||||
const config = action.prepareConfig(event);
|
||||
config.effects = Array.from(await this.document.allApplicableEffects());
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
let config = this.prepareConfig(event);
|
||||
if (!config) return;
|
||||
|
||||
await this.addEffects(config);
|
||||
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(this.actor, this.item);
|
||||
|
||||
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
||||
|
||||
|
|
@ -266,14 +266,26 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
return config;
|
||||
}
|
||||
|
||||
/** */
|
||||
async addEffects(config) {
|
||||
let effects = [];
|
||||
if (this.actor) {
|
||||
effects = Array.from(await this.actor.allApplicableEffects());
|
||||
}
|
||||
/**
|
||||
* Get the all potentially applicable effects on the actor
|
||||
* @param {DHActor} actor The actor performing the action
|
||||
* @param {DHItem|DhActor} effectParent The parent of the effect
|
||||
* @returns {DhActiveEffect[]}
|
||||
*/
|
||||
static async getEffects(actor, effectParent) {
|
||||
if (!actor) return [];
|
||||
|
||||
config.effects = effects;
|
||||
return Array.from(await actor.allApplicableEffects()).filter(effect => {
|
||||
/* Effects on weapons only ever apply for the weapon itself */
|
||||
if (effect.parent.type === 'weapon') {
|
||||
/* Unless they're secondary - then they apply only to other primary weapons */
|
||||
if (effect.parent.system.secondary) {
|
||||
if (effectParent?.type !== 'weapon' || effectParent?.system.secondary) return false;
|
||||
} else if (effectParent?.id !== effect.parent.id) return false;
|
||||
}
|
||||
|
||||
return !effect.isSuppressed;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -167,7 +167,9 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
const config = foundry.utils.deepClone(this.system);
|
||||
config.event = event;
|
||||
if (this.system.action) {
|
||||
await this.system.action.addEffects(config);
|
||||
const actor = await foundry.utils.fromUuid(config.source.actor);
|
||||
const item = actor?.items.get(config.source.item) ?? null;
|
||||
config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(actor, item);
|
||||
await this.system.action.workflow.get('damage')?.execute(config, this._id, true);
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +203,16 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelectedOrPerm'));
|
||||
|
||||
this.consumeOnSuccess();
|
||||
this.system.action?.workflow.get('applyDamage')?.execute(config, targets, true);
|
||||
if (this.system.action) this.system.action.workflow.get('applyDamage')?.execute(config, targets, true);
|
||||
else {
|
||||
for (const target of targets) {
|
||||
const actor = await foundry.utils.fromUuid(target.actorId);
|
||||
if (!actor) continue;
|
||||
|
||||
if (this.system.hasHealing) actor.takeHealing(this.system.damage);
|
||||
else actor.takeDamage(this.system.damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async onRollSave(event) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue