mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
Create files
This commit is contained in:
parent
bf31ced3df
commit
af01f8f1b2
6 changed files with 79 additions and 12 deletions
|
|
@ -19,7 +19,6 @@ import {
|
|||
} from './module/systemRegistration/_module.mjs';
|
||||
import { placeables } from './module/canvas/_module.mjs';
|
||||
import { registerRollDiceHooks } from './module/dice/dhRoll.mjs';
|
||||
import { registerDHActorHooks } from './module/documents/actor.mjs';
|
||||
import './node_modules/@yaireo/tagify/dist/tagify.css';
|
||||
|
||||
Hooks.once('init', () => {
|
||||
|
|
@ -169,7 +168,7 @@ Hooks.on('ready', () => {
|
|||
registerCountdownHooks();
|
||||
socketRegistration.registerSocketHooks();
|
||||
registerRollDiceHooks();
|
||||
registerDHActorHooks();
|
||||
socketRegistration.registerUserQueries();
|
||||
});
|
||||
|
||||
Hooks.once('dicesoniceready', () => {});
|
||||
|
|
|
|||
|
|
@ -8,3 +8,4 @@ export { default as Downtime } from './downtime.mjs';
|
|||
export { default as OwnershipSelection } from './ownershipSelection.mjs';
|
||||
export { default as ResourceDiceDialog } from './resourceDiceDialog.mjs';
|
||||
export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs';
|
||||
export { default as ReactionRollDialog } from './reactionRollDialog.mjs';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { damageKeyToNumber, getDamageLabel } from '../../helpers/utils.mjs';
|
||||
|
||||
const { DialogV2, ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class DamageReductionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(resolve, reject, actor, damage, damageType) {
|
||||
|
|
@ -53,10 +53,6 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
);
|
||||
}
|
||||
|
||||
get title() {
|
||||
return game.i18n.localize('DAGGERHEART.APPLICATIONS.DamageReduction.title');
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ['daggerheart', 'views', 'damage-reduction'],
|
||||
|
|
|
|||
68
module/applications/dialogs/reactionRollDialog.mjs
Normal file
68
module/applications/dialogs/reactionRollDialog.mjs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
|
||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class ReactionRollDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(resolve, reject, actor, trait) {
|
||||
super({});
|
||||
|
||||
this.resolve = resolve;
|
||||
this.reject = reject;
|
||||
this.actor = actor;
|
||||
this.trait = trait;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
classes: ['daggerheart', 'views', 'damage-reduction'],
|
||||
position: {
|
||||
width: 240,
|
||||
height: 'auto'
|
||||
},
|
||||
actions: {
|
||||
// setMarks: this.setMarks,
|
||||
// useStressReduction: this.useStressReduction,
|
||||
// takeDamage: this.takeDamage
|
||||
},
|
||||
form: {
|
||||
handler: this.updateData,
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
damageSelection: {
|
||||
id: 'damageReduction',
|
||||
template: 'systems/daggerheart/templates/dialogs/damageReduction.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @inheritDoc */
|
||||
get title() {
|
||||
return game.i18n.localize('DAGGERHEART.APPLICATIONS.DamageReduction.title');
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static updateData(event, _, formData) {
|
||||
const form = foundry.utils.expandObject(formData.object);
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
static async reactionRollQuery({ actorId, trait }) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const actor = await fromUuid(actorId);
|
||||
if (!actor || !actor?.isOwner) reject();
|
||||
new ReactionRollDialog(resolve, reject, actor, trait).render({ force: true });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import { emitAsGM, GMUpdateEvent } from '../systemRegistration/socket.mjs';
|
||||
import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs';
|
||||
import { LevelOptionType } from '../data/levelTier.mjs';
|
||||
import DHFeature from '../data/item/feature.mjs';
|
||||
import { damageKeyToNumber } from '../helpers/utils.mjs';
|
||||
|
|
@ -584,7 +583,3 @@ export default class DhpActor extends Actor {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const registerDHActorHooks = () => {
|
||||
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs';
|
||||
import ReactionRollDialog from '../applications/dialogs/reactionRollDialog.mjs';
|
||||
|
||||
export function handleSocketEvent({ action = null, data = {} } = {}) {
|
||||
switch (action) {
|
||||
case socketEvent.GMUpdate:
|
||||
|
|
@ -69,6 +72,11 @@ export const registerSocketHooks = () => {
|
|||
});
|
||||
};
|
||||
|
||||
export const registerUserQueries = () => {
|
||||
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
|
||||
CONFIG.queries.reactionRoll = ReactionRollDialog.reactionRollQuery;
|
||||
}
|
||||
|
||||
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
||||
if (!game.user.isGM) {
|
||||
return await game.socket.emit(`system.${CONFIG.DH.id}`, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue