mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
g
This commit is contained in:
parent
1c90024a5d
commit
385d414d7d
4 changed files with 75 additions and 14 deletions
|
|
@ -1,4 +1,10 @@
|
|||
import D20RollDialog from '../dialogs/d20RollDialog.mjs';
|
||||
import DamageDialog from '../dialogs/damageDialog.mjs';
|
||||
|
||||
/*
|
||||
- Damage & other resources roll
|
||||
- Close dialog => don't roll
|
||||
*/
|
||||
|
||||
export class DHRoll extends Roll {
|
||||
constructor(formula, data, options) {
|
||||
|
|
@ -31,7 +37,7 @@ export class DHRoll extends Roll {
|
|||
config = await DialogClass.configure(config, message);
|
||||
}
|
||||
console.log(config)
|
||||
let roll = new this('', config.actor, config);
|
||||
let roll = new this(config.formula, config.actor, config);
|
||||
|
||||
for ( const hook of config.hooks ) {
|
||||
if ( Hooks.call(`${SYSTEM.id}.post${hook.capitalize()}RollConfiguration`, roll, config, message) === false ) return [];
|
||||
|
|
@ -381,13 +387,9 @@ export class DamageRoll extends DHRoll {
|
|||
|
||||
static messageType = 'damageRoll';
|
||||
|
||||
static DefaultDialog = D20RollDialog;
|
||||
|
||||
get messageType() {
|
||||
return 'damageRoll';
|
||||
}
|
||||
static DefaultDialog = DamageDialog;
|
||||
|
||||
get messageTemplate() {
|
||||
return '';
|
||||
return 'systems/daggerheart/templates/chat/damage-roll.hbs';
|
||||
}
|
||||
}
|
||||
|
|
@ -7,10 +7,11 @@ const fields = foundry.data.fields;
|
|||
|
||||
/*
|
||||
ToDo
|
||||
- Add setting for Hope/Fear result on Damage, Heal, Resource (Handle Roll result as part of formula if needed)
|
||||
- Add setting and/or checkbox for cost and damage like
|
||||
- Target Check / Target Picker
|
||||
- Range Check
|
||||
- Area of effect and measurement placement
|
||||
- Handle Roll result as part of formula if needed
|
||||
- Summon Action create method
|
||||
|
||||
- Create classes form Target, Cost, etc ?
|
||||
|
|
@ -390,7 +391,18 @@ export class DHDamageAction extends DHBaseAction {
|
|||
let roll = { formula: formula, total: formula },
|
||||
bonusDamage = [];
|
||||
|
||||
if (!event.shiftKey) {
|
||||
const config = {
|
||||
title: game.i18n.format('DAGGERHEART.Chat.DamageRoll.Title', { damage: this.name }),
|
||||
formula,
|
||||
chatMessage: {
|
||||
template: 'systems/daggerheart/templates/chat/damage-roll.hbs'
|
||||
},
|
||||
targets: (data.system?.targets ?? data.targets).map(x => ({ id: x.id, name: x.name, img: x.img, hit: true }))
|
||||
}
|
||||
|
||||
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config)
|
||||
|
||||
/* if (!event.shiftKey) {
|
||||
const dialogClosed = new Promise((resolve, _) => {
|
||||
new DamageSelectionDialog(formula, bonusDamage, resolve).render(true);
|
||||
});
|
||||
|
|
@ -444,7 +456,7 @@ export class DHDamageAction extends DHBaseAction {
|
|||
rolls: [roll]
|
||||
});
|
||||
|
||||
cls.create(msg.toObject());
|
||||
cls.create(msg.toObject()); */
|
||||
}
|
||||
|
||||
get chatTemplate() {
|
||||
|
|
|
|||
47
module/dialogs/damageDialog.mjs
Normal file
47
module/dialogs/damageDialog.mjs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class DamageDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(config={}, options={}) {
|
||||
super(options);
|
||||
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: 'roll-selection',
|
||||
classes: ['daggerheart', 'views', 'damage-selection'],
|
||||
position: {
|
||||
width: 400,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {},
|
||||
form: {
|
||||
handler: this.updateRollConfiguration,
|
||||
submitOnChange: true,
|
||||
submitOnClose: false
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
damageSelection: {
|
||||
id: 'damageSelection',
|
||||
template: 'systems/daggerheart/templates/views/damageSelection.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.formula = this.config.formula;
|
||||
return context;
|
||||
}
|
||||
|
||||
static async configure(config={}) {
|
||||
return new Promise(resolve => {
|
||||
const app = new this(config);
|
||||
app.addEventListener("close", () => resolve(app.config), { once: true });
|
||||
app.render({ force: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
<div class="form-group">
|
||||
<label><strong>Total Damage</strong></label>
|
||||
<div class="form-fields">
|
||||
<input type="text" value="{{rollString}}" disabled />
|
||||
<input type="text" value="{{formula}}" disabled />
|
||||
</div>
|
||||
</div>
|
||||
{{#each bonusDamage as |damage index|}}
|
||||
{{!-- {{#each bonusDamage as |damage index|}}
|
||||
<div class="form-group">
|
||||
<label><strong>{{damage.description}}</strong></label>
|
||||
<div class="form-fields">
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
{{/each}} --}}
|
||||
<footer>
|
||||
<button data-action="rollDamage">Roll</button>
|
||||
<button data-action="close">Roll</button>
|
||||
</footer>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue