package game func (gm *Game) SetGameState(stateJson *GameStateJson) { for id, score := range stateJson.Scores { gm.setScore(id, score) } for _, id := range stateJson.QuotesPlayed { if quote, err := gm.getQuoteById(id); err != nil { continue } else { quote.SetIsPlayed() } } } func (gm *Game) setScore(id string, score int) { gm.mu.Lock() defer gm.mu.Unlock() pi := gm.players[id] if pi.id == id { pi.score = score gm.players[id] = pi } }