<aside> 🃏
UNO-Java-Game
A Java implementation of the famous card game UNO, playable in the terminal. It is a OOP Java project, using the model View-Controller we can get the players to play against eachother or against a machine using the terminal.
</aside>
We chose UNO because we both know how to play it and the rules are clear enough to know what you need to code. It has turns, special cards with effects, and a winner condition, which is basically everything you need for a game.
| Class | Package | What it does |
|---|---|---|
| Card | model | A card. Has a value and a color. Has a method to check if you can play it on top of the current card. |
| Color | model | Enum for the colors: RED, BLUE, GREEN, YELLOW and BLACK (black is for wild cards). |
| Value | model | Enum for the values: numbers 0 to 9, SKIP, REVERSE, DRAW_TWO, WILD and WILD_DRAW_FOUR. |
| Deck | model | The draw pile. Builds all 108 cards when you create it and shuffles them. If it runs out, it takes the discard pile and shuffles that back in. |
| Hand | model | The cards a player has in their hand right now. You can add cards, play one by position, and check if there is anything playable. |
| Player | model | A player. Has a name, a hand, and a boolean for whether it is the computer or a real person. |
| GameState | model | Stores everything about the current match: the players, the deck, the discard pile, whose turn it is, which direction the game is going, the active color, and a HashMap with how many wins each player has. |
| ConsoleView | view | All the printing and reading from the console goes here. Cards are shown with ANSI colors. There is no game logic in this class. |
| GameController | controller | Controls the flow: sets up the game, runs the turn loop, applies card effects, and calls the view and the model when needed. |
| FileManager | utils | Reads and saves scores.csv. That is basically all it does. |
The game runs in the terminal. At the start you choose how many players there are (between 2 and 4) and whether each one is a person or the computer. The computer player is not very smart, but it works: it tries to play action cards when it can, and when it plays a wild it picks the color it has the most of in its hand.
When you run the program it loads scores.csv if it exists and shows the main menu.
If you pick New Game:
From the menu you can also check the rules or see the all-time scores.
Wins are saved in a CSV file so they do not reset every time you close the program.