refactor(game): extract guards.ts pure predicates (Phase 1 of #132)#136
Merged
Conversation
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
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 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 todevelopment.What changed
src/Game/guards.ts(leaf module) holds the pure turn/roll predicatescanRoll,canRollForStart,canPlayerRoll,canGetPossibleMovesas free functions.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.canPlayerRollcalls the module-localcanRolldirectly (Rule A: extracted functions never route back through theGamefacade).canOfferDouble/canAcceptDouble/canRefuseDouble) andcanUndoActivePlayare intentionally left for their concern-specific modules (cube.ts / undo.ts).Verification
tsc -b --forcecleannpx jest: 448 passed / 12 skipped (identical to baseline)Refs #132, #133