File Structure Rework (#262)

* Restructured all the files

* Moved build/daggerheart.js to ./daggerheart.js. Changed rollup to use the css file instead of the less

* Restored build/ folder

* Mvoed config out form under application

* Moved roll.mjs to module/dice and renamed to dhRolls.mjs

* Update module/canvas/placeables/_module.mjs

Co-authored-by: joaquinpereyra98 <24190917+joaquinpereyra98@users.noreply.github.com>

* Le massive export update

* Removed unncessary import

---------

Co-authored-by: joaquinpereyra98 <24190917+joaquinpereyra98@users.noreply.github.com>
This commit is contained in:
WBHarry 2025-07-05 00:26:33 +02:00 committed by GitHub
parent 099a4576da
commit 9d76405221
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
203 changed files with 1556 additions and 2565 deletions

View file

@ -1,25 +1,20 @@
import {
DHAttackAction,
DHBaseAction,
DhBeastformAction,
DHDamageAction,
DHEffectAction,
DHHealingAction,
DHMacroAction,
// DHResourceAction,
// DHSpellCastAction,
DHSummonAction
} from './action.mjs';
export * as ActionDice from './actionDice.mjs';
import AttackAction from './attackAction.mjs';
import BaseAction from './baseAction.mjs';
import BeastformAction from './beastformAction.mjs';
import DamageAction from './damageAction.mjs';
import EffectAction from './effectAction.mjs';
import HealingAction from './healingAction.mjs';
import MacroAction from './macroAction.mjs';
import SummonAction from './summonAction.mjs';
export const actionsTypes = {
base: DHBaseAction,
attack: DHAttackAction,
// spellcast: DHSpellCastAction,
// resource: DHResourceAction,
damage: DHDamageAction,
healing: DHHealingAction,
summon: DHSummonAction,
effect: DHEffectAction,
macro: DHMacroAction,
beastform: DhBeastformAction
base: BaseAction,
attack: AttackAction,
damage: DamageAction,
healing: HealingAction,
summon: SummonAction,
effect: EffectAction,
macro: MacroAction,
beastform: BeastformAction
};

View file

@ -8,21 +8,25 @@ export class DHActionRollData extends foundry.abstract.DataModel {
/** @override */
static defineSchema() {
return {
type: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.GENERAL.rollTypes }),
trait: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.ACTOR.abilities }),
type: new fields.StringField({ nullable: true, initial: null, choices: CONFIG.DH.GENERAL.rollTypes }),
trait: new fields.StringField({ nullable: true, initial: null, choices: CONFIG.DH.ACTOR.abilities }),
difficulty: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true }),
advState: new fields.StringField({ choices: SYSTEM.ACTIONS.advandtageState, initial: 'neutral' }),
advState: new fields.StringField({ choices: CONFIG.DH.ACTIONS.advandtageState, initial: 'neutral' }),
diceRolling: new fields.SchemaField({
multiplier: new fields.StringField({
choices: SYSTEM.GENERAL.diceSetNumbers,
choices: CONFIG.DH.GENERAL.diceSetNumbers,
initial: 'prof',
label: 'Dice Number'
}),
flatMultiplier: new fields.NumberField({ nullable: true, initial: 1, label: 'Flat Multiplier' }),
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Dice Type' }),
dice: new fields.StringField({
choices: CONFIG.DH.GENERAL.diceTypes,
initial: 'd6',
label: 'Dice Type'
}),
compare: new fields.StringField({
choices: SYSTEM.ACTIONS.diceCompare,
choices: CONFIG.DH.ACTIONS.diceCompare,
initial: 'above',
label: 'Should be'
}),
@ -40,7 +44,7 @@ export class DHActionRollData extends foundry.abstract.DataModel {
this.diceRolling.multiplier === 'flat'
? this.diceRolling.flatMultiplier
: `@${this.diceRolling.multiplier}`;
formula = `${multiplier}${this.diceRolling.dice}cs${SYSTEM.ACTIONS.diceCompare[this.diceRolling.compare].operator}${this.diceRolling.treshold}`;
formula = `${multiplier}${this.diceRolling.dice}cs${CONFIG.DH.ACTIONS.diceCompare[this.diceRolling.compare].operator}${this.diceRolling.treshold}`;
break;
default:
// formula = `${(!!this.parent?.actor?.system?.attack ? `@attackBonus` : `@traits.${this.trait}.total`)}`;
@ -58,12 +62,12 @@ export class DHActionDiceData extends foundry.abstract.DataModel {
static defineSchema() {
return {
multiplier: new fields.StringField({
choices: SYSTEM.GENERAL.multiplierTypes,
choices: CONFIG.DH.GENERAL.multiplierTypes,
initial: 'prof',
label: 'Multiplier'
}),
flatMultiplier: new fields.NumberField({ nullable: true, initial: 1, label: 'Flat Multiplier' }),
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Dice' }),
dice: new fields.StringField({ choices: CONFIG.DH.GENERAL.diceTypes, initial: 'd6', label: 'Dice' }),
bonus: new fields.NumberField({ nullable: true, initial: null, label: 'Bonus' }),
custom: new fields.SchemaField({
enabled: new fields.BooleanField({ label: 'Custom Formula' }),
@ -101,7 +105,7 @@ export class DHDamageData extends foundry.abstract.DataModel {
// ...super.defineSchema(),
base: new fields.BooleanField({ initial: false, readonly: true, label: 'Base' }),
type: new fields.StringField({
choices: SYSTEM.GENERAL.damageTypes,
choices: CONFIG.DH.GENERAL.damageTypes,
initial: 'physical',
label: 'Type',
nullable: false,

View file

@ -0,0 +1,34 @@
import { DHDamageData } from './actionDice.mjs';
import DHDamageAction from './damageAction.mjs';
export default class DHAttackAction extends DHDamageAction {
static extraSchemas = [...super.extraSchemas, ...['roll', 'save']];
static getRollType(parent) {
return parent.type === 'weapon' ? 'weapon' : 'spellcast';
}
get chatTemplate() {
return 'systems/daggerheart/templates/ui/chat/duality-roll.hbs';
}
prepareData() {
super.prepareData();
if (this.damage.includeBase && !!this.item?.system?.damage) {
const baseDamage = this.getParentDamage();
this.damage.parts.unshift(new DHDamageData(baseDamage));
}
}
getParentDamage() {
return {
value: {
multiplier: 'prof',
dice: this.item?.system?.damage.dice,
bonus: this.item?.system?.damage.bonus ?? 0
},
type: this.item?.system?.damage.type,
base: true
};
}
}

View file

@ -1,7 +1,6 @@
import { DHActionDiceData, DHActionRollData, DHDamageData, DHDamageField } from './actionDice.mjs';
import DhpActor from '../../documents/actor.mjs';
import D20RollDialog from '../../dialogs/d20RollDialog.mjs';
import BeastformDialog from '../../dialogs/beastformDialog.mjs';
import D20RollDialog from '../../applications/dialogs/d20RollDialog.mjs';
const fields = foundry.data.fields;
@ -21,7 +20,7 @@ const fields = foundry.data.fields;
- Auto use action <= Into Roll
*/
export class DHBaseAction extends foundry.abstract.DataModel {
export default class DHBaseAction extends foundry.abstract.DataModel {
static extraSchemas = [];
static defineSchema() {
@ -33,11 +32,15 @@ export class DHBaseAction extends foundry.abstract.DataModel {
description: new fields.HTMLField(),
img: new fields.FilePathField({ initial: undefined, categories: ['IMAGE'], base64: false }),
chatDisplay: new fields.BooleanField({ initial: true, label: 'Display in chat' }),
actionType: new fields.StringField({ choices: SYSTEM.ITEM.actionTypes, initial: 'action', nullable: true }),
actionType: new fields.StringField({
choices: CONFIG.DH.ITEM.actionTypes,
initial: 'action',
nullable: true
}),
cost: new fields.ArrayField(
new fields.SchemaField({
type: new fields.StringField({
choices: SYSTEM.GENERAL.abilityCosts,
choices: CONFIG.DH.GENERAL.abilityCosts,
nullable: false,
required: true,
initial: 'hope'
@ -51,13 +54,13 @@ export class DHBaseAction extends foundry.abstract.DataModel {
value: new fields.NumberField({ nullable: true, initial: null }),
max: new fields.NumberField({ nullable: true, initial: null }),
recovery: new fields.StringField({
choices: SYSTEM.GENERAL.refreshTypes,
choices: CONFIG.DH.GENERAL.refreshTypes,
initial: null,
nullable: true
})
}),
range: new fields.StringField({
choices: SYSTEM.GENERAL.range,
choices: CONFIG.DH.GENERAL.range,
required: false,
blank: true
// initial: null
@ -71,17 +74,21 @@ export class DHBaseAction extends foundry.abstract.DataModel {
damage: new DHDamageField(),
roll: new fields.EmbeddedDataField(DHActionRollData),
save: new fields.SchemaField({
trait: new fields.StringField({ nullable: true, initial: null, choices: SYSTEM.ACTOR.abilities }),
trait: new fields.StringField({
nullable: true,
initial: null,
choices: CONFIG.DH.ACTOR.abilities
}),
difficulty: new fields.NumberField({ nullable: true, initial: 10, integer: true, min: 0 }),
damageMod: new fields.StringField({
initial: SYSTEM.ACTIONS.damageOnSave.none.id,
choices: SYSTEM.ACTIONS.damageOnSave
initial: CONFIG.DH.ACTIONS.damageOnSave.none.id,
choices: CONFIG.DH.ACTIONS.damageOnSave
})
}),
target: new fields.SchemaField({
type: new fields.StringField({
choices: SYSTEM.ACTIONS.targetTypes,
initial: SYSTEM.ACTIONS.targetTypes.any.id,
choices: CONFIG.DH.ACTIONS.targetTypes,
initial: CONFIG.DH.ACTIONS.targetTypes.any.id,
nullable: true,
initial: null
}),
@ -95,10 +102,10 @@ export class DHBaseAction extends foundry.abstract.DataModel {
),
healing: new fields.SchemaField({
type: new fields.StringField({
choices: SYSTEM.GENERAL.healingTypes,
choices: CONFIG.DH.GENERAL.healingTypes,
required: true,
blank: false,
initial: SYSTEM.GENERAL.healingTypes.hitPoints.id,
initial: CONFIG.DH.GENERAL.healingTypes.hitPoints.id,
label: 'Healing'
}),
resultBased: new fields.BooleanField({
@ -143,7 +150,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
}
get chatTemplate() {
return 'systems/daggerheart/templates/chat/duality-roll.hbs';
return 'systems/daggerheart/templates/ui/chat/duality-roll.hbs';
}
static getRollType(parent) {
@ -228,7 +235,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
data: actorData
};
if (Hooks.call(`${SYSTEM.id}.preUseAction`, this, config) === false) return;
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
// Display configuration window if necessary
if (config.dialog?.configure && this.requireConfigurationDialog(config)) {
@ -284,7 +291,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
// Consume resources
await this.consume(config);
if (Hooks.call(`${SYSTEM.id}.postUseAction`, this, config) === false) return;
if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return;
return config;
}
@ -324,11 +331,11 @@ export class DHBaseAction extends foundry.abstract.DataModel {
prepareTarget() {
let targets;
if (this.target?.type === SYSTEM.ACTIONS.targetTypes.self.id)
if (this.target?.type === CONFIG.DH.ACTIONS.targetTypes.self.id)
targets = this.constructor.formatTarget(this.actor.token ?? this.actor.prototypeToken);
targets = Array.from(game.user.targets);
// foundry.CONST.TOKEN_DISPOSITIONS.FRIENDLY
if (this.target?.type && this.target.type !== SYSTEM.ACTIONS.targetTypes.any.id) {
if (this.target?.type && this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
targets = targets.filter(t => this.isTargetFriendly(t));
if (this.target.amount && targets.length > this.target.amount) targets = [];
}
@ -350,7 +357,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
difficulty: this.roll?.difficulty,
formula: this.roll.getFormula(),
bonus: this.roll.bonus,
advantage: SYSTEM.ACTIONS.advandtageState[this.roll.advState].value
advantage: CONFIG.DH.ACTIONS.advandtageState[this.roll.advState].value
};
if (this.roll?.type === 'diceSet') roll.lite = true;
@ -413,7 +420,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
const fearCost = realCosts.splice(hasFearCost, 1);
if (
!game.user.isGM ||
fearCost[0].total > game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.Fear)
fearCost[0].total > game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear)
)
return false;
}
@ -446,8 +453,10 @@ export class DHBaseAction extends foundry.abstract.DataModel {
: this.actor.prototypeToken.disposition,
targetDisposition = target.document.disposition;
return (
(this.target.type === SYSTEM.ACTIONS.targetTypes.friendly.id && actorDisposition === targetDisposition) ||
(this.target.type === SYSTEM.ACTIONS.targetTypes.hostile.id && actorDisposition + targetDisposition === 0)
(this.target.type === CONFIG.DH.ACTIONS.targetTypes.friendly.id &&
actorDisposition === targetDisposition) ||
(this.target.type === CONFIG.DH.ACTIONS.targetTypes.hostile.id &&
actorDisposition + targetDisposition === 0)
);
}
@ -567,7 +576,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
user: game.user.id,
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/ability-use.hbs',
'systems/daggerheart/templates/ui/chat/ability-use.hbs',
systemData
)
});
@ -575,239 +584,3 @@ export class DHBaseAction extends foundry.abstract.DataModel {
cls.create(msg.toObject());
}
}
export class DHDamageAction extends DHBaseAction {
static extraSchemas = ['damage', 'target', 'effects'];
getFormulaValue(part, data) {
let formulaValue = part.value;
if (this.hasRoll && part.resultBased && data.system.roll.result.duality === -1) return part.valueAlt;
return formulaValue;
}
async rollDamage(event, data) {
let formula = this.damage.parts.map(p => this.getFormulaValue(p, data).getFormula(this.actor)).join(' + ');
if (!formula || formula == '') return;
let roll = { formula: formula, total: formula },
bonusDamage = [];
if (isNaN(formula)) formula = Roll.replaceFormulaData(formula, this.getRollData(data.system ?? data));
const config = {
title: game.i18n.format('DAGGERHEART.Chat.DamageRoll.Title', { damage: this.name }),
roll: { formula },
targets: data.system?.targets.filter(t => t.hit) ?? data.targets,
hasSave: this.hasSave,
isCritical: data.system?.roll?.isCritical ?? false,
source: data.system?.source,
event
};
if (this.hasSave) config.onSave = this.save.damageMod;
if (data.system) {
config.source.message = data._id;
config.directDamage = false;
}
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config);
}
}
export class DHAttackAction extends DHDamageAction {
static extraSchemas = [...super.extraSchemas, ...['roll', 'save']];
static getRollType(parent) {
return parent.type === 'weapon' ? 'weapon' : 'spellcast';
}
get chatTemplate() {
return 'systems/daggerheart/templates/chat/duality-roll.hbs';
}
prepareData() {
super.prepareData();
if (this.damage.includeBase && !!this.item?.system?.damage) {
const baseDamage = this.getParentDamage();
this.damage.parts.unshift(new DHDamageData(baseDamage));
}
}
getParentDamage() {
return {
value: {
multiplier: 'prof',
dice: this.item?.system?.damage.dice,
bonus: this.item?.system?.damage.bonus ?? 0
},
type: this.item?.system?.damage.type,
base: true
};
}
}
export class DHHealingAction extends DHBaseAction {
static extraSchemas = ['target', 'effects', 'healing', 'roll'];
static getRollType(parent) {
return 'spellcast';
}
getFormulaValue(data) {
let formulaValue = this.healing.value;
if (this.hasRoll && this.healing.resultBased && data.system.roll.result.duality === -1)
return this.healing.valueAlt;
return formulaValue;
}
async rollHealing(event, data) {
let formulaValue = this.getFormulaValue(data),
formula = formulaValue.getFormula(this.actor);
if (!formula || formula == '') return;
let roll = { formula: formula, total: formula },
bonusDamage = [];
const config = {
title: game.i18n.format('DAGGERHEART.Chat.HealingRoll.Title', {
healing: game.i18n.localize(SYSTEM.GENERAL.healingTypes[this.healing.type].label)
}),
roll: { formula },
targets: (data.system?.targets ?? data.targets).filter(t => t.hit),
messageType: 'healing',
type: this.healing.type,
event
};
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config);
}
get chatTemplate() {
return 'systems/daggerheart/templates/chat/healing-roll.hbs';
}
}
export class DHSummonAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
documentUUID: new fields.DocumentUUIDField({ type: 'Actor' })
};
}
async trigger(event, ...args) {
if (!this.canSummon || !canvas.scene) return;
// const config = await super.use(event, args);
}
get canSummon() {
return game.user.can('TOKEN_CREATE');
}
}
export class DHEffectAction extends DHBaseAction {
static extraSchemas = ['effects', 'target'];
async use(event, ...args) {
const config = await super.use(event, args);
if (['error', 'warning'].includes(config.type)) return;
return await this.chatApplyEffects(event, config);
}
async chatApplyEffects(event, data) {
const cls = getDocumentClass('ChatMessage'),
systemData = {
title: game.i18n.format('DAGGERHEART.Chat.ApplyEffect.Title', { name: this.name }),
origin: this.actor._id,
description: '',
targets: data.targets.map(x => ({ id: x.id, name: x.name, img: x.img, hit: true })),
action: {
itemId: this.item._id,
actionId: this._id
}
},
msg = new cls({
type: 'applyEffect',
user: game.user.id,
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/apply-effects.hbs',
systemData
)
});
cls.create(msg.toObject());
}
get chatTemplate() {
return 'systems/daggerheart/templates/chat/apply-effects.hbs';
}
}
export class DHMacroAction extends DHBaseAction {
static defineSchema() {
return {
...super.defineSchema(),
documentUUID: new fields.DocumentUUIDField({ type: 'Macro' })
};
}
async trigger(event, ...args) {
// const config = await super.use(event, args);
// if (['error', 'warning'].includes(config.type)) return;
const fixUUID = !this.documentUUID.includes('Macro.') ? `Macro.${this.documentUUID}` : this.documentUUID,
macro = await fromUuid(fixUUID);
try {
if (!macro) throw new Error(`No macro found for the UUID: ${this.documentUUID}.`);
macro.execute();
} catch (error) {
ui.notifications.error(error);
}
}
}
export class DhBeastformAction extends DHBaseAction {
static extraSchemas = ['beastform'];
async use(event, ...args) {
const beastformConfig = this.prepareBeastformConfig();
const abort = await this.handleActiveTransformations();
if (abort) return;
const beastformUuid = await BeastformDialog.configure(beastformConfig);
if (!beastformUuid) return;
await this.transform(beastformUuid);
}
prepareBeastformConfig(config) {
const settingsTiers = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers).tiers;
const actorLevel = this.actor.system.levelData.level.current;
const actorTier =
Object.values(settingsTiers).find(
tier => actorLevel >= tier.levels.start && actorLevel <= tier.levels.end
) ?? 1;
return {
tierLimit: this.beastform.tierAccess.exact ?? actorTier
};
}
async transform(beastformUuid) {
const beastform = await foundry.utils.fromUuid(beastformUuid);
this.actor.createEmbeddedDocuments('Item', [beastform.toObject()]);
}
async handleActiveTransformations() {
const beastformEffects = this.actor.effects.filter(x => x.type === 'beastform');
if (beastformEffects.length > 0) {
for (let effect of beastformEffects) {
await effect.delete();
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,49 @@
import BeastformDialog from '../../applications/dialogs/beastformDialog.mjs';
import DHBaseAction from './baseAction.mjs';
export default class DhBeastformAction extends DHBaseAction {
static extraSchemas = ['beastform'];
async use(event, ...args) {
const beastformConfig = this.prepareBeastformConfig();
const abort = await this.handleActiveTransformations();
if (abort) return;
const beastformUuid = await BeastformDialog.configure(beastformConfig);
if (!beastformUuid) return;
await this.transform(beastformUuid);
}
prepareBeastformConfig(config) {
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
const actorLevel = this.actor.system.levelData.level.current;
const actorTier =
Object.values(settingsTiers).find(
tier => actorLevel >= tier.levels.start && actorLevel <= tier.levels.end
) ?? 1;
return {
tierLimit: this.beastform.tierAccess.exact ?? actorTier
};
}
async transform(beastformUuid) {
const beastform = await foundry.utils.fromUuid(beastformUuid);
this.actor.createEmbeddedDocuments('Item', [beastform.toObject()]);
}
async handleActiveTransformations() {
const beastformEffects = this.actor.effects.filter(x => x.type === 'beastform');
if (beastformEffects.length > 0) {
for (let effect of beastformEffects) {
await effect.delete();
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,38 @@
import DHBaseAction from './baseAction.mjs';
export default class DHDamageAction extends DHBaseAction {
static extraSchemas = ['damage', 'target', 'effects'];
getFormulaValue(part, data) {
let formulaValue = part.value;
if (this.hasRoll && part.resultBased && data.system.roll.result.duality === -1) return part.valueAlt;
return formulaValue;
}
async rollDamage(event, data) {
let formula = this.damage.parts.map(p => this.getFormulaValue(p, data).getFormula(this.actor)).join(' + ');
if (!formula || formula == '') return;
let roll = { formula: formula, total: formula },
bonusDamage = [];
if (isNaN(formula)) formula = Roll.replaceFormulaData(formula, this.getRollData(data.system ?? data));
const config = {
title: game.i18n.format('DAGGERHEART.Chat.DamageRoll.Title', { damage: this.name }),
roll: { formula },
targets: data.system?.targets.filter(t => t.hit) ?? data.targets,
hasSave: this.hasSave,
isCritical: data.system?.roll?.isCritical ?? false,
source: data.system?.source,
event
};
if (this.hasSave) config.onSave = this.save.damageMod;
if (data.system) {
config.source.message = data._id;
config.directDamage = false;
}
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config);
}
}

View file

@ -0,0 +1,40 @@
import DHBaseAction from './baseAction.mjs';
export default class DHEffectAction extends DHBaseAction {
static extraSchemas = ['effects', 'target'];
async use(event, ...args) {
const config = await super.use(event, args);
if (['error', 'warning'].includes(config.type)) return;
return await this.chatApplyEffects(event, config);
}
async chatApplyEffects(event, data) {
const cls = getDocumentClass('ChatMessage'),
systemData = {
title: game.i18n.format('DAGGERHEART.Chat.ApplyEffect.Title', { name: this.name }),
origin: this.actor._id,
description: '',
targets: data.targets.map(x => ({ id: x.id, name: x.name, img: x.img, hit: true })),
action: {
itemId: this.item._id,
actionId: this._id
}
},
msg = new cls({
type: 'applyEffect',
user: game.user.id,
system: systemData,
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/apply-effects.hbs',
systemData
)
});
cls.create(msg.toObject());
}
get chatTemplate() {
return 'systems/daggerheart/templates/ui/chat/apply-effects.hbs';
}
}

View file

@ -0,0 +1,42 @@
import DHBaseAction from './baseAction.mjs';
export default class DHHealingAction extends DHBaseAction {
static extraSchemas = ['target', 'effects', 'healing', 'roll'];
static getRollType(parent) {
return 'spellcast';
}
getFormulaValue(data) {
let formulaValue = this.healing.value;
if (this.hasRoll && this.healing.resultBased && data.system.roll.result.duality === -1)
return this.healing.valueAlt;
return formulaValue;
}
async rollHealing(event, data) {
let formulaValue = this.getFormulaValue(data),
formula = formulaValue.getFormula(this.actor);
if (!formula || formula == '') return;
let roll = { formula: formula, total: formula },
bonusDamage = [];
const config = {
title: game.i18n.format('DAGGERHEART.Chat.HealingRoll.Title', {
healing: game.i18n.localize(CONFIG.DH.GENERAL.healingTypes[this.healing.type].label)
}),
roll: { formula },
targets: (data.system?.targets ?? data.targets).filter(t => t.hit),
messageType: 'healing',
type: this.healing.type,
event
};
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config);
}
get chatTemplate() {
return 'systems/daggerheart/templates/ui/chat/healing-roll.hbs';
}
}

View file

@ -0,0 +1,24 @@
import DHBaseAction from './baseAction.mjs';
export default class DHMacroAction extends DHBaseAction {
static defineSchema() {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
documentUUID: new fields.DocumentUUIDField({ type: 'Macro' })
};
}
async trigger(event, ...args) {
// const config = await super.use(event, args);
// if (['error', 'warning'].includes(config.type)) return;
const fixUUID = !this.documentUUID.includes('Macro.') ? `Macro.${this.documentUUID}` : this.documentUUID,
macro = await fromUuid(fixUUID);
try {
if (!macro) throw new Error(`No macro found for the UUID: ${this.documentUUID}.`);
macro.execute();
} catch (error) {
ui.notifications.error(error);
}
}
}

View file

@ -0,0 +1,20 @@
import DHBaseAction from './baseAction.mjs';
export default class DHSummonAction extends DHBaseAction {
static defineSchema() {
const fields = foundry.data.fields;
return {
...super.defineSchema(),
documentUUID: new fields.DocumentUUIDField({ type: 'Actor' })
};
}
async trigger(event, ...args) {
if (!this.canSummon || !canvas.scene) return;
// const config = await super.use(event, args);
}
get canSummon() {
return game.user.can('TOKEN_CREATE');
}
}