From 3b87cf6da558cc2bccc791f1415499aa173b1691 Mon Sep 17 00:00:00 2001 From: Skayo Date: Tue, 1 May 2018 01:40:27 +0200 Subject: [PATCH] Renamed JSON_Game to JSONGame and commented struct --- gamemanagment.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gamemanagment.go b/gamemanagment.go index 78b0fbb..c342fb6 100644 --- a/gamemanagment.go +++ b/gamemanagment.go @@ -7,16 +7,17 @@ import ( "werwolf/core" ) -var games []JSON_Game +var games []JSONGame -type JSON_Game struct { +// JSONGame represents the game struct +type JSONGame struct { Token string `json:"token"` Username string `json:"username"` Gamename string `json:"gamename"` } // getGame returns a reference to a game-Object identified by token -func getGame(token string) (*JSON_Game, bool) { +func getGame(token string) (*JSONGame, bool) { for _, g := range games { if g.Token == token { return &g, true @@ -26,7 +27,7 @@ func getGame(token string) (*JSON_Game, bool) { } // addGame adds a game-Object game to the list of active games or replaces an inactive game. -func addGame(game JSON_Game) bool { +func addGame(game JSONGame) bool { a := true for _, g := range games { if g.Token == "" { @@ -53,7 +54,7 @@ func removeGame(token string) bool { } func newGame(responseWriter http.ResponseWriter, request *http.Request) { - var game = new(JSON_Game) + var game = new(JSONGame) buf := new(bytes.Buffer) buf.ReadFrom(request.Body) @@ -71,7 +72,7 @@ func newGame(responseWriter http.ResponseWriter, request *http.Request) { } func joinGame(responseWriter http.ResponseWriter, request *http.Request) { - var game = new(JSON_Game) + var game = new(JSONGame) buf := new(bytes.Buffer) buf.ReadFrom(request.Body)