feat: add authoritative O.C.C. starting loadouts#66
Conversation
📝 WalkthroughWalkthroughStructured O.C.C. starting loadouts now define validated grants, choices, and checklist guidance. The builder submits only selections, while character creation resolves and rolls inventory server-side before validation and storage. Review screens distinguish unrolled grants from equipment and preserve legacy-character behavior. ChangesStructured loadout rules
Authoritative creation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Player
participant BuilderStore
participant CreateMutation
participant LoadoutEngine
participant CharacterStore
Player->>BuilderStore: choose loadout items
BuilderStore->>CreateMutation: submit loadoutSelections
CreateMutation->>LoadoutEngine: resolve and provision loadout
LoadoutEngine-->>CreateMutation: rolled CharacterItem[]
CreateMutation->>CharacterStore: validate and insert character
Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/rules/tests/loadouts.test.ts (1)
296-303: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMake the grant expectation explicit per case.
The
.toBe(...)argument recomputes the expected value from the same input the code under test consumes, so a bug that drops legal grants could still satisfy it. An explicitexpectsEnergyGrant: booleanon each case entry states the intent directly.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/rules/tests/loadouts.test.ts` around lines 296 - 303, Add an explicit expectsEnergyGrant boolean to each case entry in the loadout test cases, then update the assertion in the resolveStartingLoadout loop to compare the energy-weapon grant presence against case.expectsEnergyGrant instead of deriving it from selections.choices.packages/rules/src/schema/loadouts.ts (1)
104-113: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider bounding the selections payload.
choicesis an unbounded record of unbounded arrays.resolveStartingLoadoutpushes one error string per unknown key, so a large client-submitted payload produces a proportionally large error array on the server path. A.max(...)on both the record entries andselectedItemIdsSchemakeeps the request boundary cheap.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/rules/src/schema/loadouts.ts` around lines 104 - 113, Bound the starting loadout payload by applying a reasonable maximum to both the selected item ID array in selectedItemIdsSchema and the record entries in startingLoadoutSelectionsSchema. Preserve the existing non-empty and uniqueness validation while ensuring resolveStartingLoadout cannot receive unbounded choices or selections.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/rules/src/engine/loadouts.ts`:
- Around line 230-234: Make the rng parameter required in
provisionStartingLoadout by removing its Math.random default, then update every
caller—including backend creation transactions and tests—to pass an explicit
deterministic random source. Preserve the function’s existing behavior while
ensuring no call site can silently use ambient randomness.
---
Nitpick comments:
In `@packages/rules/src/schema/loadouts.ts`:
- Around line 104-113: Bound the starting loadout payload by applying a
reasonable maximum to both the selected item ID array in selectedItemIdsSchema
and the record entries in startingLoadoutSelectionsSchema. Preserve the existing
non-empty and uniqueness validation while ensuring resolveStartingLoadout cannot
receive unbounded choices or selections.
In `@packages/rules/tests/loadouts.test.ts`:
- Around line 296-303: Add an explicit expectsEnergyGrant boolean to each case
entry in the loadout test cases, then update the assertion in the
resolveStartingLoadout loop to compare the energy-weapon grant presence against
case.expectsEnergyGrant instead of deriving it from selections.choices.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 66a39401-73db-4fc8-975a-d559a56778fc
📒 Files selected for processing (25)
README.mdapps/web/src/builder/loadout-summary.tsxapps/web/src/builder/steps/loadout.tsxapps/web/src/builder/steps/occ.tsxapps/web/src/builder/steps/review.tsxapps/web/src/builder/store.tsapps/web/src/components/sheet-view.tsxapps/web/src/pages/new-character.tsxapps/web/tests/builder.test.tsapps/web/tests/character-sheet.test.tsdocs/rules/PAGE_MAP.mdpackages/backend/convex/characters.tspackages/backend/convex/schema.tspackages/backend/tests/characters.test.tspackages/backend/tests/combat.test.tspackages/backend/tests/healing-cast.test.tspackages/rules/src/content/occ/ley-line-walker.jsonpackages/rules/src/engine/loadouts.tspackages/rules/src/engine/occ.tspackages/rules/src/index.tspackages/rules/src/schema/loadouts.tspackages/rules/src/schema/occ.tspackages/rules/tests/character.test.tspackages/rules/tests/loadouts.test.tspackages/rules/tests/occ.test.ts
Summary
Authoritative sources
Rendered Rifts Ultimate Edition pages were used for the full Ley Line Walker entry and every referenced catalog item:
Validation
packages/rules:vp check; 20 files / 417 tests passedpackages/backend:vp check; 3 files / 139 tests passedapps/web:vp check; 4 files / 70 tests passedvp check: 134 formatted files; 106 lint/typechecked filesvp test: 27 files / 626 tests passedgit diff --checkpassedBoundaries
No retroactive grants or migration, Coalition Grunt implementation, vehicle/wallet system, ammunition consumption, or unrelated inventory changes are included.
Closes #62
Summary by cubic
Add authoritative, structured starting loadouts for the Ley Line Walker and provision starting inventory on the server during character creation. Validation is tightened to reject illegal or oversized selections and any client-authored items; quantities and armor capacity roll per instance at forge.
New Features
@riftforge/rules: Structured O.C.C. starting-loadout schema and Ley Line Walker content (fixed grants, exact-choice groups, checklist). Added planning, choice validation, and provisioning with per-suit armor rolls, a 100-instance cap, and hardening against duplicates, unknown keys, and wrong-pool picks.packages/backend:characters.createnow acceptsloadoutSelections, rejects clientitems, validates choices, and provisions concrete inventory atomically. Added a request validator forloadoutSelections.apps/web: New “Loadout” step and shared summary; the review shows the unrolled plan and hides the manifest; switching O.C.C. clears only loadout choices when ownership changes.Migration
loadoutSelectionson create; do not senditems.Written for commit c41f0aa. Summary will update on new commits.