Skip to content

refactor(game): extract guards.ts pure predicates (Phase 1 of #132)#136

Merged
nodots merged 1 commit into
developmentfrom
refactor/game-decomp-phase1-guards
Jul 15, 2026
Merged

refactor(game): extract guards.ts pure predicates (Phase 1 of #132)#136
nodots merged 1 commit into
developmentfrom
refactor/game-decomp-phase1-guards

Conversation

@nodots

@nodots nodots commented Jul 15, 2026

Copy link
Copy Markdown
Owner

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

Stacked on #135 (Phase 0). Base is refactor/game-decomp-phase0-shared; review/merge #135 first, then this retargets to development.

What changed

  • New src/Game/guards.ts (leaf module) holds the pure turn/roll predicates canRoll, canRollForStart, canPlayerRoll, canGetPossibleMoves as free functions.
  • The public Game.can* static methods stay as thin delegating wrappers, so external callers in ai/api/client see no API change — first use of the facade-delegation pattern the rest of the epic follows.
  • canPlayerRoll calls the module-local canRoll directly (Rule A: extracted functions never route back through the Game facade).
  • Cube predicates (canOfferDouble/canAcceptDouble/canRefuseDouble) and canUndoActivePlay are intentionally left for their concern-specific modules (cube.ts / undo.ts).

Verification

  • tsc -b --force clean
  • npx jest: 448 passed / 12 skipped (identical to baseline)
  • No behavior change; no public API change

Refs #132, #133

Move the pure turn/roll predicates canRoll, canRollForStart,
canPlayerRoll, and canGetPossibleMoves into src/Game/guards.ts as free
functions. The public Game.can* static methods remain as thin
delegating wrappers so external callers (ai/api/client) are unchanged.
canPlayerRoll calls the module-local canRoll directly (Rule A).

Cube predicates (canOffer/Accept/RefuseDouble) and canUndoActivePlay
stay behind for cube.ts / undo.ts phases.

No behavior change. Core: 448 passed / 12 skipped, tsc -b clean.

Refs #132, #133
Base automatically changed from refactor/game-decomp-phase0-shared to development July 15, 2026 18:32
@nodots
nodots merged commit 9b5bd1a into development Jul 15, 2026
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