A command-line implementation of Monopoly in C++, designed to be played through a Text User Interface (TUI). This project is built for educational purposes and aims to simulate the classic board game with a custom set of features and rules.
For optimal display of the gameboard, use a monospace font. Without a monospace font, the board might appear misaligned.
This project was developed and tested on Linux. Due to hardware limitations, testing on macOS was not performed.
Windows may encounter issues with UTF-8 characters in the console. While it may work depending on fonts and terminal settings, some symbols might not display correctly.
To compile the game, follow these instructions:
g++ monopoly.cpp -o monopoly --std=c++11-
Create a build directory:
mkdir build cd build -
Run CMake:
cmake ..
-
Build the project:
cmake --build .
Upon starting the game you will either be prompted to load the last saved game or to set up players for a new game. Menu's can be navigated with their respective numbered entry.
Do you want to load last saved game?
┌────────┬────────┐
│ 1: YES │ 0: NO │
└────────┴────────┘
Here, entering "1" will load the last saved game, while entering "0" starts a new game.
Each player chooses a name, symbol, and color. The color will be used to highlight the player's position on the gameboard. This step is skipped, if loading a game from file.
- The turn order is randomized.
- Each player takes their turn, and during the turn, they can perform various actions like moving, buying properties, or paying rent.
- The game continues in this way until a player wins or the quit option is selected.
- Saving: The game automatically saves when quitting early, and there is a failsafe that ensures the game will save if invalid input is given.
- Loading: You can load a previously saved game if all the necessary
.csvfiles (likePlayers.csv,Tiles.csv, etc.) are located in the same folder.
While the game closely follows the rules of Monopoly, a few small deviations were implemented to enhance the gameplay experience:
- Railroad and Utility Cards: In the original game, players are required to pay double the rent or 10x the rolled die amount when landing on certain cards. In this version, we calculate rent using the standard rules.
- Bankruptcy and Cash Raising: When a player goes bankrupt, there is an option to try to raise cash, but selling properties to other players is not yet implemented.
- Free Parking: When landing on the "Free Parking" space, players receive money accumulated in the parking. This is a house rule commonly used in Monopoly but is not part of the original rules.
The following feature is not yet implemented:
- Player vs. Bot Mode: AI-controlled bots are not available, as developing a competitive AI for Monopoly is complex. A purely random decision-making AI could lead to repetitive or boring gameplay.
The following files are part of the project:
- monopoly.cpp: Contains the main game loop and logic for playing the game.
- FileImport.hpp: Handles loading data from CSV files (e.g., game board, player data).
- FileExport.hpp: Handles saving data to CSV files.
- player.hpp: Defines the
playerstruct and methods for player setup and actions. - tile.hpp: Defines the
tilestruct and methods for setting up the game board. - card.hpp: Defines the structures and functionality for Community and Chance cards.