Renamed JSON_Game to JSONGame and commented struct

This commit is contained in:
Skayo
2018-05-01 01:40:27 +02:00
parent 8df812cb59
commit 3b87cf6da5

View File

@@ -7,16 +7,17 @@ import (
"werwolf/core" "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"` Token string `json:"token"`
Username string `json:"username"` Username string `json:"username"`
Gamename string `json:"gamename"` Gamename string `json:"gamename"`
} }
// getGame returns a reference to a game-Object identified by token // 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 { for _, g := range games {
if g.Token == token { if g.Token == token {
return &g, true 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. // 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 a := true
for _, g := range games { for _, g := range games {
if g.Token == "" { if g.Token == "" {
@@ -53,7 +54,7 @@ func removeGame(token string) bool {
} }
func newGame(responseWriter http.ResponseWriter, request *http.Request) { func newGame(responseWriter http.ResponseWriter, request *http.Request) {
var game = new(JSON_Game) var game = new(JSONGame)
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
buf.ReadFrom(request.Body) buf.ReadFrom(request.Body)
@@ -71,7 +72,7 @@ func newGame(responseWriter http.ResponseWriter, request *http.Request) {
} }
func joinGame(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 := new(bytes.Buffer)
buf.ReadFrom(request.Body) buf.ReadFrom(request.Body)