Sozzle uses a centralized game lifecycle management system provided by the game_core package. This package orchestrates the main game flow and state transitions.
-
GameCoreBloc: The main orchestrator that manages game state and lifecycle
- Located in:
packages/game_core/lib/src/bloc/ - Registered in:
lib/app.dart
- Located in:
-
Repository Adapters: Bridge between GameCore and existing repositories
LevelRepositoryAdapter: AdaptsILevelRepositorytoGameLevelRepositoryUserProgressRepositoryAdapter: AdaptsIUserStatsRepositorytoUserProgressRepository- Located in:
lib/src/game_core/adapters/
-
GameCoreCoordinator: Shell route that handles navigation based on game state
- Located in:
lib/src/game_core/coordinator/ - Wraps all routes in:
lib/core/routes/routes.dart
- Located in:
Splash → Home (Idle) → Loading → Playing → Level Won → Home (Idle)
↓
Next Level
- HomePage: Dispatches
PlayLevelRequestedevent - GamePlayPage: Listens to
GameCorePlayingstate, dispatchesLevelCompleted - LevelCompletePage: Dispatches
NextLevelRequestedorReturnToHomeRequested - GameCoreCoordinator: Automatically navigates based on state changes
- Game Start:
GameCoreBlocis initialized withGameStartedevent inapp.dart - Level Selection: HomePage reads
currentLevelfromGameCoreState.progress - Level Play: GamePlayPage displays level from
GameCorePlaying.level - Level Completion: GamePlayBloc triggers
LevelCompletedevent when all words found - Progress Persistence: GameCore automatically saves progress through repository adapters
packages/
game_core/ # Game lifecycle orchestration (pure Dart)
level_data/ # Level data models and serialization
level_generator/ # Procedural level generation
Run GameCore tests:
cd packages/game_core && dart testRun app tests:
flutter test-
The input is not considered if it's less than 3 characters long. Check lib/src/game_play/view/components/game_play_letters.dart:73 -- The _onInputComplete method.
-
GameCore uses pure Dart and has no Flutter dependencies, making it highly testable
-
Navigation is declarative - the coordinator reacts to state changes automatically
-
User progress is automatically persisted when levels are completed
-
The existing
UserStatsCubitstill manages boosters independently
- Add state class to
packages/game_core/lib/src/bloc/game_core_state.dart - Add corresponding event to
game_core_event.dart - Add event handler in
game_core_bloc.dart - Update
GameCoreCoordinatorto handle new state for navigation - Add tests in
packages/game_core/test/src/bloc/game_core_bloc_test.dart
- Update GameCore events/states as needed
- Modify coordinator navigation logic if needed
- Update UI pages to dispatch new events
- Ensure tests cover new flow
To debug game state transitions:
- GameCore logs all transitions with the name
GameCoreBloc - Check logs for: "GameCore: Starting game", "GameCore: Loading level X", etc.
- Use Flutter DevTools to inspect
GameCoreBlocstate in real-time
- GameCore API:
packages/game_core/README.md