mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 13:41: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 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 {
|
export class DHRoll extends Roll {
|
||||||
constructor(formula, data, options) {
|
constructor(formula, data, options) {
|
||||||
|
|
@ -31,7 +37,7 @@ export class DHRoll extends Roll {
|
||||||
config = await DialogClass.configure(config, message);
|
config = await DialogClass.configure(config, message);
|
||||||
}
|
}
|
||||||
console.log(config)
|
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 ) {
|
for ( const hook of config.hooks ) {
|
||||||
if ( Hooks.call(`${SYSTEM.id}.post${hook.capitalize()}RollConfiguration`, roll, config, message) === false ) return [];
|
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 messageType = 'damageRoll';
|
||||||
|
|
||||||
static DefaultDialog = D20RollDialog;
|
static DefaultDialog = DamageDialog;
|
||||||
|
|
||||||
get messageType() {
|
|
||||||
return 'damageRoll';
|
|
||||||
}
|
|
||||||
|
|
||||||
get messageTemplate() {
|
get messageTemplate() {
|
||||||
return '';
|
return 'systems/daggerheart/templates/chat/damage-roll.hbs';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,10 +7,11 @@ const fields = foundry.data.fields;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ToDo
|
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
|
- Target Check / Target Picker
|
||||||
- Range Check
|
- Range Check
|
||||||
- Area of effect and measurement placement
|
- Area of effect and measurement placement
|
||||||
- Handle Roll result as part of formula if needed
|
|
||||||
- Summon Action create method
|
- Summon Action create method
|
||||||
|
|
||||||
- Create classes form Target, Cost, etc ?
|
- Create classes form Target, Cost, etc ?
|
||||||
|
|
@ -390,7 +391,18 @@ export class DHDamageAction extends DHBaseAction {
|
||||||
let roll = { formula: formula, total: formula },
|
let roll = { formula: formula, total: formula },
|
||||||
bonusDamage = [];
|
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, _) => {
|
const dialogClosed = new Promise((resolve, _) => {
|
||||||
new DamageSelectionDialog(formula, bonusDamage, resolve).render(true);
|
new DamageSelectionDialog(formula, bonusDamage, resolve).render(true);
|
||||||
});
|
});
|
||||||
|
|
@ -444,7 +456,7 @@ export class DHDamageAction extends DHBaseAction {
|
||||||
rolls: [roll]
|
rolls: [roll]
|
||||||
});
|
});
|
||||||
|
|
||||||
cls.create(msg.toObject());
|
cls.create(msg.toObject()); */
|
||||||
}
|
}
|
||||||
|
|
||||||
get chatTemplate() {
|
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">
|
<div class="form-group">
|
||||||
<label><strong>Total Damage</strong></label>
|
<label><strong>Total Damage</strong></label>
|
||||||
<div class="form-fields">
|
<div class="form-fields">
|
||||||
<input type="text" value="{{rollString}}" disabled />
|
<input type="text" value="{{formula}}" disabled />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{#each bonusDamage as |damage index|}}
|
{{!-- {{#each bonusDamage as |damage index|}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label><strong>{{damage.description}}</strong></label>
|
<label><strong>{{damage.description}}</strong></label>
|
||||||
<div class="form-fields">
|
<div class="form-fields">
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}} --}}
|
||||||
<footer>
|
<footer>
|
||||||
<button data-action="rollDamage">Roll</button>
|
<button data-action="close">Roll</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue