Skip to content

kovalllllll/CourseWork

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎮 MyCourseWork - Tic-Tac-Toe Console Game

C# .NET 9 Spectre.Console Platform

A console-based Tic-Tac-Toe game built with modern C# and .NET 9, featuring clean architecture, beautiful terminal UI with Spectre.Console, user authentication, and game history tracking.


📋 Table of Contents


📖 Description

MyCourseWork is a classic Tic-Tac-Toe game implemented as a console application with a modern terminal interface. The project demonstrates clean architecture principles by separating concerns into distinct layers:

  • Presentation Layer - Beautiful console UI powered by Spectre. Console
  • Business Layer - Contains game logic and authentication services
  • Data Layer - Manages data persistence with repository pattern

✨ Key Features

Feature Description
🔐 User Authentication Register and login functionality with validation
🎯 Play vs Bot Challenge the AI opponent in Tic-Tac-Toe
📊 Rating System Track your performance with ELO-like rating (starts at 1000)
📜 Game History Record and view past games
🎨 Beautiful UI Interactive menus with Spectre.Console
🏗️ Clean Architecture Three-layer architecture with Dependency Injection
👥 User Management List all registered users

🛠️ Technologies

Core

Technology Version Description
C# 12 Primary programming language
.NET 9.0 Framework and runtime

Libraries & Packages

Package Version Purpose
Spectre.Console 0.49.1 Beautiful console UI components
Spectre.Console.Cli 0.49.1 Command-line interface builder
Microsoft.Extensions.DependencyInjection 9.0.0 Dependency Injection container

📁 Project Structure

CourseWork/
├── 📂 MyCourseWork/                    # 🖥️ Presentation Layer (Console App)
│   ├── 📂 Commands/                    # Command pattern implementations
│   ├── 📂 Extensions/                  # DI extension methods
│   ├── 📄 CommandManager.cs            # Command dispatcher
│   ├── 📄 GameFactory.cs               # Game instance factory
│   ├── 📄 GameLogic.cs                 # Core game mechanics (3x3 board)
│   ├── 📄 ICommand.cs                  # Command interface
│   ├── 📄 MyCourseWork.csproj          # Project configuration
│   └── 📄 Program.cs                   # Application entry point & menu
│
├── 📂 MyCourseWork. Business/           # 💼 Business Logic Layer
│   ├── 📂 Service/                     # Service implementations
│   │   ├── 📄 AuthService.cs           # Registration, login, password update
│   │   └── 📄 GameService.cs           # Game recording logic
│   ├── 📂 Extensions/                  # DI extensions
│   ├── 📄 IAuthService.cs              # Auth service contract
│   ├── 📄 IGameService. cs              # Game service contract
│   └── 📄 MyCourseWork.Business.csproj
│
├── 📂 MyCourseWork.Data/               # 💾 Data Access Layer
│   ├── 📂 Entity/                      # Domain entities (User, GameRecord)
│   ├── 📂 Interfaces/                  # Repository contracts
│   ├── 📄 InMemoryUserRepository.cs    # In-memory user storage
│   ├── 📄 InMemoryGameRepository.cs    # In-memory game storage
│   ├── 📄 MyCourseWorkDbContext.cs     # Database context
│   └── 📄 MyCourseWork.Data.csproj
│
├── 📄 MyCourseWork.sln                 # Solution file
├── 📄 . gitignore                       # Git ignore rules
└── 📄 README.md                        # This file

⚙️ Installation

Prerequisites

Steps

  1. Clone the repository

    git clone https://github.com/kovalllllll/CourseWork.git
    cd CourseWork
  2. Restore dependencies

    dotnet restore
  3. Build the solution

    dotnet build

🚀 Usage

Running the Application

dotnet run --project MyCourseWork

Main Menu Options

When you start the application, you'll see an interactive menu:

┌─────────────────────────────────────┐
│               Menu:                 │
├─────────────────────────────────────┤
│  > Register                         │
│    Login                            │
│    List Users                       │
│    Exit                             │
└─────────────────────────────────────┘
Option Description
Register Create a new user account with username and password
Login Authenticate and access game features
List Users View all registered users and their ratings
Exit Close the application

Gameplay

  1. 🔐 Register or login to your account
  2. 🎮 Start a new Tic-Tac-Toe game
  3. ✖️ Choose your symbol (X or O)
  4. 📍 Enter coordinates (0-2) for row and column to place your mark
  5. 🏆 Try to get three in a row before the bot does!

Game Rules

  • The board is a 3x3 grid
  • Players take turns placing their symbol
  • First to align 3 symbols horizontally, vertically, or diagonally wins
  • If all cells are filled with no winner, it's a draw

🤝 Contribution

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Commit your changes
    git commit -m 'Add some amazing feature'
  4. Push to the branch
    git push origin feature/amazing-feature
  5. Open a Pull Request

📝 Contribution Guidelines

  • ✅ Follow C# coding conventions and . NET best practices
  • ✅ Write meaningful commit messages
  • ✅ Add XML comments for public APIs
  • ✅ Keep the clean architecture structure
  • ✅ Update documentation as needed

💡 Ideas for Contribution

  • Add difficulty levels for the bot (Easy/Medium/Hard)
  • Implement minimax algorithm for unbeatable AI
  • Add multiplayer mode (player vs player)
  • Persist data to a database (SQLite/PostgreSQL)
  • Add unit tests

🌟 Star this repo if you found it helpful!

Made with ❤️ by @kovalllllll

About

A console-based Tic-Tac-Toe game built with modern C# and .NET 9

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages