func (g *Game) handleGameFinish(ctx context.Context, m message.Message, send messageSender) error {
	p := g.players[m.PlayerName]
	switch {
	case g.status != game.InProgress:
		return gameWarningNotInProgress
	case len(g.unusedTiles) != 0:
		return gameWarning("snag first")
	}
	usedWords, boardErr := g.checkPlayerBoard(m.PlayerName, true)
	if boardErr != nil {
		return boardErr
	}
	g.status = game.Finished
	info := fmt.Sprintf(
		"WINNER! - %v won, creating %v words, getting %v points.  Other players each get 1 point.  View other player's boards on the 'Final Boards' tab,",
		m.PlayerName,
		len(usedWords),
		p.WinPoints,
	)
	err := g.updateUserPoints(ctx, m.PlayerName)
	if err != nil {
		g.log.Printf("updating user points: %v", err)
		info = err.Error()
	}
	finalBoards := g.playerFinalBoards()
	for n := range g.players {
		m := message.Message{
			Type:       message.ChangeGameStatus,
			PlayerName: n,
			Info:       info,
			Game: &game.Info{
				Status:      game.Finished,
				FinalBoards: finalBoards,
			},
		}
		send(m)
	}
	return nil
}
// handleGameStart tries to finish the game for the player sending the message by checking to see if the player wins.
// If the player has won, game cleanup logic is triggered.
handleGameStart tries to finish the game for the player sending the message by checking to see if the player wins.
If the player has won, game cleanup logic is triggered.
// handleGameStart tries to finish the game for the player sending the message by checking to see if the player wins . // If the player has won game cleanup logic is triggered .
func (g *Game) handleGameFinish(ctx context.Context, m message.Message, send messageSender) error {
	p := g.players[m.PlayerName]
	switch {
	case g.status != game.InProgress:
		return gameWarningNotInProgress
	case len(g.unusedTiles) != 0:
		return gameWarning("snag first")
	}
	usedWords, boardErr := g.checkPlayerBoard(m.PlayerName, true)
	if boardErr != nil {
		return boardErr
	}
	g.status = game.Finished
	info := fmt.Sprintf(
		"WINNER! - %v won, creating %v words, getting %v points.  Other players each get 1 point.  View other player's boards on the 'Final Boards' tab,",
		m.PlayerName,
		len(usedWords),
		p.WinPoints,
	)
	err := g.updateUserPoints(ctx, m.PlayerName)
	if err != nil {
		g.log.Printf("updating user points: %v", err)
		info = err.Error()
	}
	finalBoards := g.playerFinalBoards()
	for n := range g.players {
		m := message.Message{
			Type:       message.ChangeGameStatus,
			PlayerName: n,
			Info:       info,
			Game: &game.Info{
				Status:      game.Finished,
				FinalBoards: finalBoards,
			},
		}
		send(m)
	}
	return nil
}
func ( g * Game ) handleGameFinish ( ctx context . Context , m message . Message , send messageSender ) error { p := g . players [ m . PlayerName ] switch { case g . status != game . InProgress : return gameWarningNotInProgress case len ( g . unusedTiles ) != 0 : return gameWarning ( " " ) } usedWords , boardErr := g . checkPlayerBoard ( m . PlayerName , true ) if boardErr != nil { return boardErr } g . status = game . Finished info := fmt . Sprintf ( " " , m . PlayerName , len ( usedWords ) , p . WinPoints , ) err := g . updateUserPoints ( ctx , m . PlayerName ) if err != nil { g . log . Printf ( " " , err ) info = err . Error ( ) } finalBoards := g . playerFinalBoards ( ) for n := range g . players { m := message . Message { Type : message . ChangeGameStatus , PlayerName : n , Info : info , Game : & game . Info { Status : game . Finished , FinalBoards : finalBoards , } , } send ( m ) } return nil }
handleGameStart tries to finish the game for the player sending the message by checking to see if the player wins.
handleGameStart tries to finish the game for the player sending the message by checking to see if the player wins .