This project is a C# implementation of the UNO card game. The game supports both console and web-based play, with features including game state saving/loading, bot players, and multiplayer support. Work is still in progress.
The UNO Card Game project is structured into several components:
- ConsoleApp: The console-based application for playing UNO.
- DAL: Data Access Layer, including Entity Framework context and repositories.
- Domain: Domain models and enums representing the game entities.
- GameEngine: Core game logic and rules implementation.
- Helpers: Utility classes and methods.
- MenuSystem: Console menu system.
- UnoConsoleUI: Console UI components.
- WebApp: Web application using Razor Pages for playing UNO online.
-
Clone the repository:
git clone <repository-url> cd uno-card-game
-
Update .NET tools:
dotnet tool update --global dotnet-ef dotnet tool update --global dotnet-aspnet-codegenerator
-
Create a new migration:
dotnet ef migrations add --project DAL --startup-project ConsoleApp InitialCreate
or
dotnet ef migrations add --project DAL --startup-project WebApp InitialCreate
-
Update the database:
dotnet ef database update --project DAL --startup-project WebApp
Navigate to the ConsoleApp
directory and run:
dotnet run
Navigate to the WebApp
directory and run:
dotnet run
If you want to switch between using a database or JSON file repository, you need to update the Program.cs
files in both the Web App and Console App.
In the Web App, modify the Program.cs
file located in WebApp/Program.cs
:
builder.Services.AddScoped<IGameRepository, GameRepositoryEF>();
//builder.Services.AddSingleton<IGameRepository, GameRepositoryFileSystem>();
Comment out the line for the repository you do not need.
In the Console App, modify the Program.cs
file located in ConsoleApp/Program.cs
:
//IGameRepository gameRepository = new GameRepositoryFileSystem();
IGameRepository gameRepository = new GameRepositoryEF(db);
Comment out the line for the repository you do not need.
The game setup involves initializing the game options, setting up players, and dealing cards. This is handled by the UnoGameEngine
class.
The game flow is managed by the GameController
class, which handles player turns, card plays, and game state updates.
Bot players are supported and can be configured to play automatically. The bot logic is implemented within the UnoGameEngine
class.
The game state can be saved to and loaded from both JSON files and a database. The data access logic is implemented in the GameRepositoryFileSystem
and GameRepositoryEF
classes.
This project is licensed under the MIT License.