Skip to content

Instantly share code, notes, and snippets.

@darkLord19
Last active May 23, 2020 17:33
Show Gist options
  • Save darkLord19/7ecf184995b58d8a4fa966e9af7c56cd to your computer and use it in GitHub Desktop.
Save darkLord19/7ecf184995b58d8a4fa966e9af7c56cd to your computer and use it in GitHub Desktop.
create new game:
localhost:8080/new?players_count=2&dimension=4
// this will return json with gameboard name
join game:
localhost:8080/join?roomname=weaselginger&username=uparmar&color=%FF1744
//color is hexadecimal color code. we accept only colors declared in constant package
// this will return json object with gameboard containing details about current turn and initial game board
play game:
ws://localhost:8080/play?roomname=flyfir&username=uparmar
// return if any errors in validation otherwise wait for players moves
// upon player move, we will broadcast msg to all players.
it contais color for updated current turn, which board state was updated and array which depicts level wise board state i.e
[1,2,3,4,5,2...,-1,..]
-1 seperates levels i.e -1 is one level of BFS for move made by user
// 1 is x, 2 is y in matrix[x][y] and 3 is count i.e. array represent values in the form (x,y,count),(x,y,count)
structure of move msg:
{ "xpos":1, "ypos":2, player_username:"uparmar"}
then backend simulates game and updates board state and sends whole game instance object as broadcast whjich contains updated current turn and updated board state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment