To run the game locally:
- Clone this repository (obviously!)
- Run
mix setup
to download Elixir and Nodejs dependencies - Run
mix phx.server
to start the Phoenix Server
Now you can visit localhost:4000
from your browser to play the game.
Scenario 1: A user wants to start a game.
- User goes to http://localhost:4000
- Since there is no Game ID in the URL params, LV generates a new Game ID and redirects the user and a new game is started upon redirect.
Scenario 2: A user wants to join a game.
- User gets a link with Game ID to join the game.
- User visits the link and the LV process checks for the Game ID in the Registry and gets the active GameServer pid of the game.
- Since the GameServer process is managing the game state and LV is only displaying this state and relaying commands from the user to this GameServer pid, the displayed board is a shared one between all users joining the game.
Scenario 3: GameServer gets shutdown when the user leaves the game
- For every game, there is a GameServer (GenServer) process started by a Dynamic Supervisor.
- When the user quits the LV page, we capture the terminate event and stop the corresponding GameServer if no other user is playing the game (in a multiplayer environment). This avoids stale GameServer sitting around forever.
Scenario 4: When the user joins a game with the link, the GameServer had already stopped running.
- User A invites User B with a link to the game.
- Before User B joins the game, User A has quit the game.
- Since there is no other player active, GameServer is stopped. When User B joins the game, a message is displayed that the game has ended and an option to start a new game is provided.
- Play solo or play with any number of people sharing the same board. (First come first served basis. All players share the same board. Key press are processed chronologically.)
- Play on mobile using touch keys or use keyboard on desktop.
- Bored to keep moving tiles? Use autoplay and watch the game playing itself. (but why would you do that??)
- Chat with other team members.
- WIP: Democracy and Random Extreme mode of play.
- During the slide, tiles of equal values pushed into each other will merge into a new tile with the combined value. 2 + 2 = 4
- If there are 3 values next to each other, e.g. 2 2 2, and the player slides right, the values closest to the wall gets merged first resulting in 2 4.
- Cascading merge in a single swipe If there are 3 values next to each other, e.g., 4 2 2, and the player slides right, the value closest to the wall gets merged first resulting in 4 and since the following number is also 4, it gets merged again in the same swipe and ends up as 8.