1
0
Fork 0
Commit graph

388 commits

Author SHA1 Message Date
8afbf00805 feat(minigames): add procedural SFX and hit explosions to the versus duel
Sound is synthesized with the Web Audio API (no new assets): a launch
thump on fire, noise-burst impacts (splash for a miss, a bigger double
boom for a destroyed emplacement), a chime when the turn passes to you,
and victory/defeat fanfares. A mute button and volume slider live in the
match header; the setting persists per browser
(polaris:call-for-fire-versus-sound).

Adds a one-shot explosion VFX on hit and destroyed cells on both boards
(larger burst for a destroyed emplacement), suppressed under
prefers-reduced-motion. Only shots that arrive while watching animate, so
loading a match does not replay every past hit.
2026-10-11 22:28:10 -04:00
a1a2dbdcac feat(minigames): highlight the selected emplacement and add rotation controls
Ring the selected emplacement's grid cells and document the controls in
the editor help text. Rotate a placed emplacement in place by
double-clicking it or by pressing the Horizontal/Vertical toggle (the
toggle also sets the orientation for a new placement, and is disabled for
the fixed 2x2 Command Post).

Fix: moving an emplacement after rotating it kept the default orientation
instead of the rotated one, so the rotation was lost on the next click.
placeAt now preserves the emplacement's stored orientation when moving it.
2026-10-11 22:18:20 -04:00
d4bf0e9742 fix(minigames): pick up placed emplacements on click instead of overwriting
Clicking a grid cell always placed the currently selected emplacement
there and silently deleted whatever it overlapped, so clicking an
earlier emplacement (after selection auto-advanced) clobbered it. Now
clicking a placed emplacement selects it so it can be moved, and placing
onto an occupied cell is refused with a message instead of deleting the
other emplacement. Adds the pick-up hint to the editor copy.
2026-10-11 22:12:04 -04:00
3ce9677fd0 fix(minigames): square versus grid cells and make the Command Post a 2x2 block
The placement and battle grids inherited a 32px line-height, so any cell
holding the emplacement glyph grew taller than its square width (29x34),
making the row gaps look inconsistent once emplacements were placed. Set
leading-none on the grids so cells stay square.

Add a shape to emplacements ("line" | "square") and lay out the Command
Post as a 2x2 block (size 4) instead of a 3-cell line. cellsForFob resolves
cells per definition; the placement editor, preview, and tests use it.
2026-10-11 22:09:09 -04:00
065018cf3c feat(minigames): color-code versus emplacements and shrink the duel board
Give each emplacement type its own color (Command Post amber, Ammo Depot
rose, Radar Site sky, FOB violet) so it is obvious what is placed where:
the picker chips carry a matching swatch, placement cells and the
in-battle "your fire bases" board use the type color, and struck enemy
cells use the struck type's color. The shot view now carries the struck
assetId so the enemy sector can be colored too.

Cap the board at a compact width (max-w-sm) instead of stretching to fill
the panel, so the 10x10 grid no longer dominates the screen.
2026-10-11 22:01:15 -04:00
005ff0e5df feat(minigames): add Call for Fire: Versus multiplayer artillery duel
Head-to-head artillery duel in a new "multiplayer" registry category
(out of periods). Each operator hides a fire-base fleet on a 10x10 grid,
then takes turns calling fire: the first mission is a grid designation,
every later shot adjusts from that operator's last impact using the
single-player range/deflection controls. First to reduce every enemy
emplacement wins; a cap decides on emplacements then cells.

Pure engine in src/lib/minigames/call-for-fire-versus (engine, views,
types, constants) is client-safe and unit-tested. The server-only
registry mirrors the blackjack table pattern (globalThis-anchored Map,
lobby, per-turn timeout, expiry sweep, single-instance only); its views
are built per viewer so the opponent's fleet layout never leaves the
server. The client polls the match snapshot (the in-memory SSE bus is
unreliable across dev module copies). Rewards on completion update the
callForFireVersus profile group, pay XP and chips, and emit
minigame:call-for-fire-versus.

Wires the game into the registry (new multiplayer category + enum
migration), the sidebar grouping, the command palette, and the profile
XP aggregation. The registry row seed is split into its own migration
because Postgres forbids using a freshly added enum value in the same
transaction.

