It is web app made with Golang server (no database) with websockets and rest API. Frontend is done in VueJs. Golang API serves the static files from frontend.
It is a betting game, where player inputs his name and chooses 2 numbers.
One number is drawn every 1s. Score is calculated and ranking between players is shown. Game lasts max 30 rounds.
It is a multiplayer game, and minimum 2 players are needes to start the game.
More info below.
- 2 players are needed to start the game (1 browser tab one player)
- On the initial page click "Play"
- Then fill your name
- Click on 2 numbers of your choice (1 to 10)
- Click "Join"
- Open another tab/window of this link in your browser
- Repeat in this other tab the steps 1 to 4
- Game will start
- When new players join in a running game they will only observe until next game starts, then they will join automatically.
- New random number generated every 1 second
- Maximum 30 rounds
- Ends if any player reaches exactly 21 points
- 10 seconds of interval between games
-
Exact match
- +5 points if there is exact match with one of the chosen number
-
Inside bounds
- +5-(upper bound - lower bound); e.g.: 3 and 8 chosen, 7 is the round number, then 5-(8-3)=0
-
Out of bounds
- -1 point; e.g.: 3 and 8 chosen, 9 is the round number
- Points
- Highest upper number chosen
- Highest lower number chosen
- Name ascending
- Players cannot have the same name
- Player names are saved in lowercase and cannot be edited
- Players cannot leave the game
- Numbers chosen cannot be changed
- New browser tab, means new player (player saved on session storage)
Below are 2 options to run the project locally:
It will build frontend and backend, generate a single docker image and run it on port 8888:
make run-docker
# Open in the browser: http://localhost:8888
# Run server locally on port 8787
make run-local
# Install Vue frontend dependencies and run it locally
make run-frontend
# Open in the browser: http://localhost:8080
# It will run tests locally
make test
# or
# It will run the same tests on docker
make test-docker
# It will run linting on docker
make lint-docker
HOST
PORT
LOGGER_LEVEL
The command below will build frontend Vue app for production(generate static files) and will build Go backend and generate the server binary. Afterwards it generates a small Alpine docker image that it is deployable
make image