refactor(game): extract cube.ts (Phase 3 of #132)#138
Merged
nodots merged 2 commits intoJul 15, 2026
Conversation
Move the cube/doubling and resign logic into src/Game/cube.ts as free functions: canOfferDouble, canAcceptDouble, acceptDouble, canRefuseDouble, refuseDouble, resign, double. The public Game.* statics remain thin delegating wrappers so external callers (ai/api/client) are unchanged. Internal cross-calls go module-local (Rule A): acceptDouble->canAcceptDouble, canRefuseDouble->canAcceptDouble, refuseDouble->canRefuseDouble, double->canOfferDouble. The cube-slice predicates (canOfferDouble/canAcceptDouble/canRefuseDouble) land here with their concern, as deferred from the guards phase. Faithful move: pre-existing casts preserved verbatim (cube-slice #96 cast removal is out of scope for this phase). Characterization tests (10) added in the prior commit stay green. No behavior change. Core: 468 passed / 12 skipped, tsc -b clean. Refs #132, #134
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 3 of the Game/index.ts decomposition epic (#133)
Stacked on #137 (Phase 2). Base is
refactor/game-decomp-phase2-undo; retarget todevelopmentas parents merge.What changed
crawford-jacoby-rules.test.ts:doubleoutput shape,canAcceptDouble/acceptDoublecube transfer, andresign(simple/gammon scoring, Jacoby reduction, disabled-resign + already-completed guards).src/Game/cube.ts—canOfferDouble,canAcceptDouble,acceptDouble,canRefuseDouble,refuseDouble,resign,doubleas free functions.Game.*statics remain thin delegating wrappers (external ai/api/client callers unchanged). Internal cross-calls are module-local (Rule A).Scope note
Faithful move — pre-existing
as anycasts in the cube slice are preserved verbatim. Cube-slice cast removal (#96) is intentionally not in this phase (only the undo slice was analyzed for #96).Verification
tsc -b --forcecleannpx jest: 468 passed / 12 skipped (458 baseline + 10 new)index.tsshrinks ~300 lines; no behavior change; public API unchangedRefs #132, #134