mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 04:01:06 +01:00
Adversary Attack
This commit is contained in:
parent
5a8aed73d2
commit
2981aab917
19 changed files with 269 additions and 499 deletions
|
|
@ -60,45 +60,45 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
super.close(options);
|
||||
}
|
||||
|
||||
getActor(id) {
|
||||
return game.actors.get(id);
|
||||
}
|
||||
|
||||
getAction(actor, itemId, actionId) {
|
||||
const item = actor.items.get(itemId),
|
||||
action = actor.system.attack?._id === actionId ? actor.system.attack : item?.system?.actions?.find(a => a._id === actionId);
|
||||
return action;
|
||||
}
|
||||
|
||||
onRollDamage = async (event, message) => {
|
||||
event.stopPropagation();
|
||||
const actor = game.actors.get(message.system.source.actor);
|
||||
const actor = this.getActor(message.system.source.actor);
|
||||
if (!actor || !game.user.isGM) return true;
|
||||
if(message.system.source.item && message.system.source.action) {
|
||||
const item = actor.items.get(message.system.source.item),
|
||||
action = item?.system?.actions?.find(a => a._id === message.system.source.action);
|
||||
if(!item || !action || !action?.rollDamage) return;
|
||||
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
||||
if(!action || !action?.rollDamage) return;
|
||||
await action.rollDamage(event, message);
|
||||
} else {
|
||||
await actor.damageRoll(
|
||||
message.system.title,
|
||||
message.system.damage,
|
||||
message.system.targets.filter(x => x.hit).map(x => ({ id: x.id, name: x.name, img: x.img })),
|
||||
event.shiftKey
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
onRollHealing = async (event, message) => {
|
||||
event.stopPropagation();
|
||||
const actor = game.actors.get(message.system.source.actor);
|
||||
const actor = this.getActor(message.system.source.actor);
|
||||
if (!actor || !game.user.isGM) return true;
|
||||
if(message.system.source.item && message.system.source.action) {
|
||||
const item = actor.items.get(message.system.source.item),
|
||||
action = item?.system?.actions?.find(a => a._id === message.system.source.action);
|
||||
if(!item || !action || !action?.rollHealing) return;
|
||||
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
||||
if(!action || !action?.rollHealing) return;
|
||||
await action.rollHealing(event, message);
|
||||
}
|
||||
};
|
||||
|
||||
onApplyEffect = async (event, message) => {
|
||||
event.stopPropagation();
|
||||
const actor = game.actors.get(message.system.source.actor);
|
||||
const actor = this.getActor(message.system.source.actor);
|
||||
if (!actor || !game.user.isGM) return true;
|
||||
if(message.system.source.item && message.system.source.action) {
|
||||
const item = actor.items.get(message.system.source.item),
|
||||
action = item?.system?.actions?.find(a => a._id === message.system.source.action);
|
||||
if(!item || !action || !action.applyEffects) return;
|
||||
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
||||
if(!action || !action?.applyEffects) return;
|
||||
await action.applyEffects(event, message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue