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`.
This commit is contained in:
2026-02-27 20:36:44 +01:00
committed by Jonas
parent 5db7ac1676
commit b967bd70eb
11 changed files with 153 additions and 157 deletions
+15 -22
View File
@@ -1,26 +1,19 @@
using API.Models.DataClasses;
namespace API.Models.Game
namespace API.Models.Game;
public enum GameState
{
public enum GameState
{
Lobby,
Running,
Ended
}
public class Game
{
public string Id { get; init; } = Guid.NewGuid().ToString();
public SixDigitInt GameCode { get; }
public string?[] PlayerConnectionIds { get; set; } = new string?[2];
public GameState State { get; private set; } = GameState.Lobby;
public GameField Field { get; }
public Game(Coordinates gFs, SixDigitInt gameCode)
{
Field = new GameField(gFs);
GameCode = gameCode;
}
}
Lobby,
Running,
Ended
}
public class Game(Coordinates gFs, SixDigitInt gameCode)
{
public string Id { get; init; } = Guid.NewGuid().ToString();
public SixDigitInt GameCode { get; } = gameCode;
public string?[] PlayerConnectionIds { get; set; } = new string?[2];
public GameState State { get; private set; } = GameState.Lobby;
public GameField Field { get; } = new(gFs);
}