package game import () func (gm *Game) GetGameInfo() *GameInfoJson { gameInfo := gm.initGameInfoJson() for i, _ := range gameInfo.Players { gameInfo.Players[i].Quotes = gm.getQuotesInfoByUserId(gameInfo.Players[i].Id) } return gameInfo } func (gm *Game) initGameInfoJson() *GameInfoJson { gm.mu.Lock() defer gm.mu.Unlock() gameInfo := GameInfoJson{ Name: gm.name, Players: make([]PlayerInfoJson, 0), } for _, player := range gm.players { gameInfo.Players = append(gameInfo.Players, PlayerInfoJson{ Id: player.id, Name: player.name, Score: player.score, IsPlaying: player.isPlaying, IsIdle: player.isIdle, }) } return &gameInfo }