- 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
28 lines
466 B
TypeScript
28 lines
466 B
TypeScript
export interface PlayerModel {
|
|
user_id: string;
|
|
username: string;
|
|
index: number;
|
|
metadata: Record<string, string>; // e.g. { symbol: "X" }
|
|
}
|
|
|
|
export interface MatchDataModel<T = any> {
|
|
opCode: number;
|
|
data: T;
|
|
userId: string | null;
|
|
}
|
|
|
|
export interface Board {
|
|
grid: string[][];
|
|
}
|
|
|
|
export interface GameMetadata {
|
|
game: string;
|
|
mode: string;
|
|
}
|
|
|
|
export interface MatchDataMessage<T = any> {
|
|
opCode: number;
|
|
data: T;
|
|
userId: string | null;
|
|
}
|