Kaysser Taylor f752d15805 v0.2.1: add Playwright test + tests/PLAN.md
- 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.
2026-06-22 16:09:23 -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.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
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%