Skip to content

refactor(game): extract cube.ts (Phase 3 of #132)#138

Merged
nodots merged 2 commits into
refactor/game-decomp-phase2-undofrom
refactor/game-decomp-phase3-cube
Jul 15, 2026
Merged

refactor(game): extract cube.ts (Phase 3 of #132)#138
nodots merged 2 commits into
refactor/game-decomp-phase2-undofrom
refactor/game-decomp-phase3-cube

Conversation

@nodots

@nodots nodots commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Phase 3 of the Game/index.ts decomposition epic (#133)

Stacked on #137 (Phase 2). Base is refactor/game-decomp-phase2-undo; retarget to development as parents merge.

What changed

  1. Characterization tests first (test: expand core coverage, starting with Game/index.ts extraction targets #134) — 10 tests covering the gaps not already exercised by crawford-jacoby-rules.test.ts: double output shape, canAcceptDouble/acceptDouble cube transfer, and resign (simple/gammon scoring, Jacoby reduction, disabled-resign + already-completed guards).
  2. New src/Game/cube.tscanOfferDouble, canAcceptDouble, acceptDouble, canRefuseDouble, refuseDouble, resign, double as free functions.
  3. Public Game.* statics remain thin delegating wrappers (external ai/api/client callers unchanged). Internal cross-calls are module-local (Rule A).
  4. The cube-slice predicates land here with their concern, as deferred from the guards phase.

Scope note

Faithful move — pre-existing as any casts 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 --force clean
  • npx jest: 468 passed / 12 skipped (458 baseline + 10 new)
  • index.ts shrinks ~300 lines; no behavior change; public API unchanged

Refs #132, #134

nodots added 2 commits July 15, 2026 09:18
Cover the gaps not already exercised by crawford-jacoby-rules.test.ts:
Game.double output shape, canAcceptDouble/acceptDouble cube transfer,
and Game.resign (simple/gammon scoring, Jacoby reduction, disabled-resign
and already-completed guards). 10 tests.

Refs #132, #134
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
@nodots
nodots merged commit 30a42dd into refactor/game-decomp-phase2-undo Jul 15, 2026
@nodots
nodots deleted the refactor/game-decomp-phase3-cube branch July 15, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant