mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Split methods
This commit is contained in:
parent
42df9c6318
commit
b09cd8a692
14 changed files with 437 additions and 213 deletions
|
|
@ -62,7 +62,6 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
if (!!this.action.effects) context.effects = this.action.effects.map(e => this.action.item.effects.get(e._id));
|
||||
if (this.action.damage?.hasOwnProperty('includeBase') && this.action.type === 'attack') context.hasBaseDamage = !!this.action.parent.damage;
|
||||
context.getRealIndex = this.getRealIndex.bind(this);
|
||||
console.log(context)
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
|
|||
64
module/applications/costSelectionDialog.mjs
Normal file
64
module/applications/costSelectionDialog.mjs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class CostSelectionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(cost, resolve) {
|
||||
super({});
|
||||
this.cost = cost;
|
||||
this.resolve = resolve;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ['daggerheart', 'views', 'damage-selection'],
|
||||
position: {
|
||||
width: 400,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
sendHope: this.sendHope
|
||||
},
|
||||
form: {
|
||||
handler: this.updateForm,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
damageSelection: {
|
||||
id: 'costSelection',
|
||||
template: 'systems/daggerheart/templates/views/costSelection.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @inheritDoc */
|
||||
get title() {
|
||||
return `Cost Options`;
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
return {
|
||||
cost: this.cost.map(c => {
|
||||
c.scale = c.scale ?? 1;
|
||||
c.step = c.step ?? 1;
|
||||
c.total = c.value * c.scale * c.step;
|
||||
c.enabled = c.hasOwnProperty('enabled') ? c.enabled : true;
|
||||
return c
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
static async updateForm(event, _, formData) {
|
||||
this.cost = foundry.utils.mergeObject(this.cost, foundry.utils.expandObject(formData.object));
|
||||
this.render(true)
|
||||
}
|
||||
|
||||
static sendHope(event) {
|
||||
event.preventDefault();
|
||||
this.resolve(this.cost.filter(c => c.enabled));
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue