Commit Graph

12 Commits

Author SHA1 Message Date
Jonas 955d1e18c6 Add player tags, game lifecycle and win checks
Additions and refactors across controllers, models, repo and services to support game lifecycle and win detection. Key changes:

- Models: Player now has PlayerTag; Game assigns tags, starts when 2 players join, exposes GetPlayerByConnectionId, StartGame and EndGame helpers.
- GameField: Implemented win-detection (CountInDirection, CheckLine, CheckForWin) and minor backing-field init.
- Repository/API: GameRepository.Create no longer accepts a Player (repo only creates games); minor variable cleanups; IGameRepository signature updated accordingly.
- Services: GameManager now injects IHubContext<GameHubSocket>, moves player-adding into manager (CreateGame), makes JoinGame async and notifies the SignalR group when a game starts, and adds a placeholder async Place method. Controller (GameHubSocket) also exposes a Place method stub to match the service API.

Motivation: separate responsibilities so repository only creates games, manager handles player joins and notifications, and add core game logic (player tagging and win checks) needed for gameplay. Place methods are added as placeholders for future move handling.
2026-03-12 23:20:05 +01:00
Jonas 85521f3b23 Return game ID+code; update hub and Player model
Change GameManager/CreateGame to return (gameId, gameCode) and Make JoinGame return the game Id (or null) instead of a bool. Update IGameManager signature accordingly. Refactor Hub methods to construct Player objects, accept Coordinates for game creation, use the manager results to add connections to groups and send GameCreated with GameId and GameCode, and handle join failures with an error message. Simplify Player class to use a primary-constructor style with property initialization; add necessary using directives.
2026-03-12 23:20:05 +01:00
Jonas ce52d1462f Add player list and wire repo/manager
Replace the nullable PlayerConnectionIds array with a private List<Player> inside Game and add AddPlayer/RemovePlayer methods to manage membership. Have GameRepository.Create attach the initial player to the newly created game. Implement GameManager.CreateGame and JoinGame to call the repository (using the injected gameRepository) — CreateGame returns the created game's code and JoinGame looks up the game and tries to add the player. Also update imports accordingly. These changes centralize player handling in the Game model and connect repository/manager flows to use it.
2026-03-12 23:20:05 +01:00
jonas 0e7bfb7241 Refactor GameRepository and GameManager architecture, introduce Player model, and update dependency registration in Program.cs. 2026-03-12 23:20:05 +01:00
jonas b967bd70eb Refactor and clean up codebase:
- Introduced `IGameRepository` interface and its implementation.
- Transitioned namespaces to `file-scoped` for consistency.
- Simplified class definitions, e.g., `Game` and `SixDigitInt`.
- Restructured `GameField` logic for improved readability and functionality.
- Fixed formatting issues in `API.csproj` and added a `using` directive in `Program.cs`.
2026-03-12 23:20:05 +01:00
jhim 5db7ac1676 Added Backend Classes and FUnctions for an working Game. But lacking Implementations 2026-03-12 23:20:05 +01:00
jonas 306dacc300 Update Vite output path and remove redundant wwwroot configuration 2026-03-12 23:20:05 +01:00
jonas 8eefc1a2b8 Configure API to serve SPA, integrate SignalR, and update build paths 2026-03-12 23:20:05 +01:00
jonas 3fa0455f1b Add GameController with SignalR functionality for joining games 2026-03-12 23:20:05 +01:00
jonas f98d9e79b2 Add StatusController, improve local game logic, and enable Swagger in API 2026-03-12 23:20:05 +01:00
jonas d39b06e3e9 Remove WeatherForecastController and update project file to clean up unused code. 2026-03-12 23:20:05 +01:00
jhim d886fa24a6 Add project files. 2026-02-06 08:29:28 +01:00