[PR #6327] [MERGED] feat(game): ruleset sheets on characters and personas (rulesets slice 3) #7137

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/6327
Author: @kolacheee
Created: 9/18/2026
Status: ✅ Merged
Merged: 9/18/2026
Merged by: @kolacheee

Base: staging ← Head: feat/rulesets-sheets


📝 Commits (2)

  • f5ea468 feat(game): store and edit ruleset sheets on characters and personas
  • 8f3a181 fix(game): refuse oversized ruleset sheet edits and report a failed ruleset read

📊 Changes

24 files changed (+1042 additions, -13 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/characters/colors-and-stats.md (+16 -0)
📝 docs/characters/personas.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+9 -1)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+6 -0)
📝 packages/client/src/components/personas/PersonaEditor.tsx (+9 -0)
➕ packages/client/src/components/rulesets/RulesetSheetEditor.tsx (+416 -0)
➕ packages/client/src/components/rulesets/RulesetSheetsSection.tsx (+186 -0)
📝 packages/client/src/hooks/use-capability-packages.ts (+11 -0)
📝 packages/client/src/localization/locales/en.json (+22 -0)
📝 packages/server/src/routes/capability-packages.routes.ts (+10 -1)
📝 packages/server/src/services/game/ruleset-registry.service.ts (+11 -4)
📝 packages/server/src/services/import/marinara.importer.ts (+21 -1)
📝 packages/server/src/services/import/st-character.importer.ts (+13 -2)
📝 packages/shared/src/features/rulesets/sheet-math.ts (+6 -3)
📝 packages/shared/src/schemas/character.schema.ts (+3 -0)
📝 packages/shared/src/schemas/persona.schema.ts (+8 -1)
📝 packages/shared/src/schemas/ruleset.schema.ts (+65 -0)
📝 packages/shared/src/types/character.ts (+3 -0)
📝 packages/shared/src/types/persona.ts (+2 -0)

...and 4 more files

📄 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 3 of 7; it does not close the issue). Builds on #6323 (slice 2, merged).

Why this change

  • A ruleset needs a full character sheet, and players need somewhere to enter one before a game starts. Sheets belong to the character or persona as a starting build.

What changed

  • Storage: rulesetSheets, keyed by ruleset id, on character.data.extensions and persona.personaStats. The boundary checks only what holds for any ruleset (a usable key, an object, 64 KB per sheet, 32 sheets) and never the sheet's shape, because the ruleset may not be installed. Keep dormant, never drop.
  • Importers cap, they do not refuse: an unusable sheet costs an import that sheet, never the card. This runs in the native importer, the SillyTavern importer and normalizePersonaStats.
  • Exports verified: native, Compatible JSON, PNG, bulk and backup all copy extensions and personaStats wholesale, so sheets travel.
  • Editor: one generic, schema-driven RulesetSheetEditor in both Stats tabs, one collapsible entry per installed ruleset. Dormant sheets show as one line with Remove. Values are clamped when edited, never when read.
  • A sheet the editor cannot read is never overwritten: a stored value for an installed ruleset that does not read as a sheet (saved by a newer version, or edited by hand) shows as "Cannot be edited here" with Remove this sheet only, so Add a sheet can never replace it. A failed load of the installed rulesets shows a line saying so instead of hiding the block, and Add a sheet is off once a card holds the 32-sheet limit, so a save cannot fail on it.
  • Sheet math: a stored choice the ruleset no longer offers reads as the field's default in abilityModFromField, which is also what the editor shows, so the two cannot disagree.
  • API: GET /api/capability-packages/rulesets.
  • Regression: scripts/regressions/game-ruleset-sheets-storage.regression.ts (boundary, cards, personas, native and SillyTavern imports against a real store), plus one row in game-ruleset-checks.regression.ts for the stale choice.

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 storage regression. The agent also drove a scratch server on port 7820 with the 5e package installed: the block rendered in the character Stats tab in dark mode, DEX 16 and level 5 recomputed proficiency +3 and Stealth expertise +9, Save persisted the sheet, a dormant Kenhito/v20 sheet was kept and shown as one line, the Compatible JSON export carried both sheets, and live geometry at 400 px showed no overflow. A test character holding an unreadable 5e sheet showed "Cannot be edited here" with Remove this sheet as the only button. Four local CodeRabbit sweeps were run before opening; the last returned no findings.

Still to verify by hand:

  • Manually verify the persona Stats tab the same way.
  • Manually verify the failed-load line and the 32-sheet limit note (both are covered by type checks only).
  • Manually verify light mode and take the light, dark and 400 px screenshots.

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/characters/colors-and-stats.md, docs/characters/personas.md, the plan. The [docs-i18n] follow-up is batched for the ruleset slices.

UI evidence (if applicable)

To be added by a human: light, dark and 400 px screenshots of the Ruleset sheets block.

Summary by CodeRabbit

  • New Features

    • Added ruleset-specific character and persona sheets in the Stats tab.
    • Sheets use layouts defined by installed Game Modes, calculate derived values automatically, and provide starting builds copied into new games.
    • Sheets for unavailable rulesets are retained, removable, and included in exports.
    • Added limits of 32 sheets per card or persona and 64 KB per sheet.
  • Bug Fixes

    • Imports now preserve valid ruleset sheets while dropping only unusable entries.
  • Documentation

    • Documented ruleset sheets for characters, personas, and Game Mode development.

