Table of Contents
War is a card game with it's simplest version played between two players. The rules for this implementation can be found here. You can read up more about the game here.
The major frameworks/libraries used in this project are as listed below:
The backend flask server and mysql server are dockerized to run in two containers. Prior to setting up and running the backend and mysql server, make sure you have docker and docker-compose installed and setup. The installation guide for the docker engine can be found here. Docker-compose is installed with the desktop version of docker engine, you can visit this page for more information. Follow the instructions on these pages carefully and verify the installation and the version at the end.
For the frontend, make sure Node and NPM are installed on your computer. You can download both at this link (NPM is included in your Node installation).
Note: The following commands and installation steps have been tested on MacOS.
Once you have verified docker-compose and npm are installed and working correctly, you may first proceed to build and run the backend and database services.
- Clone the repo
git clone https://github.com/arjun120/war-card-game.git
-
cd war-card-game
- Here, you can use
docker-compose
to build the images and start the containers for the backend and SQL db.docker-compose up -d
- The endpoint to your backend Flask server is exposed on port
4000
. - Now that your backend and db services are up and running, you can run the frontend React server.
-
cd war-ui
- Now, install NPM packages using
npm install
- Now, if your backend is running on
127.0.0.1
that islocalhost
if you ran your containers locally, you can start the react server using the following command:Replace theREACT_APP_BACKEND_IP=127.0.0.1 npm start
127.0.0.1
with the DNS of the container depending on where your backend service is running. - Now, you have successfully installed and run the war game. You should be able to access the game at http://localhost:3000/.
- The backend for this project currently simulates the game between two players. This could be extended to accommodate more players by adapting to a different version of the game. Currently a variation of the regular version is implemented to handle and avoid infinite sessions of the game. The current fix includes declaring the game as a draw in case the number of cards in each players deck toggles between two fixed values for a threshold number of rounds. While this variation is a reasonable fix, alternate versions could be explored.
- The backend and db for this game have been dockerized and packaged as a unit which can be brought up and down easily. The UI is a separate service, which runs independently. While this decoupling was a design choice, the three services could be dockerized and brought up finally exposing only the UI to the users. These services could also be deployed and orchestrated using tools such as Kubernetes on a cloud platform.
- Finally, the UI could be improved to show the cards in play dynamically. However, observing the number of rounds these games typically last for, this may not be viable. Other improvements such as beautification of the UI could be potential directions to explore.
Arjun Manjunatha Rao | LinkedIn | email
Project Link: https://github.com/arjun120/war-card-game