refactor(game): extract lifecycle.ts standalone transitions (Phase 4 of #132)#139
Merged
nodots merged 2 commits intoJul 15, 2026
Conversation
#132) Move the standalone lifecycle transitions rollForStart and restoreState into src/Game/lifecycle.ts as free functions. Public Game.* statics remain thin delegating wrappers (external ai/api/client callers unchanged). rollForStart self-recurses on a tie via the module-local function (Rule A). Removed two now-dead imports from index.ts (RESTORABLE_GAME_STATE_KINDS, BackgammonPlayerRollingForStart). Game.initialize and Game.createNewGame stay on the class: they drive the new Game() constructor path (PositionReconstructor, gnuPositionId getter) and the overloaded initialize signature. Faithful move; pre-existing casts preserved. Characterization tests for restoreState (7) added in the prior commit stay green. No behavior change. Core: 475 passed / 12 skipped, tsc -b clean. Refs #132, #134
Base automatically changed from
refactor/game-decomp-phase3-cube
to
refactor/game-decomp-phase2-undo
July 15, 2026 18:34
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.
Phase 4 of the Game/index.ts decomposition epic (#133)
Stacked on #138 (Phase 3). Base is
refactor/game-decomp-phase3-cube; retarget todevelopmentas parents merge.Scope decision
Game.initializeandGame.createNewGamestay on the class — they drive thenew Game()constructor path (PositionReconstructor, thegnuPositionIdgetter consumed in ai/api) and the overloadedinitializesignature. This phase extracts only the clearly-standalone lifecycle transitions.What changed
restoreStatehad zero coverage; added 7 tests locking every validation guard branch + the valid-state passthrough.rollForStartis already well-covered by existing suites.src/Game/lifecycle.ts—rollForStartandrestoreStateas free functions.rollForStartself-recurses on a tie via the module-local function (Rule A).Game.*statics remain thin delegating wrappers.index.ts(RESTORABLE_GAME_STATE_KINDS,BackgammonPlayerRollingForStart).Verification
tsc -b --forcecleannpx jest: 475 passed / 12 skipped (468 baseline + 7 new)Refs #132, #134