[PR #6330] [MERGED] feat(game): choose a ruleset at game creation (rulesets slice 4) #7139

Closed
opened 2026-10-23 04:16:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6330
Author: @kolacheee
Created: 9/18/2026
Status: ✅ Merged
Merged: 9/18/2026
Merged by: @kolacheee

Base: staging ← Head: feat/rulesets-setup


📝 Commits (3)

  • 0267297 feat(game): choose a ruleset at game creation and copy sheets into the game
  • 0213882 fix(game): keep a card's ruleset sheet through session conclude and in-game save, and give recruits one
  • acbbb05 fix(game): address ruleset setup review findings

📊 Changes

16 files changed (+787 additions, -28 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+9 -1)
📝 docs/game/dice-and-skill-checks.md (+1 -1)
📝 docs/game/getting-started.md (+14 -1)
➕ packages/client/src/components/game/GameSetupRulesChooser.tsx (+155 -0)
📝 packages/client/src/components/game/GameSetupWizard.tsx (+65 -1)
📝 packages/client/src/components/game/GameSurface.tsx (+4 -1)
📝 packages/client/src/lib/game-setup-share.ts (+41 -2)
📝 packages/client/src/localization/locales/en.json (+12 -0)
📝 packages/server/src/routes/game.routes.ts (+110 -7)
📝 packages/server/src/services/game/name-normalization.ts (+1 -9)
📝 packages/shared/src/features/rulesets/sheet-math.ts (+15 -5)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/types/game.ts (+5 -0)
➕ packages/shared/src/utils/character-lookup-name.ts (+15 -0)
➕ scripts/regressions/game-ruleset-setup.regression.ts (+338 -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

Part of #6314 (slice 4 of 7; it does not close the issue). Builds on #6327 (slice 3, merged).

Why this change

  • Players need a way to start a game on a ruleset, and the game needs its own copy of each member's sheet.

What changed

  • Rules choice in the setup wizard, beside Combat Preference, for new games with at least one ruleset installed (GameSetupRulesChooser). It shows each ruleset's coverage summary and says when battles still use default combat. The Party step, where the persona and party are picked, then lists who Has a sheet and who Starts on a blank sheet (GameSetupRulesetSheetStatus).
  • The server builds the pin: only the chosen id is trusted. POST /game/create rebuilds the RulesetRef from its own registry, refuses ruleset_not_installed, and writes gameRuleset only when a ruleset was chosen, so legacy metadata keeps its bytes.
  • Copy-at-setup lives inside applyGameSetupPayload, so both setup entry points copy the same way: matched by normalized name, a blank default for a member without a sheet, and nothing written back to the library.
  • The wizard predicts the copy exactly: normalizeCharacterLookupName moved to the shared package (the server file re-exports it, so no server caller changed). The sheet status builds the same one-sheet-per-normalized-name map the server builds, with the persona's sheet winning a name it shares with a party member, and it uses the same "reads as a sheet" test, so a stored value the game would replace with a blank sheet is not listed as ready.
  • Setup sharing restores a ruleset when it is installed at the shared version or newer, otherwise drops it and names it in a notice. The pin in a shared file is read through rulesetRefSchema. Importing waits for the installed-rulesets list, so a list that is still loading cannot read as "not installed" and drop a ruleset this install has.
  • Regression: scripts/regressions/game-ruleset-setup.regression.ts, including a real create and /setup/apply-json run against a really installed package.

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

Commands run locally by the agent: pnpm check (exit 0), pnpm localization:check, and the regressions game-ruleset-setup and experience-setup-config. The agent also opened the wizard on a scratch server on port 7820 and saw the Rules block beside Combat Preference, selected 5e, and saw the pinned and default-combat lines. That check was made before the sheet status moved to the Party step, so the moved block is covered by type checks and lint only. Five local CodeRabbit sweeps were run before opening; the last returned no findings.

Still to verify by hand:

  • Manually verify the sheet status block at the end of the Party step, including a persona and a party member that share a name.
  • Manually create a game on 5e with a persona and a party member, generate the world, and confirm each card has a copied sheet.
  • Manually import a shared setup whose ruleset is not installed and confirm the notice.
  • Manually verify light mode and a phone-width viewport.

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)

Docs touched: CHANGELOG.md, docs/game/getting-started.md, the plan. The [docs-i18n] follow-up is batched for the ruleset slices.

UI evidence (if applicable)

To be added by a human: a screenshot of the Rules block.

Summary by CodeRabbit

  • New Features
    • Choose a Game Mode ruleset when creating a new game; the selection remains fixed.
    • Character and persona sheets are copied into the game, with blank sheets provided when needed.
    • Shared setup files preserve compatible rulesets and fall back to Marinara’s rules when unavailable.
    • Sheets persist through edits and session conclusion, and are copied to recruited members.
  • Documentation
    • Added guidance for rules, sheet handling, setup sharing, and ruleset behavior.

🔄 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/6330 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/18/2026 **Status:** ✅ Merged **Merged:** 9/18/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/rulesets-setup` --- ### 📝 Commits (3) - [`0267297`](https://github.com/Pasta-Devs/Marinara-Engine/commit/02672975acabcf6ddad6cf59a5e8cb4f9e1d1637) feat(game): choose a ruleset at game creation and copy sheets into the game - [`0213882`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0213882b8fd82846dda37c13e1461a87f1422fa7) fix(game): keep a card's ruleset sheet through session conclude and in-game save, and give recruits one - [`acbbb05`](https://github.com/Pasta-Devs/Marinara-Engine/commit/acbbb05514b61bfe371a9246a02bea5ee8efeb39) fix(game): address ruleset setup review findings ### 📊 Changes **16 files changed** (+787 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+9 -1) 📝 `docs/game/dice-and-skill-checks.md` (+1 -1) 📝 `docs/game/getting-started.md` (+14 -1) ➕ `packages/client/src/components/game/GameSetupRulesChooser.tsx` (+155 -0) 📝 `packages/client/src/components/game/GameSetupWizard.tsx` (+65 -1) 📝 `packages/client/src/components/game/GameSurface.tsx` (+4 -1) 📝 `packages/client/src/lib/game-setup-share.ts` (+41 -2) 📝 `packages/client/src/localization/locales/en.json` (+12 -0) 📝 `packages/server/src/routes/game.routes.ts` (+110 -7) 📝 `packages/server/src/services/game/name-normalization.ts` (+1 -9) 📝 `packages/shared/src/features/rulesets/sheet-math.ts` (+15 -5) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/types/game.ts` (+5 -0) ➕ `packages/shared/src/utils/character-lookup-name.ts` (+15 -0) ➕ `scripts/regressions/game-ruleset-setup.regression.ts` (+338 -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 Part of #6314 (slice 4 of 7; it does not close the issue). Builds on #6327 (slice 3, merged). ## Why this change - Players need a way to start a game on a ruleset, and the game needs its own copy of each member's sheet. ## What changed - **Rules choice** in the setup wizard, beside **Combat Preference**, for new games with at least one ruleset installed (`GameSetupRulesChooser`). It shows each ruleset's coverage summary and says when battles still use default combat. The **Party** step, where the persona and party are picked, then lists who **Has a sheet** and who **Starts on a blank sheet** (`GameSetupRulesetSheetStatus`). - **The server builds the pin**: only the chosen `id` is trusted. `POST /game/create` rebuilds the `RulesetRef` from its own registry, refuses `ruleset_not_installed`, and writes `gameRuleset` only when a ruleset was chosen, so legacy metadata keeps its bytes. - **Copy-at-setup** lives inside `applyGameSetupPayload`, so both setup entry points copy the same way: matched by normalized name, a blank default for a member without a sheet, and nothing written back to the library. - **The wizard predicts the copy exactly**: `normalizeCharacterLookupName` moved to the shared package (the server file re-exports it, so no server caller changed). The sheet status builds the same one-sheet-per-normalized-name map the server builds, with the persona's sheet winning a name it shares with a party member, and it uses the same "reads as a sheet" test, so a stored value the game would replace with a blank sheet is not listed as ready. - **Setup sharing** restores a ruleset when it is installed at the shared version or newer, otherwise drops it and names it in a notice. The pin in a shared file is read through `rulesetRefSchema`. Importing waits for the installed-rulesets list, so a list that is still loading cannot read as "not installed" and drop a ruleset this install has. - **Regression**: `scripts/regressions/game-ruleset-setup.regression.ts`, including a real create and `/setup/apply-json` run against a really installed package. ## 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 Commands run locally by the agent: `pnpm check` (exit 0), `pnpm localization:check`, and the regressions `game-ruleset-setup` and `experience-setup-config`. The agent also opened the wizard on a scratch server on port 7820 and saw the Rules block beside Combat Preference, selected 5e, and saw the pinned and default-combat lines. That check was made before the sheet status moved to the **Party** step, so the moved block is covered by type checks and lint only. Five local CodeRabbit sweeps were run before opening; the last returned no findings. Still to verify by hand: - Manually verify the sheet status block at the end of the **Party** step, including a persona and a party member that share a name. - Manually create a game on 5e with a persona and a party member, generate the world, and confirm each card has a copied sheet. - Manually import a shared setup whose ruleset is not installed and confirm the notice. - Manually verify light mode and a phone-width viewport. ## 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) Docs touched: `CHANGELOG.md`, `docs/game/getting-started.md`, the plan. The `[docs-i18n]` follow-up is batched for the ruleset slices. ## UI evidence (if applicable) To be added by a human: a screenshot of the Rules block. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Choose a Game Mode ruleset when creating a new game; the selection remains fixed. * Character and persona sheets are copied into the game, with blank sheets provided when needed. * Shared setup files preserve compatible rulesets and fall back to Marinara’s rules when unavailable. * Sheets persist through edits and session conclusion, and are copied to recruited members. * **Documentation** * Added guidance for rules, sheet handling, setup sharing, and ruleset behavior. <!-- 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-23 04:16:52 +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#7139
No description provided.