mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
parent
cf571aa2a5
commit
bcedc74bf3
16 changed files with 57 additions and 156 deletions
|
|
@ -111,12 +111,13 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
return actorData;
|
||||
}
|
||||
|
||||
async use(event, ...args) {
|
||||
async use(event, options = {}) {
|
||||
if (!this.actor) throw new Error("An Action can't be used outside of an Actor context.");
|
||||
|
||||
if (this.chatDisplay) await this.toChat();
|
||||
|
||||
let config = this.prepareConfig(event);
|
||||
|
||||
let { byPassRoll } = options,
|
||||
config = this.prepareConfig(event, byPassRoll);
|
||||
for (let i = 0; i < this.constructor.extraSchemas.length; i++) {
|
||||
let clsField = this.constructor.getActionField(this.constructor.extraSchemas[i]);
|
||||
if (clsField?.prepareConfig) {
|
||||
|
|
@ -133,14 +134,14 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
if (!config) return;
|
||||
}
|
||||
|
||||
if (this.hasRoll) {
|
||||
if (config.hasRoll) {
|
||||
const rollConfig = this.prepareRoll(config);
|
||||
config.roll = rollConfig;
|
||||
config = await this.actor.diceRoll(config);
|
||||
if (!config) return;
|
||||
}
|
||||
|
||||
if (this.doFollowUp()) {
|
||||
if (this.doFollowUp(config)) {
|
||||
if (this.rollDamage && this.damage.parts.length) await this.rollDamage(event, config);
|
||||
else if (this.trigger) await this.trigger(event, config);
|
||||
else if (this.hasSave || this.hasEffect) {
|
||||
|
|
@ -160,7 +161,8 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
}
|
||||
|
||||
/* */
|
||||
prepareConfig(event) {
|
||||
prepareConfig(event, byPass = false) {
|
||||
const hasRoll = this.getUseHasRoll(byPass);
|
||||
return {
|
||||
event,
|
||||
title: `${this.item.name}: ${this.name}`,
|
||||
|
|
@ -170,10 +172,10 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
actor: this.actor.uuid
|
||||
},
|
||||
dialog: {
|
||||
configure: this.hasRoll
|
||||
configure: hasRoll
|
||||
},
|
||||
type: this.type,
|
||||
hasRoll: this.hasRoll,
|
||||
hasRoll: hasRoll,
|
||||
hasDamage: this.damage?.parts?.length && this.type !== 'healing',
|
||||
hasHealing: this.damage?.parts?.length && this.type === 'healing',
|
||||
hasEffect: !!this.effects?.length,
|
||||
|
|
@ -182,12 +184,12 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
selectedRollMode: game.settings.get('core', 'rollMode'),
|
||||
isFastForward: event.shiftKey,
|
||||
data: this.getRollData(),
|
||||
evaluate: this.hasRoll
|
||||
evaluate: hasRoll
|
||||
};
|
||||
}
|
||||
|
||||
requireConfigurationDialog(config) {
|
||||
return !config.event.shiftKey && !this.hasRoll && (config.costs?.length || config.uses);
|
||||
return !config.event.shiftKey && !config.hasRoll && (config.costs?.length || config.uses);
|
||||
}
|
||||
|
||||
prepareRoll() {
|
||||
|
|
@ -205,7 +207,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
}
|
||||
|
||||
doFollowUp(config) {
|
||||
return !this.hasRoll;
|
||||
return !config.hasRoll;
|
||||
}
|
||||
|
||||
async consume(config, successCost = false) {
|
||||
|
|
@ -257,6 +259,10 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
/* */
|
||||
|
||||
/* ROLL */
|
||||
getUseHasRoll(byPass = false) {
|
||||
return this.hasRoll && !byPass;
|
||||
}
|
||||
|
||||
get hasRoll() {
|
||||
return !!this.roll?.type;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue