package game import ( "fmt" "time" ) func (gm *Game) revealShowCount() { if !gm.allPlayersHaveSelectedAQuote() { fmt.Println("not all players have selected a quote yet") return } if err := gm.changeGamePhase(STATE_PLAY, PHASE_SELECT_QUOTE, PHASE_REVEAL_START); err != nil { fmt.Println(err) return } gm.round.revelation = Revelation{ votes: make(map[string][]string, 0), } gm.notifyClients() time.Sleep(1 * time.Second) if err := gm.changeGamePhase(STATE_PLAY, PHASE_REVEAL_START, PHASE_REVEAL_SHOW_COUNT); err != nil { fmt.Println(err) return } for key, val := range gm.round.selections { gm.round.revelation.votes[val] = append(gm.round.revelation.votes[val], key) } gm.notifyClients() } func (gm *Game) allPlayersHaveSelectedAQuote() bool { gm.mu.Lock() defer gm.mu.Unlock() for id, playerInfo := range gm.players { if !playerInfo.isPlaying || playerInfo.isIdle { continue } if len(gm.round.selections[id]) == 0 { return false } } return true }