How belodri/talia-custom works
Project Type and Purpose
• This is a Foundry VTT “module” (plugin) tailored for the Talia D&D campaign.
• It bundles character features, items, spells, world‐event hooks, macros, UI templates, styles, and utility code into a single JS module loaded by Foundry.
File Structure Analysis
• Top-level “module.json” + “scripts/” contain the entry point (scripts/module.mjs), constants and socket/api setup.
• “features/”, “items/”, “spells/”, “features/professions/”, “features/mythic/” house domain logic for character abilities, items, spells, professions and mythic destinies.
• “world/” holds event-driven handlers (game hooks) that apply global behavior (e.g., settlement simulations, guild manager, wild magic).
• “macros/” & “gmMacros/” contain reusable player and GM macros.
• “utils/” and “wrappers/” provide shared helpers and override core Foundry behavior via hook wrappers.
• “templates/” + “styles/” define the UI layer (Handlebars templates, CSS).
• “jsonData/” provides static lookup tables (names, settlement data, surge tables).
• “scripts/socket.mjs” and “scripts/api.mjs” manage inter-client communication.
• “types/” holds TypeScript definition for socket library.
Key Architectural Patterns
• Plugin/Module architecture: scripts/module.mjs registers all hooks, features, macros, templates at initialization.
• Event-Driven (hook-based) design: “world/…” and “wrappers/…” intercept Foundry events and core methods.
• Layered design:
• Core Loader & Configuration
• Domain Logic (features/items/spells/professions/mythic)
• Infrastructure (utils, wrappers, socket/api)
• UI (templates, styles, macros)
• Data (jsonData)
Main Components
a. Core Module Loader
• scripts/module.mjs
• scripts/constants.mjs
• scripts/api.mjs / scripts/socket.mjs
b. Domain Logic
• features/
• items/
• spells/
• features/professions/
• features/mythic/
c. Infrastructure
• utils/
• wrappers/
d. World Event Handlers
• world/ (guildmanager, settlement, wildMagic, configChanges, etc.)
e. Macros
• macros/ (player)
• gmMacros/ (GM tools)
f. UI Layer
• templates/ (Handlebars)
• styles/ (CSS)
g. Static Data
• jsonData/
• types/ (TS defs)
Relationships & Interactions
• The Core Loader initializes at Foundry startup → registers domain modules, hooks, templates, macros, socket listeners.
• Domain Logic modules export definitions used by the world handlers and UI.
• Infrastructure (utils + wrappers) intercepts or augments Foundry core methods called by domain and world handlers.
• World Event Handlers listen to gameplay events → invoke Domain Logic and Utils.
• Macros call into API/socket layer → trigger domain logic or world changes.
• UI Templates & Styles present data and controls for features, professions, settlements, guild management.
• JSON Data feeds lookup tables into domain logic and UI.
Essential Elements
• Clear labels: folder names, role (“Loader”, “Feature Modules”, “World Hooks”, etc.)
• Annotations: note the hook-based pattern, plugin registration step, and client/server messaging via socket