Kaysser Taylor e6531ec569 v0.2.2: bump MODULE_VERSION in main.js to match module.json/package.json
Missed the 3-place version rule on the v0.2.2 bump. MODULE_VERSION
was still v0.2.0 in scripts/main.js, so Foundry's init log showed
the old version and the live system didn't have getFeed/clearFeed.
Caught during the e2e Playwright run when Foundry loaded v0.2.0
of the main.js but v0.2.2 of the module.json.
2026-06-22 17:06:35 -04:00

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 via subscribeMany for the combat envelope stream (combatStart, combatEnd, combatRound, combatTurn, createCombatant, deleteCombatant, dnd5e.rollAttackV2, dnd5e.rollDamageV2).
  • Soft-dep battle-focus — reads the active encounter via battle-focus.api.getActiveEncounter().
  • Public APIgame.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.2 — added getFeed/clearFeed read accessors. 50/50 smoke tests.
  • v0.2.1 — current-turn indicator; encounter-as-source-of-truth for currentTurn. 46/46 smoke tests.
  • v0.2.0 — ported HUD from its-achievable (section-based rendering, throttled to 1Hz). 42/42 smoke tests.
  • v0.1.0 — public API + soft-dep wiring (initial scaffolding).

Tests

npm test
Description
Foundry VTT v14 module: generic combat HUD host. Other modules register sections via public API; built-in core sections render round/turn/damage/dice-streak. Soft-dep on foundry-hooks-lib and battle-focus.
Readme MIT 193 KiB
Languages
JavaScript 91%
CSS 7.6%
HTML 1.4%