[PR #7335] [MERGED] fix(game): ask before a same-name library card joins the party #7686

Closed
opened 2026-10-24 04:06:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7335
Author: @SpicyMarinara
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/7324-party-promotion-card-match


📝 Commits (10+)

  • 49a300e fix(game): ask before a same-name library card joins the party
  • dd73ce9 fix(game): keep party card choice rows fully outlined and readable
  • b1c57a1 Merge origin/staging into fix/7324-party-promotion-card-match
  • 8a33630 Merge remote-tracking branch 'origin/staging' into fix/7324-party-promotion-card-match
  • f8d6abb fix(game): ask about NPCs met this session and match NPCs by whole words
  • ffa120c Merge remote-tracking branch 'origin/fix/7324-party-promotion-card-match' into fix/7324-party-promotion-card-match
  • 0678cb8 fix(game): tell same-name party cards apart when they have no title
  • 14753ec Merge origin/staging into fix/7324-party-promotion-card-match
  • ad2ef22 Merge origin/staging into fix/7324-party-promotion-card-match
  • d0cd1d6 Move the CHANGELOG entry away from other open PRs

📊 Changes

9 files changed (+372 additions, -57 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/game/party-and-npcs.md (+2 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+36 -11)
📝 packages/client/src/components/ui/AppDialogRenderer.tsx (+53 -16)
📝 packages/client/src/hooks/use-game.ts (+13 -1)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/client/src/stores/dialog.store.ts (+12 -2)
📝 packages/server/src/routes/game.routes.ts (+71 -27)
➕ scripts/regressions/game-party-recruit-card-choice.regression.ts (+181 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7324

Why this change

  • In Game Mode, when the Game Master promoted an NPC to the party, Marinara looked the name up in the whole character library first and used partial matches. An NPC named Sam pulled in an unrelated female Samantha card, and an NPC named Emma pulled in an unrelated Emma card, so the party got a backstory and description that conflicted with the character the story had built.
  • Root cause: POST /game/party/recruit (packages/server/src/routes/game.routes.ts) matched library cards by exact name and then by substring (lookup.includes(...)), and a library match always won over the game's own tracked NPC.
  • Maintainer direction (Discord, quoted in the issue): when several characters share the name, ask the player which one, showing names, titles and avatars in a prompt window.

What changed

  • Server, /game/party/recruit
    • Library cards are matched by exact (normalized) name only. Sam never matches Samantha.
    • When the game's tracked NPC and a library card share the name, or several library cards share it, the route changes nothing and returns cardChoices (id, name, title, avatar, avatar crop) so the player can pick.
    • New optional characterId in the request: a card id from those choices, or null to keep the game's own character. A card id that is not one of the same-name cards is refused.
    • Unchanged: a card or NPC already in the party is a quiet no-op (so the window does not come back), a single same-name card with no NPC of that name joins as before, and a name with no match still creates the tracked stand-in NPC.
    • A shortened name for a library card already in the party ("Kael" for "Kael Stormborn", whole words only) is treated as that member, so dropping the substring match does not add a duplicate stand-in.
    • An NPC the game met this session but has not tracked yet is in the journal's NPC log, so a single same-name card asks about it too instead of joining silently (the issue's Emma case when Emma was not a starting NPC).
    • Tracked NPCs are found by whole words too, so an NPC named Sam no longer recruits the game's own Samantha NPC.
    • A member of that name already in the party also wins over a late answer, so a stale window can never add a second Emma or Lena.
  • Client
    • GameSurface handles the cardChoices answer by opening the shared app choice dialog. Each card shows its avatar, name and title. The bottom button, Keep the game's own , keeps the NPC. Closing the window (X, Escape, backdrop) does the same, so the game is never left half-done. Several prompts from one turn are asked one at a time, back to back (the next window does not wait for the previous pick's party card).
    • The recruit call now uses mutateAsync, because the per-call callbacks of mutate() only fire for the last of several calls in a loop.
    • AppDialogRenderer / dialog.store: choice dialog entries can carry an optional avatar and a smaller description line. Those rows are equal picks (no first-button highlight). Existing choice dialogs are unchanged.
    • 3 new English strings under game.partyCardChoice.*.
  • Docs: one paragraph in docs/game/party-and-npcs.md (Recruiting and removing party members). Translation follow-up: #7336.
  • Regression: scripts/regressions/game-party-recruit-card-choice.regression.ts runs the real route: Sam is never Samantha, NPC plus same-name card asks and changes nothing, a stray choice is refused, keeping the NPC adds npc:emma and asking again is quiet, two same-name cards let the player pick one, a single card still joins, and "Kael" stays the party's Kael Stormborn. It fails on current staging (Sam joins as Samantha).

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify in a Game: with an NPC named Sam and a library card named Samantha, ask the GM to add Sam to the party. Sam joins with the game's own profile and no Samantha card appears.
  • Manually verify: with an NPC named Emma and a library card named Emma, ask the GM to add Emma. A window titled "More than one Emma" lists the Emma card with its avatar and title. Picking the card adds the card; Keep the game's own Emma adds the NPC.
  • Manually verify that closing that window with X, Escape or a backdrop click keeps the game's own Emma and the next turn plays normally.
  • Manually verify: with the Character Tracker on, meet a new NPC named Mira mid-session (not a starting NPC), keep a library card named Mira, and ask the GM to add Mira. The window asks instead of adding the card.
  • Manually verify the window on a mobile viewport and in light and dark mode: avatars are round, long titles truncate, nothing overflows.
  • Manually verify an existing choice dialog (for example the character delete scope choice) still looks the same, with the first button highlighted.

Agent-run checks: node ./scripts/run-regressions.mjs --filter scripts/regressions/game-party-recruit-card-choice (passes; fails on unfixed staging), node ./scripts/run-regressions.mjs --filter scripts/regressions/game-ruleset-setup (passes, recruit path unchanged for a single card), pnpm check via the slot limiter (exit 0), the existing core-flows e2e test "destructive confirmation actions use the shared accent button treatment" (passes, so plain choice dialogs keep their look), and a temporary Playwright check (not committed) that opened the new window on desktop-chromium and mobile-chromium: two rows with avatar or letter, name and truncated title, no first-row highlight, no overflow, and Escape resolving to "keep the game's own". Local CodeRabbit (--committed against the staging merge-base, run on the final commit after one earlier rate_limit answer) completed with no findings.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG: one entry under [Unreleased]. Docs: docs/game/party-and-npcs.md; translation follow-up #7336.

UI evidence (if applicable)

None captured by the agent. The window reuses the shared app choice dialog (Modal), with theme variables only.

Out of scope: the reporter's wish to remove a card from a party member without removing the profile is not built here.

Summary by CodeRabbit

  • New Features
    • When a game character’s name exactly matches multiple character cards, choose which card joins the party or keep the game’s character. Dismissing the choice window also keeps the game’s character.
    • Character choices can display an avatar and description to help distinguish cards.
  • Bug Fixes
    • A single exact-name card match still joins automatically when no game character with that name is already in the party. Similar names alone no longer cause a library card to be recruited.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7335 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7324-party-promotion-card-match` --- ### 📝 Commits (10+) - [`49a300e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/49a300e2f42776ef0308ec2e15d9ee2ac822bbdc) fix(game): ask before a same-name library card joins the party - [`dd73ce9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dd73ce9907fce4c016d9da3e86eeab93e6cbc72e) fix(game): keep party card choice rows fully outlined and readable - [`b1c57a1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b1c57a1496010155fcb581b5d16801f83643627a) Merge origin/staging into fix/7324-party-promotion-card-match - [`8a33630`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8a33630c67273bfa573069d660e859bd27611e8f) Merge remote-tracking branch 'origin/staging' into fix/7324-party-promotion-card-match - [`f8d6abb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f8d6abb77a4fa314c03eeece8cd3015306ad1824) fix(game): ask about NPCs met this session and match NPCs by whole words - [`ffa120c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ffa120cd6b44df4e9b5e5dd1026d9960cfce08e8) Merge remote-tracking branch 'origin/fix/7324-party-promotion-card-match' into fix/7324-party-promotion-card-match - [`0678cb8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0678cb86f0f9501f915c01c1654ce5225897641b) fix(game): tell same-name party cards apart when they have no title - [`14753ec`](https://github.com/Pasta-Devs/Marinara-Engine/commit/14753ec5d20cc4e4d148ea0fda44c623b542ea69) Merge origin/staging into fix/7324-party-promotion-card-match - [`ad2ef22`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ad2ef22150994b254ad623b5f885762163398147) Merge origin/staging into fix/7324-party-promotion-card-match - [`d0cd1d6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d0cd1d6b18c196c332902fc7f2b72168c594d7b8) Move the CHANGELOG entry away from other open PRs ### 📊 Changes **9 files changed** (+372 additions, -57 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/game/party-and-npcs.md` (+2 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+36 -11) 📝 `packages/client/src/components/ui/AppDialogRenderer.tsx` (+53 -16) 📝 `packages/client/src/hooks/use-game.ts` (+13 -1) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/client/src/stores/dialog.store.ts` (+12 -2) 📝 `packages/server/src/routes/game.routes.ts` (+71 -27) ➕ `scripts/regressions/game-party-recruit-card-choice.regression.ts` (+181 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7324 ## Why this change - In Game Mode, when the Game Master promoted an NPC to the party, Marinara looked the name up in the **whole character library first** and used partial matches. An NPC named Sam pulled in an unrelated female **Samantha** card, and an NPC named Emma pulled in an unrelated **Emma** card, so the party got a backstory and description that conflicted with the character the story had built. - Root cause: `POST /game/party/recruit` (`packages/server/src/routes/game.routes.ts`) matched library cards by exact name and then by substring (`lookup.includes(...)`), and a library match always won over the game's own tracked NPC. - Maintainer direction (Discord, quoted in the issue): when several characters share the name, ask the player which one, showing names, titles and avatars in a prompt window. ## What changed - **Server, `/game/party/recruit`** - Library cards are matched by exact (normalized) name only. Sam never matches Samantha. - When the game's tracked NPC and a library card share the name, or several library cards share it, the route changes nothing and returns `cardChoices` (id, name, title, avatar, avatar crop) so the player can pick. - New optional `characterId` in the request: a card id from those choices, or `null` to keep the game's own character. A card id that is not one of the same-name cards is refused. - Unchanged: a card or NPC already in the party is a quiet no-op (so the window does not come back), a single same-name card with no NPC of that name joins as before, and a name with no match still creates the tracked stand-in NPC. - A shortened name for a library card already in the party ("Kael" for "Kael Stormborn", whole words only) is treated as that member, so dropping the substring match does not add a duplicate stand-in. - An NPC the game met this session but has not tracked yet is in the journal's NPC log, so a single same-name card asks about it too instead of joining silently (the issue's Emma case when Emma was not a starting NPC). - Tracked NPCs are found by whole words too, so an NPC named Sam no longer recruits the game's own Samantha NPC. - A member of that name already in the party also wins over a late answer, so a stale window can never add a second Emma or Lena. - **Client** - `GameSurface` handles the `cardChoices` answer by opening the shared app choice dialog. Each card shows its avatar, name and title. The bottom button, **Keep the game's own <name>**, keeps the NPC. Closing the window (X, Escape, backdrop) does the same, so the game is never left half-done. Several prompts from one turn are asked one at a time, back to back (the next window does not wait for the previous pick's party card). - The recruit call now uses `mutateAsync`, because the per-call callbacks of `mutate()` only fire for the last of several calls in a loop. - `AppDialogRenderer` / `dialog.store`: choice dialog entries can carry an optional avatar and a smaller description line. Those rows are equal picks (no first-button highlight). Existing choice dialogs are unchanged. - 3 new English strings under `game.partyCardChoice.*`. - **Docs**: one paragraph in `docs/game/party-and-npcs.md` (Recruiting and removing party members). Translation follow-up: #7336. - **Regression**: `scripts/regressions/game-party-recruit-card-choice.regression.ts` runs the real route: Sam is never Samantha, NPC plus same-name card asks and changes nothing, a stray choice is refused, keeping the NPC adds `npc:emma` and asking again is quiet, two same-name cards let the player pick one, a single card still joins, and "Kael" stays the party's Kael Stormborn. It fails on current `staging` (Sam joins as Samantha). ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify in a Game: with an NPC named Sam and a library card named Samantha, ask the GM to add Sam to the party. Sam joins with the game's own profile and no Samantha card appears. - Manually verify: with an NPC named Emma and a library card named Emma, ask the GM to add Emma. A window titled "More than one Emma" lists the Emma card with its avatar and title. Picking the card adds the card; **Keep the game's own Emma** adds the NPC. - Manually verify that closing that window with X, Escape or a backdrop click keeps the game's own Emma and the next turn plays normally. - Manually verify: with the Character Tracker on, meet a new NPC named Mira mid-session (not a starting NPC), keep a library card named Mira, and ask the GM to add Mira. The window asks instead of adding the card. - Manually verify the window on a mobile viewport and in light and dark mode: avatars are round, long titles truncate, nothing overflows. - Manually verify an existing choice dialog (for example the character delete scope choice) still looks the same, with the first button highlighted. Agent-run checks: `node ./scripts/run-regressions.mjs --filter scripts/regressions/game-party-recruit-card-choice` (passes; fails on unfixed staging), `node ./scripts/run-regressions.mjs --filter scripts/regressions/game-ruleset-setup` (passes, recruit path unchanged for a single card), `pnpm check` via the slot limiter (exit 0), the existing `core-flows` e2e test "destructive confirmation actions use the shared accent button treatment" (passes, so plain choice dialogs keep their look), and a temporary Playwright check (not committed) that opened the new window on desktop-chromium and mobile-chromium: two rows with avatar or letter, name and truncated title, no first-row highlight, no overflow, and Escape resolving to "keep the game's own". Local CodeRabbit (`--committed` against the staging merge-base, run on the final commit after one earlier rate_limit answer) completed with no findings. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG: one entry under `[Unreleased]`. Docs: `docs/game/party-and-npcs.md`; translation follow-up #7336. ## UI evidence (if applicable) None captured by the agent. The window reuses the shared app choice dialog (`Modal`), with theme variables only. Out of scope: the reporter's wish to remove a card from a party member without removing the profile is not built here. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * When a game character’s name exactly matches multiple character cards, choose which card joins the party or keep the game’s character. Dismissing the choice window also keeps the game’s character. * Character choices can display an avatar and description to help distinguish cards. * **Bug Fixes** * A single exact-name card match still joins automatically when no game character with that name is already in the party. Similar names alone no longer cause a library card to be recruited. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:31 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7686
No description provided.