Documentation
¶
Index ¶
- type CreateGameReq
- type JoinGameReq
- type ListGameResp
- type PlayMoveReq
- type Runtime
- func (r *Runtime) AttachGame(w http.ResponseWriter, req *http.Request) error
- func (r *Runtime) Close() error
- func (r *Runtime) CreateGame(w http.ResponseWriter, req *http.Request) error
- func (r *Runtime) Init(four *engine.Four) error
- func (r *Runtime) JoinGame(w http.ResponseWriter, req *http.Request) error
- func (r *Runtime) ListGames(w http.ResponseWriter, req *http.Request) error
- func (r *Runtime) PlayMove(w http.ResponseWriter, req *http.Request) error
- func (r *Runtime) Run() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateGameReq ¶
CreateGameReq is the request to create a new game.
type JoinGameReq ¶
JoinGameReq is the request to join a game.
type ListGameResp ¶
type ListGameResp struct { GameID string `json:"game_id"` PlayerCount int `json:"player_count"` MaxPlayerCount int `json:"max_player_count"` GameState string `json:"game_state"` Players map[engine.State]string `json:"players"` }
ListGameResp is the response
type PlayMoveReq ¶
PlayMoveReq is the request to play a move in a game.
type Runtime ¶
Runtime is a HTTP server for Connect Four.
func (*Runtime) AttachGame ¶
AttachGame is the http endpoint to attach to a game. This endpoint will send one message each time the game changes state until the game is finished.
Method: GET Query String: - game_id: string, game uuid to attach to. Response: - JSON object of engine.Four. One entry per state change.
func (*Runtime) CreateGame ¶
CreateGame is the http endpoint handling the game creation.
Method: GET Query String: - cols: int, columns count of the grid. - rows: int, rows count of the grid. - nplayers: int, number of players allowed in the game. - nwin: int, number of consecutive field to win. Response: - json formatted UUID of the new game.
func (*Runtime) Init ¶
Init setup the connect four game. Note: In server mode, we discard the init's given engine.
func (*Runtime) JoinGame ¶
JoinGame is the http endpoint to join a game.
Method: GET Query String: - game_id: string, uuid of the game to join. - player_name: string, arbitrary player name.
func (*Runtime) ListGames ¶
ListGames is the http endpoint returning the list of games.
Method: GET Response: - JSON array of ListGameResp.