v0.1 - orionsbelt-battlegrounds/game GitHub Wiki

The first milestone will be all about the engine, networking and data persistence. No UI will be contemplated. On v0.1 we will be able to:

  • Open a raw page on a browser
  • The page spawns a bot
  • The boot connects to ws://server/lobby - the lobby will send messages with the current open games to join
  • If there are no game available, the bot creates a new game, by sending an HTTP request to http://server/create-game, and waits for an opponent
  • If there is a game available to join, the bot will join it and on ws://server/game/:id will play when it's turn, and wait when it's the opponent's turn
  • When the game ends, the bot will return to listen to the lobby

Extra mile:

  • The lobby also sends messages with the amount of games running and the number of players online
  • It's possible to have spectators on a running game

Guidelines

  • For all work to be done, an issue should be created with the implementation overview
  • All server dependecies (rethingdb, events, etc) should be able to represent itself using Components.

Modules

Server src/obb/server/

The server will have to persist a game and be able to identify players. On the lobby, should use a pub/sub/events mechanism (maybe abstracted on src/obb/events?). Every player connected should subscribe to the lobby event. When a related game is created/joined, an event should be fired and all the subscribers should receive the new lobby, that will receive the data via the websocket.

Should have endpoints to create and join games. And another websocket for two players to play a game. Maybe also use pubsub to notify game changes?

Frontend src/obb/frontend/

The frontend will be very simple and just have a dummy page that launches a bot.

Bot src/obb/bot/

All the logic to create/join games and play them. Should be coded in cljc so that in the future we be able to spawn JVM servers with bots.

Persistence src/obb/dal/ ???

All the abstractions to CRUD operations and at least one implementation, in rethinkdb.

Events src/obb/events/ ???

Abstraction for typical publish/subscribe workflow. For now just in memory with core.async, but considering an external source (redis?, queues?).

URL Flow

The following shows a group of URLs and how to interact with them to make things happen:

  • /game/create - Creates a game with one player, registers it on the lobby, that sends an event notification
  • /lobby - WebSocket - When you connect you get the full lobby. Then lobby changes, you get what changed
  • /game/join/:id - Allows other player to join a game, notifies the lobby to remove the game from the list
  • /game/:id - WebSocket - When you connect you get the full game, and you'll get additional game versions when it changes. If you are a player and it's your time to play, you can send the actions to perform