Verified: 21 new tests (engine + registry) plus the wider minigame suite
pass; tsc clean; a live two-player award run confirmed XP, chips, and
the event.
2026-10-11 21:55:39 -04:00
0bb9719139 feat(minigames): show upcoming games as disabled with a release countdown
- Optional `estimatedReleaseDate` (date and time) on the minigames registry,
  with a named migration and regenerated types.
- Sidebar: an `upcoming` game renders greyed out and non-interactive, with a
  tooltip carrying the estimate and a live countdown. It is a hoverable row
  rather than a disabled menu item, because a disabled Radix item sets
  `pointer-events: none` and would swallow the tooltip.
- Page gate: each minigame page checks its registry status and renders
  `MinigameComingSoon` instead of the arena while the game is upcoming, so a
  typed URL cannot reach unfinished gameplay. The date is display only: the
  game goes live when an admin flips `status` to active.
- Leaderboards exclude upcoming games, so they get neither a tab nor a board.
- Pure `countdown.ts` formatter plus a client ticker that computes the
  remaining time only after mount, avoiding an SSR hydration mismatch.

Note: `registry.ts`, `payload-types.ts` and `migrations/index.ts` also carry
the Call for Fire registry row and its generated types. That feature was
committed as 6d6a5fb and announced a separate commit for those files; they are
included here because they are entangled with these edits in the same files.

Tests: pure countdown unit tests, registry/gate/leaderboard integration tests,
and an e2e that seeds an upcoming row, hovers the disabled sidebar entry to
assert the tooltip, and checks the coming-soon gate.
2026-10-11 18:47:43 -04:00
6d6a5fb0ce feat(minigames): add Call for Fire artillery observer game
Bracket hidden artillery targets across patrol/checkpoint/compound
difficulties. Pure rules in src/lib/minigames/call-for-fire.ts (compass
bearing observer reports, ADD/DROP + RIGHT/LEFT corrections, scoring,
distance-to-target accuracy, injected rng) with a 23-case spec.

Wires the game into the minigame ecosystem: submit action validates the
run, updates the profile callForFire group, pays out XP and chips, emits
minigame:call-for-fire, and records the period ledger entry (accuracy is
distance-to-target on a win, null on a loss). Adds the game page with
period standings and an all-time board, a command palette entry, the
Target icon, and the profiles XP aggregation.

The registry row and regenerated payload types land with the minigame
registry changes in a separate commit.
2026-10-11 18:18:02 -04:00
08f2630442 feat(minigames): add an admin close/reopen control for periods
Phase 7 of the minigame periods feature:

- New admin component `PeriodCloseControl` renders above the minigame-periods
  list: it shows the recent periods with their status and a Close now / Reopen
  button that drives POST /api/minigame-periods/close (gated on
  minigame-periods:close; a 403 is shown inline rather than swallowed).
- Registered via `admin.components.beforeListTable` and the import map
  regenerated.

Registry CRUD and the period/entry/achievement review lists already exist as
permission-gated admin collection views, so this was the only missing surface.
Verified end to end in the running admin panel: an open period closed, its
status flipped and closedAt stamped, then reopened.
2026-10-11 17:06:52 -04:00
316797d27d feat(minigames): add period leaderboards, all-time view and achievements
Phase 5 of the minigame periods feature:

- Read model (lib/minigames/periods/standings.ts) that shapes period boards
  from the ledger (rank, placement points, names) and All-Time boards from the
  untouched profile aggregates into one row type.
- GET /api/minigames/leaderboards: ?period=current|<id>|all-time, returning
  the period, the period list, the boards and the achievements honor roll.
- New /minigames/leaderboards page: period selector (current, every past
  period, All-Time), per-game tabs, and the achievements honor roll. Core-only
  in period mode; every registered game in All-Time.
- Shared client pieces: useLeaderboards hook, StandingsTable,
  PeriodStandingsCard (period by default, All-Time toggle) and
  AchievementsHonorRoll.
- Each Core game page gains an "Anchored period standings" card so the period
  board is visible on the game itself; its existing all-time board and
  mode/difficulty selectors are untouched, and it links to the full page.
  (Plan said replace the inline board; keeping it preserves the per-mode
  selectors, so the period board is added instead. Easy to swap if you prefer.)
