This is a C++ implementation of the classic card game UNO. The game supports two players and includes all the standard UNO rules, such as playing matching cards, drawing cards, and using special cards like Skip, Reverse, Draw Two, Wild, and Wild Draw Four. The game also features a scoreboard to track wins and a history log to save game results.
- Two-Player Gameplay: Play against another player in a turn-based manner.
- Full UNO Rules: Includes all standard UNO rules and special cards.
- Colorful Console Interface: Uses colored text to represent cards and game elements.
- Scoreboard: Tracks the number of wins for each player.
- Game Logs: Saves game results and statistics to a file.
- Pause and Resume: Players can pause the game and return to the main menu.
- Uno Call: Players must call "Uno" when they have one card left, or face a penalty.
- Start the Game: Choose option
1
from the main menu to start a new game. - Player Turns:
- Each player takes turns playing a card that matches the color or value of the top card on the discard pile.
- Special cards (Skip, Reverse, Draw Two, Wild, Wild Draw Four) have unique effects.
- Drawing Cards: If a player cannot play a card, they must draw a card from the deck.
- Calling Uno: When a player has one card left, they must call "Uno" to avoid a penalty.
- Winning the Game: The first player to play all their cards wins the game.
-
Main Functions:
initializeDeck()
: Initializes the deck with all UNO cards.shuffleDeck()
: Shuffles the deck randomly.dealCards()
: Deals cards to both players at the start of the game.playTurn()
: Handles a player's turn, including playing cards, drawing cards, and handling special cards.saveLoadGameResult()
: Saves game results and updates the scoreboard.storedHistory()
: Displays the scoreboard with the number of wins for each player.
-
Helper Functions:
cardHorizontal()
: Displays a card in the console with color and value.PrintPlayerHand()
: Displays a player's hand of cards.isValidPlay()
: Checks if a card can be played on the current top card.handleSpecialCard()
: Handles the effects of special cards.
- Operating System: Windows (uses Windows-specific functions like
GetStdHandle
andSetConsoleTextAttribute
). - Compiler: A C++ compiler that supports C++11 or later (e.g., GCC, Clang, or MSVC).
- Clone the repository or download the source code.
- Compile the code using a C++ compiler:
g++ -o uno_game main.cpp
- Run the executable:
./uno_game
main.cpp
: The main source code file containing the game logic.results1.txt
: Stores the number of wins for Player 1.results2.txt
: Stores the number of wins for Player 2.game_logs.txt
: Logs game results and statistics.
- Multiplayer Support: Add support for more than two players.
- AI Opponent: Implement an AI opponent for single-player mode.
- Graphical Interface: Create a graphical user interface (GUI) for a better user experience.
- Cross-Platform Support: Modify the code to work on non-Windows platforms.
This project is open-source. Feel free to modify and distribute it.
Abdullah
abdullah_netiz
[email protected]
Enjoy playing UNO! 🎴