f752d15805c4e2343bec60f440be682fd58f1c20
- New tests/verify-combat-hud-hub-foundry.mjs (12 assertion sections). Covers live Foundry v14: API surface, soft-dep presence, section registry round-trip, pushFeedEntry, HUD open on combatStart, core section rendering, current-turn indicator, screenshot, no errors. - New tests/PLAN.md (per-repo test plan). - .gitignore: tests/screenshots/ excluded.
Combat HUD Hub
A generic combat HUD host for Foundry VTT v14. Other modules register sections via the public API; the hub ships built-in core sections (round, current turn, per-PC damage, dice streak) that light up when foundry-hooks-lib and battle-focus are present. Consumer-registered sections work even when both are missing.
Architecture
foundry-hooks-lib ─┐
├──▶ combat-hud-hub ◀── its-achievable (Pinned Achievements)
battle-focus ─┘ ◀── <future modules>
- Soft-dep
foundry-hooks-lib— subscribed viasubscribeManyfor the combat envelope stream (combatStart,combatEnd,combatRound,combatTurn,createCombatant,deleteCombatant,dnd5e.rollAttackV2,dnd5e.rollDamageV2). - Soft-dep
battle-focus— reads the active encounter viabattle-focus.api.getActiveEncounter(). - Public API —
game.modules.get("combat-hud-hub").api:addSection({ id, label, render })— register a slot.render(ctx)receives{ feed, section, round, turn, combatants, ... }.removeSection(id)pushFeedEntry(sectionId, entry)— append an entry to a section's feed.listSections()— snapshot of registered sections.getHud(),openHud(),closeHud().
Consumer example
// its-achievable wants to surface unlocks in the HUD
Hooks.once("ready", () => {
const hub = game.modules.get("combat-hud-hub")?.api;
if (!hub) return; // soft dep; hub not installed
hub.addSection({
id: "pinned-achievements",
label: "Pinned Achievements",
render: (ctx) => (ctx.feed ?? []).slice(-5).map(e =>
`<li>${e.icon ?? "🏆"} ${e.name}</li>`).join(""),
});
});
// later, on unlock:
hub.pushFeedEntry("pinned-achievements", { name: "Critical Hit!", icon: "🎯" });
Status
- v0.2.0 — ApplicationV2 with section-based rendering, throttled to 1Hz. Built-in core sections (header, combatants, dice streak). 42/42 smoke tests passing.
- v0.1.0 — public API + soft-dep wiring (initial scaffolding).
Tests
npm test
Languages
JavaScript
91%
CSS
7.6%
HTML
1.4%