mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 20:21:06 +01:00
Merged with development
This commit is contained in:
commit
379398f2c7
46 changed files with 968 additions and 73 deletions
|
|
@ -66,6 +66,7 @@ CONFIG.Token.rulerClass = placeables.DhTokenRuler;
|
|||
CONFIG.Token.hudClass = applications.hud.DHTokenHUD;
|
||||
|
||||
CONFIG.ui.combat = applications.ui.DhCombatTracker;
|
||||
CONFIG.ui.nav = applications.ui.DhSceneNavigation;
|
||||
CONFIG.ui.chat = applications.ui.DhChatLog;
|
||||
CONFIG.ui.effectsDisplay = applications.ui.DhEffectsDisplay;
|
||||
CONFIG.ui.hotbar = applications.ui.DhHotbar;
|
||||
|
|
@ -89,6 +90,8 @@ Hooks.once('init', () => {
|
|||
fields
|
||||
};
|
||||
|
||||
game.system.registeredTriggers = new RegisteredTriggers();
|
||||
|
||||
const { DocumentSheetConfig } = foundry.applications.apps;
|
||||
DocumentSheetConfig.unregisterSheet(TokenDocument, 'core', foundry.applications.sheets.TokenConfig);
|
||||
DocumentSheetConfig.registerSheet(TokenDocument, SYSTEM.id, applications.sheetConfigs.DhTokenConfig, {
|
||||
|
|
@ -321,7 +324,7 @@ const updateActorsRangeDependentEffects = async token => {
|
|||
CONFIG.DH.SETTINGS.gameSettings.variantRules
|
||||
).rangeMeasurement;
|
||||
|
||||
for (let effect of token.actor.allApplicableEffects()) {
|
||||
for (let effect of token.actor?.allApplicableEffects() ?? []) {
|
||||
if (!effect.system.rangeDependence?.enabled) continue;
|
||||
const { target, range, type } = effect.system.rangeDependence;
|
||||
|
||||
|
|
@ -384,3 +387,50 @@ Hooks.on('refreshToken', (_, options) => {
|
|||
|
||||
Hooks.on('renderCompendiumDirectory', (app, html) => applications.ui.ItemBrowser.injectSidebarButton(html));
|
||||
Hooks.on('renderDocumentDirectory', (app, html) => applications.ui.ItemBrowser.injectSidebarButton(html));
|
||||
|
||||
class RegisteredTriggers extends Map {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
async registerTriggers(trigger, actor, triggeringActorType, uuid, commands) {
|
||||
const existingTrigger = this.get(trigger);
|
||||
if (!existingTrigger) this.set(trigger, new Map());
|
||||
|
||||
this.get(trigger).set(uuid, { actor, triggeringActorType, commands });
|
||||
}
|
||||
|
||||
async runTrigger(trigger, currentActor, ...args) {
|
||||
const updates = [];
|
||||
const triggerSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).triggers;
|
||||
if (!triggerSettings.enabled) return updates;
|
||||
|
||||
const dualityTrigger = this.get(trigger);
|
||||
if (dualityTrigger) {
|
||||
for (let { actor, triggeringActorType, commands } of dualityTrigger.values()) {
|
||||
const triggerData = CONFIG.DH.TRIGGER.triggers[trigger];
|
||||
if (triggerData.usesActor && triggeringActorType !== 'any') {
|
||||
if (triggeringActorType === 'self' && currentActor?.uuid !== actor) continue;
|
||||
else if (triggeringActorType === 'other' && currentActor?.uuid === actor) continue;
|
||||
}
|
||||
|
||||
for (let command of commands) {
|
||||
try {
|
||||
const result = await command(...args);
|
||||
if (result?.updates?.length) updates.push(...result.updates);
|
||||
} catch (_) {
|
||||
const triggerName = game.i18n.localize(triggerData.label);
|
||||
ui.notifications.error(
|
||||
game.i18n.format('DAGGERHEART.CONFIG.Triggers.triggerError', {
|
||||
trigger: triggerName,
|
||||
actor: currentActor?.name
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return updates;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue