Welcome to the War Card Game repository! This Python program allows you to play the classic card game of War, where players compete to win all the cards in the deck.
War (also known as Battle in the United Kingdom) is a simple card game typically played by two players using a standard playing card deck. The objective of the game is to win all of the cards. In this implementation, the player with the higher number of cards at the end of 10 rounds is declared the winner.
To play the game, follow these steps:
- Run the main Python program main.py.
- Enter the names of the two players.
- View the cards dealt to each player.
- Watch as the game progresses through 10 rounds.
- At the end of the game, the winner will be declared.
Object-oriented design: The game is implemented using classes and objects, making it modular and easy to understand. Customizable: Players can enter their names and initial number of cards. Interactive: The game prints out the moves and waits between rounds to build tension. Unit tests: The program includes unit tests to ensure the correctness of the classes.
Python 3.x No additional libraries or dependencies required, except for the standard random module.
To run the game, simply download or clone the entire project directory onto your local machine. Then, navigate to the project directory in your terminal or command prompt and execute the main.py file using Python:
python3 main.py
If you're using PyCharm, you can run unit tests directly from the PyCharm interface instead of using terminal commands:
- Open your PyCharm project.
- Navigate to the test file in the Project tool window.
- Right-click on the test file and select "Run
Test-Name
" or "RunTest-Name
with Coverage" from the context menu. - PyCharm will execute the unit tests and display the results in the "Run" tool window.
By running the tests through PyCharm, you can take advantage of its features such as test result visualization, debugging, and coverage analysis.
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.