- Ledger fetch helper extracted to lib/minigames/periods/ledger.ts.
- Integration test for the period boards, the All-Time path and the honor roll.
2026-10-11 17:06:52 -04:00
deb88ded56 feat(minigames): drive the nav and period scoring from the registry
Phase 4 of the minigame periods feature:

- Server registry loader (lib/minigames/loadRegistry.ts) reads the
  minigames collection and falls back to the built-in seven when it is empty
  or unreadable, so the nav and boards never render blank.
- The sidebar minigames dropdown now renders from the registry (Core and
  Cardtable groups, retired games hidden, registry order), with lucide icons
  resolved from the icon-name string through a client icon map and a
  safe fallback.
- Period scoring is registry-driven: the close pipeline uses core games with
  countsForPeriods instead of a hardcoded list. A retired game simply stops
  accruing entries and drops out of the next period while its history stays.
- Integration tests for the fallback, ordering, retirement filtering and the
  non-scoring-game exclusion; the older minigame specs now wipe the registry
  too so files stay order-independent.
2026-10-11 17:06:52 -04:00
997ae39a59 feat(minigames): record completed runs in the period ledger
Phase 1 of the minigame periods feature:

- Shared server-side recorder (lib/minigames/periods/record.ts) writes one
  minigame-entries row per completed scored run, lazily creating the
  anchored period it belongs to (unique startDate makes it race-safe).
  Failures are swallowed so a ledger hiccup can never break a submission.
- Pure anchored-period math (lib/minigames/periods/derive.ts).
- Wire the recorder into all five Core submit actions after their profile
  update: flappy (passes > 0), EOD (win), radio (>= 1 correct message),
  aim trainer and OPORD (any completed round).
- Server-validated durations for every game: flappy and radio watch now
  report durationMs (with bounds), aim trainer reports its run duration
  (clamped to the 30s course), EOD derives it from seconds, OPORD from
  timeMs.
- Integration test covering derivation, lazy period creation, pre-anchor
  null period and the never-throw guarantee.
2026-10-11 17:06:52 -04:00
32365e6612 feat(intelligence): add threat assessment dossier table to mission details
New Intelligence tab on the Missions collection holds a threatAssessment.likelihoods
array (category + 5-level likelihood select). Renders a color-coded, dossier-styled
table on the mission details page, ordered after Mission Details and above the
briefing. Rows match the free-text category to a lucide glyph (helicopter, plane,
armor, infantry, etc.) so the estimate scans at a glance.
2026-10-10 13:26:02 -04:00
db98adbcee fix(game-structures): repair Labor Crew panel data loading
- Read labor requirements via useAllFormFields + reduceFieldsToValues:
  useField on an array path returns the row count, not rows, so
  requirementList.flatMap threw and raised the "Failed to load labor
  data" toast on every page load
- Use valid REST where syntax (where[structure][equals]= plus
  positionType/status filters); the dot-notation key was silently
  ignored and returned every staffing doc unfiltered
- Match staffing rows by raw relationship id at depth=0;
  m.laborClassification?.id never matched numeric ids
- Validate fetch responses and show a distinct load-failure message
  instead of the misleading "no classifications configured" empty state
- Give the Apply button type="button" so it stops submitting the
  whole document form on every click
