A game with two independent units β the players β communicating with each other using an API.
When a player starts, it starts a random (whole) number and sends it to the second player as an approach of starting the game. The receiving player can now always choose between adding one of {-1,0,1} to get to a number that is divisible by 3. Divide it by three. The resulting whole number is then sent back to the original sender. the security layer does not reflect the player. it is just a security demonstration to access the platform.
- PrivateRoute
- PublicRoute
The behaviour of the PrivateRoute is it renders the targeted component if the user is logged in and redirect to the PublicRoute if not logged in.
The default PublicRoute renders the Login component.
The Login component is a form on it's submit the user sends the credentials to the server via 'http' request to get a valid JWT.
after successful login the App redirects to the root Route / and renders the players components then init the socket connection.
here they are
| username | password |
|---|---|
| runesam | rogina003 |
| sameh | rogina003 |
install yarn package manager globally
Yarn
clone the repo git clone git@github.com:runesam/independent-units-communication.git
then navigate to the project root dir cd independent-units-communication
- navigate to the client dir
cd client - install dependencies via
yarn - init the client server via
yarn serve- default client server port is defined in
.envfile as3000.
- default client server port is defined in
- navigate to the client dir
cd server - install dependencies via
yarn - init the client server via
yarn start- default server port is defined in
.envfile as5000.
- default server port is defined in
./install.sh
./execute.sh- build the image
docker build -t game .- run the container
docker run -p 3000:3000 -p 5000:5000 game- Redux as state manager
- custom middleware
- axios
- socket.io
- redux form
- material UI
- jest
- express
- socket.io
- jwt
- bcrypt
- app is only designed for mobile. responsive to be implemented
- full unit test
- integration test
- include the jwt in the socket messages to be validated
- implement tests for the backend
- enhance message listeners
- remove players from players list when they are in a game so they don't receive invitations
- break the game in case one of players left the game.
Both players should be able to play automatically without user input. One of the players should optionally be adjustable by a user.not really clear. but to be done :)
![Login flow]](/runesam/independent-units-communication/raw/master/docs/01.gif)
![Login flow]](/runesam/independent-units-communication/raw/master/docs/02.gif)