diff --git a/game.go b/game.go index cfaf4c4..97e95a6 100644 --- a/game.go +++ b/game.go @@ -357,3 +357,16 @@ func (g *game) sendGameOver(eg *GameOver) { s.send <- eg } } + +// returns a GameParam object popuplated by info from the game. This is +// used during client/server initial negociation. +func (g *game) gameParam() *GameParam { + return &GameParam{ + BoardSize: BoardSize{ + Width: g.width, + Height: g.height, + }, + MaxPoints: g.maxPoints, + Type: "gameparam", + } +} diff --git a/protocol.go b/protocol.go index 0b46b73..d6bea26 100644 --- a/protocol.go +++ b/protocol.go @@ -71,20 +71,13 @@ type BoardSize struct { } type GameParam struct { + // TODO: should have information about max points in here BoardSize BoardSize `json:"boardsize"` + MaxPoints int `json:"max_points"` Type string `json:"type"` } // > [OK | FULL | NOT AUTH], board size, game params -func NewGameParam(w, h float32) *GameParam { - return &GameParam{ - BoardSize: BoardSize{ - Width: w, - Height: h, - }, - Type: "gameparam", - } -} type Handshake struct { ID string `json:"id"` @@ -197,7 +190,7 @@ func addPlayer(ws *websocket.Conn) { return } - gameParam := NewGameParam(game.width, game.height) + gameParam := game.gameParam() err = websocket.JSON.Send(ws, gameParam) if err != nil { log.Printf("%s %s game param parse error", gid.Id, player_id)