🔄 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/6327 **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-sheets` --- ### 📝 Commits (2) - [`f5ea468`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f5ea4687c0e488ab7fdb70386f36de2989ceb608) feat(game): store and edit ruleset sheets on characters and personas - [`8f3a181`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f3a181eccff5b65a3fba5d64dbba77411ea5b0f) fix(game): refuse oversized ruleset sheet edits and report a failed ruleset read ### 📊 Changes **24 files changed** (+1042 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/characters/colors-and-stats.md` (+16 -0) 📝 `docs/characters/personas.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+9 -1) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+6 -0) 📝 `packages/client/src/components/personas/PersonaEditor.tsx` (+9 -0) ➕ `packages/client/src/components/rulesets/RulesetSheetEditor.tsx` (+416 -0) ➕ `packages/client/src/components/rulesets/RulesetSheetsSection.tsx` (+186 -0) 📝 `packages/client/src/hooks/use-capability-packages.ts` (+11 -0) 📝 `packages/client/src/localization/locales/en.json` (+22 -0) 📝 `packages/server/src/routes/capability-packages.routes.ts` (+10 -1) 📝 `packages/server/src/services/game/ruleset-registry.service.ts` (+11 -4) 📝 `packages/server/src/services/import/marinara.importer.ts` (+21 -1) 📝 `packages/server/src/services/import/st-character.importer.ts` (+13 -2) 📝 `packages/shared/src/features/rulesets/sheet-math.ts` (+6 -3) 📝 `packages/shared/src/schemas/character.schema.ts` (+3 -0) 📝 `packages/shared/src/schemas/persona.schema.ts` (+8 -1) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+65 -0) 📝 `packages/shared/src/types/character.ts` (+3 -0) 📝 `packages/shared/src/types/persona.ts` (+2 -0) _...and 4 more files_ </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 3 of 7; it does not close the issue). Builds on #6323 (slice 2, merged). ## Why this change - A ruleset needs a full character sheet, and players need somewhere to enter one before a game starts. Sheets belong to the character or persona as a starting build. ## What changed - **Storage**: `rulesetSheets`, keyed by ruleset id, on `character.data.extensions` and `persona.personaStats`. The boundary checks only what holds for any ruleset (a usable key, an object, 64 KB per sheet, 32 sheets) and never the sheet's shape, because the ruleset may not be installed. **Keep dormant, never drop.** - **Importers cap, they do not refuse**: an unusable sheet costs an import that sheet, never the card. This runs in the native importer, the SillyTavern importer and `normalizePersonaStats`. - **Exports verified**: native, Compatible JSON, PNG, bulk and backup all copy `extensions` and `personaStats` wholesale, so sheets travel. - **Editor**: one generic, schema-driven `RulesetSheetEditor` in both **Stats** tabs, one collapsible entry per installed ruleset. Dormant sheets show as one line with **Remove**. Values are clamped when edited, never when read. - **A sheet the editor cannot read is never overwritten**: a stored value for an installed ruleset that does not read as a sheet (saved by a newer version, or edited by hand) shows as "Cannot be edited here" with **Remove this sheet** only, so **Add a sheet** can never replace it. A failed load of the installed rulesets shows a line saying so instead of hiding the block, and **Add a sheet** is off once a card holds the 32-sheet limit, so a save cannot fail on it. - **Sheet math**: a stored choice the ruleset no longer offers reads as the field's default in `abilityModFromField`, which is also what the editor shows, so the two cannot disagree. - **API**: `GET /api/capability-packages/rulesets`. - **Regression**: `scripts/regressions/game-ruleset-sheets-storage.regression.ts` (boundary, cards, personas, native and SillyTavern imports against a real store), plus one row in `game-ruleset-checks.regression.ts` for the stale choice. ## 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 storage regression. The agent also drove a scratch server on port 7820 with the 5e package installed: the block rendered in the character **Stats** tab in dark mode, DEX 16 and level 5 recomputed proficiency +3 and Stealth expertise +9, **Save** persisted the sheet, a dormant `Kenhito/v20` sheet was kept and shown as one line, the Compatible JSON export carried both sheets, and live geometry at 400 px showed no overflow. A test character holding an unreadable 5e sheet showed "Cannot be edited here" with **Remove this sheet** as the only button. Four local CodeRabbit sweeps were run before opening; the last returned no findings. Still to verify by hand: - Manually verify the persona **Stats** tab the same way. - Manually verify the failed-load line and the 32-sheet limit note (both are covered by type checks only). - Manually verify light mode and take the light, dark and 400 px screenshots. ## 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/characters/colors-and-stats.md`, `docs/characters/personas.md`, the plan. The `[docs-i18n]` follow-up is batched for the ruleset slices. ## UI evidence (if applicable) To be added by a human: light, dark and 400 px screenshots of the **Ruleset sheets** block. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added ruleset-specific character and persona sheets in the **Stats** tab. * Sheets use layouts defined by installed Game Modes, calculate derived values automatically, and provide starting builds copied into new games. * Sheets for unavailable rulesets are retained, removable, and included in exports. * Added limits of 32 sheets per card or persona and 64 KB per sheet. * **Bug Fixes** * Imports now preserve valid ruleset sheets while dropping only unusable entries. * **Documentation** * Documented ruleset sheets for characters, personas, and Game Mode development. <!-- 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#7137
No description provided.