feat(rules): character-sheet assembly — deriveSheet()#5
Merged
Conversation
The pure function that turns a character's choices into a complete computed sheet, tying every subsystem together. Lives in the engine (no Convex/UI dep) so it runs in tests, the backend, or the client. - schema/character.ts — Character: the player's choices (occId, level, 8 attributes, hthType, skill picks + bonuses, spell picks, optional rolled H.P./ S.D.C./P.P.E.). Derived stats are computed, never stored. - engine/character.ts — deriveSheet(character): validates, then returns identity, attribute bonuses, combat profile (attacks/strike/parry/dodge/damage), vitals (H.P./S.D.C. ranges + coma/death floor), P.P.E. range, spell strength, a saves map (attribute + O.C.C. bonuses, with targets), resolved skill %s, and known spells. Tested end-to-end against a level-1 Ley Line Walker. 70 tests pass; `vp check` clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ur5Eu6dC17feVQH5smrFw
There was a problem hiding this comment.
4 issues found across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
… skills/spells - P.P.E.: add ppeRange(occ, pe, level) that includes per-level growth (was showing level-1 base for all levels); basePpeRange delegates to it. deriveSheet now uses the character's level. - Psionics save target: carry `psychicClass` on the character (default "ordinary") and pass it to psionicsSaveTarget, instead of hardcoding "ordinary". - Reject duplicate skillIds and spellIds via schema .refine() (can't take a skill or know a spell twice). - deriveSheet accepts CharacterInput (z.input) so defaulted fields may be omitted. 73 tests pass; `vp check` clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ur5Eu6dC17feVQH5smrFw
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Requires human review: Core character sheet assembly function with complex derivation logic; requires domain expert review for correctness.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pure character-assembly that turns a player's choices into a complete computed sheet — the culmination of the rules engine, and the function the Convex backend will serve.
What's included
schema/character.ts—Character: the player's choices (O.C.C. id, level, 8 attributes, H2H type, skill picks + their bonuses, spell picks, optional recordedrolledH.P./S.D.C./P.P.E.). Derived stats are computed, never stored.engine/character.ts—deriveSheet(character): validates the character, then assembles:Pure and deterministic — dice rolls are inputs (
character.rolled), not generated — so it runs anywhere.Verification
vp run rules#test→ 70 tests (9 new), asserting a full level-1 Ley Line Walker sheet (attacks 4, P.P.E. 64–214, spell strength 12, Wilderness Survival 44%, +4 vs Horror Factor, …)vp run rules#check→ cleanNext
This is the sheet the Convex backend will persist + serve. Convex setup needs an interactive
npx convex devlogin, so that lands in a follow-up once the deployment is provisioned.Summary by cubic
Adds
deriveSheetto compute a complete character sheet from a player's choices. Now level-aware P.P.E., psionics saves honor the character’s psychic class, and duplicate skills/spells are rejected.New Features
engine/character.ts:deriveSheet(character)validates input and returns identity, attribute bonuses, combat profile, vitals, P.P.E./spell strength, saves, resolved skills, and known spells.schema/character.ts:Characterschema for choices (O.C.C., level, attributes, H2H, skills with bonuses, spellIds, optional rolled H.P./S.D.C./P.P.E.,psychicClasswith default "ordinary").index.ts; tests assert a level‑1 Ley Line Walker sheet.Bug Fixes
psychicClass.skillIdandspellIdentries.Written for commit efe3af0. Summary will update on new commits.