Skip to content

Commit

Permalink
Add option to play again from game over view
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben9922 committed Apr 10, 2023
1 parent 8a1d76a commit 8e55a64
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
case GameOverView:
switch msg.(type) {
switch msg := msg.(type) {
case tea.KeyMsg:
return m, tea.Quit
switch msg.String() {
case "enter":
return initialModel(), nil
default:
return m, tea.Quit
}
}
}

Expand Down Expand Up @@ -449,7 +454,7 @@ func (m model) View() string {
"",
lipgloss.NewStyle().
Foreground(lipgloss.Color("241")).
Render("any key: quit"),
Render("enter: play again • any other key: quit"),
}
} else {
infoText = make([]string, 0, 10)
Expand Down

0 comments on commit 8e55a64

Please sign in to comment.