- Removed onCellClick from TicTacToeGameProps and migrated move sending inside TicTacToeGame
- Updated TicTacToeGame to:
- import TicTacToePayload
- use movePayload() builder
- send moves using handleMove() with matchId + sendMatchData
- remove old matchId destructuring duplication
- Updated BattleshipGame to:
- import BattleshipPayload
- use placePayload() and shootPayload() helpers
- collapse place and shoot handlers into a single handleMove()
- send typed payloads instead of raw objects
- Updated App.tsx:
- Removed handleCellClick and no longer pass onCellClick down
- Created typed ticTacToeProps and battleshipProps without UI callbacks
- Cleaned unused state and simplified board rendering
- Use {...commonProps} to propagate shared game state
- Updated props:
- Removed TicTacToeGameProps.onCellClick
- BattleshipGameProps continues to extend GameProps
- Removed duplicate MatchDataModel definition from interfaces/models
- Fixed imports to use revised models and payload types
This refactor completes the transition from UI-triggered handlers to
typed action payloads per game, significantly improving type safety,
consistency, and separation of concerns.
- Replaced multiple App-level state fields with unified GameState
- Added INITIAL_GAME_STATE and migrated App.tsx to use single game state
- Introduced GameProps as shared base props for all turn-based board games
- Created TicTacToeGameProps and BattleshipGameProps extending GameProps
- Updated TicTacToe and Battleship components to use new props
- Replaced verbose prop passing with spread {...commonProps}
- Updated renderGameBoard to use game.metadata consistently
- Renamed TicTacToeBoard -> TicTacToeGame for clarity
- Renamed BattleShipBoard -> BattleShipGame for naming consistency
- Updated all import paths to reflect new component names
- Replaced MatchDataMessage with MatchDataModel
- Moved GameState definition from models.ts to interfaces/states.ts
- Removed old board-specific prop structures and per-field state management
- Increased type safety and reduced duplication across the codebase
This commit consolidates game state flow, introduces a clean component props
architecture, and standardizes naming convention
- Extracted context contract to `contexts.ts` (NakamaContextType)
- Added strongly typed internal provider refs in `refs.ts`
- socketRef: React.RefObject<Socket | null>
- gameMetadataRef: React.RefObject<GameMetadata | null>
- Added `NakamaProviderState` in `states.ts` for React-managed provider state
- session, socket, matchId, matchmakerTicket
- Refactored NakamaProvider to use new modular structure
- Replaced scattered useState/useRef with structured internal state + refs
- Updated onMatchData to use MatchDataMessage model
- Replaced deprecated MutableRefObject typing with RefObject
- Cleaned update patterns using `updateState` helper
- Updated imports to use new models and context structure
- Improved separation of responsibilities:
- models = pure domain types
- context = exposed provider API
- refs = internal mutable runtime refs
- state = provider-managed reactive state
- Ensured all Nakama provider functions fully typed and consistent with TS
This refactor improves clarity, type safety, and maintainability for the
Nakama real-time multiplayer provider.
Added renderGameBoard() resolver for dynamic board rendering
Board now hidden before match join
Game auto-selected based on metadata.game from Player matchmaking
Updated header to use dynamic game name
Removed hardcoded Battleship board
- Replaced single `board` state with `boards` map in App.tsx
- Updated state parsing to use `state.boards` instead of `state.board.grid`
- Updated TicTacToeBoard props to accept `boards` instead of `board`
- Safely extracted TicTacToe board using `boards['tictactoe']?.grid ?? null`
- Added loading fallback when board is not yet available
- Updated rendering guards to prevent undefined map errors
This change fully aligns the frontend with the new multi-board MatchState
introduced on the server (supports TicTacToe, Battleship, and future games).