2026-10-10 13:23:52 -04:00
4673aa7a66 feat(map): redesign world picker cards with overflow tooltips
Redesign the World Map picker as 4:3 cards with cover imagery, a classification strip (REF code + campaign), corner brackets, and a readout footer (size/weather/access/faction). Add OverflowTooltip, a hover tooltip that only opens when the value is actually clipped, so truncated readouts stay readable.
2026-10-09 17:56:22 -04:00
42d860da44 feat(wiki): redesign index with URL-shared filters, category portals, featured strip
Rewrite the wiki index: filters (query/tag/category/sort) sync to the URL for shareable/bookmarkable views; a moderator-curated 'Start here' featured strip; category grouping with per-category portal pages (/wiki/category/*) and CATEGORY_META blurbs; excerpt previews; case-insensitive, alphabetized tag counts; and a compact WikiRow. Updates the wiki controls tour copy.
2026-10-09 17:56:09 -04:00
3a2ae34b83 feat(contributions): add crowdsourced XP reward system
Reward users for helping build the app: wiki pages, mission planning
markers (queued until the mission completes), surveys, and manual awards.
Contribution XP folds into the existing virtual profile total, so it
flows into the level ladder, sidebar XP display, dashboard, and profile.

- contribution-entries ledger collection + profile progression.contributions.xpEarned bucket
- src/lib/contributions service (record/grant/expire/revoke, caps, idempotency, leaderboard) with a pure rules module
- per-mission planning-map delegation (missions:update grants) and a completed/cancelled map lock
- wiki, survey, and marker action/hook integration
- contribution:* event types, muteable notifications, permissions group, event targets
- profile Contributions section and /contributions leaderboard
- migration, reconcile tool, and integration tests
2026-10-09 16:30:05 -04:00
b28708c590 docs(agents): split domain guidance into nested AGENTS.md files
Move 19 domain sections out of the root guide into per-directory
AGENTS.md files that OpenCode v2 injects lazily when an agent reads
each subtree. The always-loaded root drops from 121KB to ~30KB and
gains a domain index table with never-miss invariants. Original root
and pre-merge sub-guides are preserved under
docs/backups/pre-agents-split-20261009/ for restoration.

Note: also carries the pre-existing uncommitted wiki-section edits to
the root AGENTS.md, preserved verbatim in src/lib/wiki/AGENTS.md.
2026-10-09 15:46:36 -04:00
37d7297b1a feat(notifications): add staff toggle to show only your own notifications
Staff with read-all oversight (superuser / system:admin-access) see everyone's
notifications in the bell. Add a "Show all users" switch inside the dropdown,
rendered only when the caller can view others, that narrows the feed to the
caller's own notifications. The choice is remembered per browser (localStorage)
and the unread badge follows the selected scope.

The inbox route now reports canViewOthers and honors scope=all|mine; non-staff
callers are always forced to their own regardless of the param.
2026-10-09 14:43:12 -04:00
aa09252b06 feat(chronicle): show draft entries to staff on /story
Drafts were only reachable in the admin panel: /story hard-filtered to
published. Story staff (admin/developer) now see drafts in the
Chronicle, badged and clearly marked, while everyone else stays
published-only. The collection's own read access remains the backstop
(overrideAccess stays false), so a non-staff request can never leak a
draft.

- page: staff fetch all entries, others published-only
- new DraftBadge (amber pill) rendered in the list, immersive reader,
  book view, and table of contents
- drafts hide the read marker and reactions
- front-end copy adopts Chronicle wording
2026-10-09 13:48:51 -04:00
dffcd0013c chore(chronicle): rename Story Beats to Chronicle Entries
The Chronicle collections were auto-labeled from their slugs ("Story
Beats"). Give them explicit Chronicle labels and adopt the word
Chronicle in the surrounding titles, descriptions, and event text.

- StoryBeats: labels Chronicle Entry/Entries, admin group Story ->
  Chronicle, descriptions updated
- Voiceovers / StoryBeatStates: Chronicle labels, group, descriptions
  (including the "beat" field label)
- GameEventLogs: event-log target labels -> Chronicle Entries / States
- lib/story: event message text -> "chronicle entry" (internal
  event-type strings left intact so existing logs stay valid)
- regenerate payload-types.ts

Slugs are unchanged, so no migration is required.
2026-10-09 13:48:14 -04:00
66e70d3d56 feat(notifications): scope notification read state per recipient
Read state is personal to the recipient. Marking a notification read now
only ever flips the acting user's own rows — never another user's, even
when staff view it via read-all oversight (which would otherwise hide it
from its real owner).

- add /api/notifications/inbox endpoint that enriches each row with
  ownerId, ownerName, and isMine so the bell can label "meant for
  someone else" rows
- move mark-read logic into per-user lib helpers (markNotificationsReadForUser,
  markAllNotificationsReadForUser) and have the actions delegate
- surface ownership in the bell UI and skip marking rows that aren't mine
2026-10-09 13:13:16 -04:00
c019e642a3 feat(campaigns): hide completed campaigns by default
Default the campaigns list "Show completed" toggle to off, so only
ongoing campaigns show until the user opts in. Renamed the toggle from
"Hide completed" to "Show completed" and flipped the empty-state link to
turn completion visibility on.
2026-10-09 13:13:09 -04:00
6f3d1a4147 feat(campaigns): let owners set campaign status from the detail page
Add a Campaign Status dropdown on the campaign detail page, gated by
campaign ownership or the campaigns:update permission (mirroring the
existing requireCampaignOwnership gate). Owners can set On Hold to pause
a campaign they are not actively running, and flip it back; admins act
through the same control. The editor optimistically updates the field,
toasts on success, refreshes the view, and reverts on failure.

- new CampaignStatusEditor client component (optimistic select + save)
- updateCampaignStatus server action (owner OR campaigns:update)
- render the editor on the detail page for authorized users
- add "On Hold" to the create dialog status options
- color + label the new status on cards and campaign rows (missions,
  factions, dashboard) so it never renders as raw "onHold"
2026-10-09 13:13:05 -04:00
cc9d3b8073 fix(missions): only accept Arma 3 Launcher preset exports as mod lists
Root cause of the upload failures: the launcher writes an
<?xml version="1.0"?> prologue, Payload sniffs uploads with
fileTypeFromBuffer, and the collection mimeTypes allowlist lacked
application/xml, so every genuine launcher export was rejected with
'Invalid MIME type: application/xml'.

- Add application/xml to the mod-lists upload mimeTypes (the document is
  still stored as text/html; verified end to end).
- New pure parser src/lib/modlistPreset.ts validates the launcher export
  structure (arma:Type=preset meta + data-type=ModContainer rows) and is
  shared by the server action (authoritative) and CreateSideOpDialog
  (instant client-side feedback).
- Plain-text lists are no longer accepted anywhere: dialog accept/hint,
  collection mimeTypes, and the action now agree on HTML presets only.
- Upload name defaults to the preset's own arma:PresetName.
- Tests: tests/int/modlist-preset.int.spec.ts (9 cases).
2026-10-08 13:25:08 -04:00
8e42077c1f fix(uploads): store upload collections under the persistent media volume
VoiceSubmissions, ModLists and MissionFiles relied on Payload's default
upload staticDir (the collection slug resolved from cwd), so prod wrote
their files to /app/<slug> instead of the mounted /app/media volume and
every redeploy wiped them (voice takes returned 500 on play/download).
Pin all three under media/ subdirs like story Voiceovers already does,
add regression guards, and fix the audio-preview fallbacks that pointed
at the media collection's file route instead of the owning collection.
2026-10-08 12:14:46 -04:00
0370df6c2d feat(game-structures): add Labor Crew admin panel for staffing writes
Wire the previously orphaned LaborCrewPanel into the game-structures
editor so staff can set actual headcount and per-worker wage for a
labor classification. Adds a laborCrewPanel ui field on the edit view,
a POST route under /api/game-structures that authenticates and gates on
game-structures:update, delegates to the canonical setLaborHeadcount
service (enforcing caps and wage logic), and an integration test
covering auth, validation, and cap enforcement.
2026-10-07 23:28:35 -04:00
a96eddf32c feat(npc-dialogue): bigger flow handles + delete edges via Delete
- Enlarge flow-editor wire handles from size-2 (8px) to size-3 (12px) so
  they are easier to click and grab.
- Select an edge by clicking it, then remove it with the Delete key.
  Selection is tracked in state and the highlight renders through BaseEdge
  stroke props so the chosen line stands out.
- Edges are a derived projection, so deletion scrubs the hop from the
  source node data via a new pure removeHopFromNode() helper in dialogue.ts
  (choice row, condition branch, or single continuation).
- Add tests/int/npc-dialogue-remove-hop.int.spec.ts (4 tests).
2026-10-07 14:25:14 -04:00
538b7d4c4c feat(npc-dialogue): reorder choices in the dialogue editor
Choice rows in the dialogue node editor now have up/down buttons so a
choice can be moved up or down into the desired order, which is the
order shown to the player. The swap lives in a pure reorderChoice
helper (no-op at the edges, input not mutated) with a focused test.
2026-10-07 14:01:00 -04:00
9f0f7db612 feat(npc-dialogue): auto-grow the dialogue line box to fit its content
The Line textarea in the dialogue node editor grows to fit its content
up to a 200px default max, so long lines no longer scroll in a
fixed-height box. It stays drag-resizable (resize-y) and the user can
still expand it past the max.

The auto-grow hooks run above the early-return guard so their call
order never changes, fixing a Rules of Hooks violation the change would
otherwise introduce.
2026-10-07 14:00:15 -04:00
f643028638 feat(npc-dialogue): let event flag effects target self, global, or a specific user
Event node flag effects previously always wrote the active participant's
flag. A flag's identity is (owner, key), so the same key can hold
independent values for different owners, but there was no way to target
them from the editor.

- Add flagTarget ("self" | "global" | "user") + flagTargetUserId to
  NpcDialogueEffect. "self" (default) keeps current behavior.
- Add resolveFlagOwner (flags.ts) to map a scope onto the player-flags
  user column; "user" with no id falls back to the participant so a
  misconfigured effect never nudges the global flag.
- Move applyFlagEffect into flags.ts, parameterized by resolved owner;
  the runtime action resolves the owner and delegates.
- Add a Target control (+ user picker) to the event node editor and
  validateGraph enforcement for the "user" scope.
- Integration tests cover owner resolution and self/global/user writes.
2026-10-07 13:33:52 -04:00
2231cc86ee feat(dashboard): flag restricted events with a lock icon in Recent Events 2026-10-07 13:07:23 -04:00
e0f305b026 feat(tickets): allow staff to archive tickets, hiding them from the front-end
Archived tickets disappear from every front-end surface for all users
(staff included): helpdesk list, detail page 404s, dashboard widget, and
project board/sprints/releases/search views. They remain fully visible in
the Payload admin panel, where un-archiving restores them. The collection
hook stamps archivedAt and appends an activity entry on each toggle; the
archiveTicket server action is tickets:staff gated and emits a
ticket:archive event. Edits and votes on archived tickets are rejected.
2026-10-07 01:22:51 -04:00
8cda724e21 feat(event-log): configurable per-event visibility with permission gates
- game-event-logs gains visibility (public|restricted) + requiredPermissions
  (any-of gate from the permission registry); read access becomes a Where
  clause: public OR actor-is-me OR held permission; superusers and
  game-event-logs:update staff see all; admin panel gate unchanged
- src/utils/event-log/visibility.ts: per-type policy map consumed by
  emitGameEvent, with per-emit overrides; npc:dialogue and flag:set start
  restricted, everything else stays public
- PlayerFlags hooks emit restricted flag:set audit events on every flag
  write (admin edits and dialogue effects alike)
- fix dashboard RecentEvents leaking events: local API find now runs as
  the viewer with overrideAccess false
- SSE broadcast sends an opaque nudge for restricted events instead of
  type/actor metadata
- /events table marks restricted rows with a lock badge
- migration 20261007_025942_add_event_log_visibility + regenerated types
- tests/int/event-log-visibility.int.spec.ts (8 cases)
2026-10-06 23:31:30 -04:00
b1168dcc38 fix(personnel): mobile layout for conversations
- Converse button no longer floats over the hero text on phones: it sits
  in the card's content flow below the status chips and only anchors to
  the hero's right edge from md up
- conversation dialog keeps a side margin on small screens instead of
  rendering edge-to-edge
- dialog titles truncate with min-w-0 so long NPC names and attachment
  urls cannot push the close buttons out
2026-10-06 17:21:26 -04:00
f595828c99 feat(npc-dialogue): stacked markup, link popups, new badges, locked choices, timed flags
- DialogueText rewritten as a recursive parser so markup accumulates
  ({green}**bold green**{/} and friends nest freely, colors close inner-first)
- [label](url) dialogue links open in an iframe popup dialog so
  conversation progress survives; only http(s)/relative urls render
- NEW badges: Converse button + choice buttons badge unread paths via a
  per-browser seen map (ptf:npc-dialogue-seen) keyed by flow hash, so GM
  edits re-flag the conversation
- choices gain lockedHint: failing conditions can show the choice disabled
  with a rich tooltip instead of hiding it (evaluateNpcDialogueChoices now
  returns ChoiceGate pass/showLocked pairs)
- player flags gain activatesAt/expiresAt time windows honored by readFlag,
  flag effects gain flagDelayMinutes for slow-burn writes, and
  {{countdown:key}} tokens tick live toward activation (done/missing states)
- migration 20261006_add_flag_time_windows; spec extended to 33 tests
2026-10-06 17:06:27 -04:00
59fe616024 feat(npc-dialogue): rich hover tooltips on player choices 2026-10-06 16:21:53 -04:00
f20f57de66 feat(npc-dialogue): interpolate flag values into conversation text 2026-10-06 16:09:10 -04:00
efab41ba29 refactor(flow): share the edge shape builder between both flow canvases
Extract the dialogue canvas's routing upgrades into routeEdge() in the
shared lib: perpendicular handle stubs, candidate scoring (Z-step vs
straight for forward edges, top/bottom bus corridors for back edges),
per-edge detour lane spreading, and multi-pass obstacle clearing. The
NPC dialogue RoutedFlowEdge becomes a thin renderer over it, and the
tech tree RoutedEdge now inherits the same logic while keeping its own
features intact: manual waypoints route verbatim (and define the
add-a-bend base), per-source stepPosition lanes feed the Z-step, and
its fixed right/left handles map to the new direction params.

New pure spec covers the Z-step shape, blocked-forward detouring,
back-edge bus routing, per-id lane spread, and waypoint pass-through.
2026-10-06 14:47:14 -04:00
28bb08f43e fix(npc-dialogue): bus-route return edges and spread detour lanes
Two routing defects on the dialogue canvas:

- Return edges entering the same handle detoured through identical
  corners, stacking into one thick bundle on the left of the target.
  Each edge now derives a stable lane offset from its id, so parallel
  detours run in visibly separate lanes.
- Long leftward runs relied on greedy corner-hopping alone, which could
  still leave a segment cutting under a card. Back edges now try
  structured bus routes (corridor above or below every card, then swing
  in to the entry handle) and score candidates by residual crossings,
  picking the first clean shape. The router also re-runs until clean
  (bounded to three passes) instead of trusting one greedy pass.

Verified on doc #2: all seven edges route with zero card crossings and
no stacked lanes; tech-tree edge-routing specs still pass.
2026-10-06 14:38:42 -04:00
3c70fa70d8 fix(npc-dialogue): persist node drags into the flow field value
Dragging a card updated the canvas but never wrote to the Payload
field, so document Save persisted stale positions. Wrap onNodesChange
and serialize once a drag settles (the final position change with
dragging === false), keeping the write off the mousemove hot path.
Selection and in-progress-drag flags are stripped before serializing
so clicking a card never marks the document dirty.
2026-10-06 14:28:18 -04:00
46f1abd4da feat(npc-dialogue): selection ring, draft-cancel removal, snap-to-grid toggle
- Selected node cards gain a gentle cyan ring so selection state is
  obvious without fighting the per-type border colors.
- A node created via double-click/toolbar/pane menu opens straight into
  its dialog; closing that dialog with Cancel (or Escape/backdrop/X)
  now discards the empty draft instead of persisting it. Saving clears
  the draft marker, so cancelling a later edit never deletes anything.
- New Snap toggle in the editor toolbar enables React Flow grid
  snapping (20px, matching the background dots); the preference is
  remembered per browser like the tech tree's.
2026-10-06 14:20:21 -04:00
5a9bd0052b feat(npc-dialogue): route flow edges around node cards
Crossing Bezier connectors made return edges (a choice looping back to
an earlier line) impossible to trace on the dialogue canvas. Extract
the tech tree's obstacle-avoidance router into a shared pure lib
(src/lib/flow-edge-routing.ts, plus rounded path building and a new
polylineMidpoint for label placement), leave re-export shims where the
tech tree imported it, and render dialogue edges through a new
RoutedFlowEdge type: perpendicular stubs at each handle, an orthogonal
base for forward edges, full-card detouring for back edges, arrowheads,
and condition labels as chips at the path midpoint.
2026-10-06 14:13:13 -04:00
1f7729c509 feat(npc-dialogue): select nodes on click, edit on double-click
- Single click now only selects a node; the edit dialog opens on
  double-click so the Del-to-delete flow is never interrupted by a modal
- Guard the canvas double-click handler so double-clicking a node can
  never also spawn a new dialogue node behind the dialog
- Update the editor hint text to describe the new click model
2026-10-06 13:56:46 -04:00
089246def8 feat(npc-dialogue): flow editor UX pass for authoring dialogue flows
- Delete selected nodes with Del/Backspace (guarded against open dialogs,
  menus, and focused form fields)
- Double-click the canvas to drop a dialogue node at the cursor; right-click
  empty canvas for a New node menu with all six types; toolbar buttons now
  place nodes at the viewport center instead of blind grid coordinates
- Choices support optional flag conditions evaluated server-side per player
  (player flag first, global fallback); gated choices stay hidden until the
  server confirms them, so forbidden options never flash on screen
- Litegraph-style per-output handles: one source handle per choice row plus
  dedicated true/false handles on condition nodes, wired through derived
  edges and handle-aware connections
- Brighten passive edge lines and edge labels on the dark canvas
- New dialogue nodes default to an empty speaker, rendering the NPC's name
2026-10-06 13:44:01 -04:00
0cadd1e062 feat(npc-dialogue): taller flow canvas plus expand-to-screen toggle
Raise the default editor height from h-96 to 60vh (min 28rem) and add an
Expand/Shrink toolbar toggle that floats the whole editor over the document
form, filling the viewport right of the admin sidebar via the shell's
--nav-width/--app-header-height vars. Esc collapses it unless the node
dialog or context menu is open.
2026-10-06 12:43:02 -04:00
035dd49149 feat(npc-dialogue): add global flag support (nullable user on player-flags) 2026-10-06 11:58:54 -04:00
ac6415d034 feat(npc): complete dialogue feature and fix migration snapshot base
Finish the NPC dialogue flowchart work carried over from the base commit:
- Coloured NPC dialogue text via friendly names ({red}) or hex ({#ff00ff});
  invalid names/hex render as literal text. Shared client-safe renderer
  (DialogueText.tsx) used by both the admin canvas preview and the runtime.
- Player-flags feature: condition nodes branch on flags (evaluated
  server-side), flag effects set/clear/adjust flags, PlayerFlags collection
  + migration, and event nodes can set flags.
- One-time ("once") choices: a choice flagged "Hide after picked" is hidden
  for the rest of the current conversation only (per-session, resets on
  begin()); GMs can persist across conversations with a condition flag.
- Admin editor: colour hint, once checkbox on choices, amber "once" badge.

Migration repair: the player_flags migration (20261005_185014) was sorting
before 20261006_000000, whose stale snapshot omitted player_flags, so any
future `migrate:create` re-emitted player_flags DDL. Restored 20261006_000000's
snapshot to the full current schema so it is the correct diff base.

Verified: `bun run payload migrate` clean, `migrate:create` reports no
schema changes, `tsc --noEmit` clean.
2026-10-05 16:02:53 -04:00
2a3ad57bce feat(npc): add weighted activity, level, and dialogue conversations
- GameNpcs: Narrative Activity group (weighted options, forced flag,
  configurable reshuffle interval), level + richText levelDescription,
  canMessage toggle
- New npc-dialogues collection with a purpose-built React Flow dialogue
  editor (dialogue/choice/event/end nodes) in the admin panel
- Frontend: Currently-activity line and level description on the contact
  profile page; NpcConversation messaging surface with a documented
  (disabled) LLM extension seam
- Permissions: npc-dialogues CRUD + admin manage in a new NPC Dialogue
  group; event types for dialogue triggers
- Migration 20261006_000000 (applied to dev DB) with full schema
  snapshot sidecar
2026-10-05 12:51:59 -04:00
3e9d54486f chore(ui): replace em-dash placeholders with hyphen in NPC readouts
The 'Goods' readout cell rendered an em-dash when the NPC was not a vendor;
dash-sanitize gate requires a plain hyphen on user-facing surfaces.
2026-10-05 03:39:23 -04:00