Skip to content

Commit

Permalink
show correct answer
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkbing committed May 16, 2024
1 parent 8a4878e commit 520687d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.currentWord = newWord(constants.Both)

case "enter":
if m.textInput.Value() == toRomaji(m.currentWord) {
correctAns := toRomaji(m.currentWord)
ans := strings.ToLower(m.textInput.Value())
if ans == correctAns {
m.status = "🎉 Correct!"
m.points++
m.textInput.Reset()
m.currentWord = newWord(m.kanaType)
} else {
m.status = "😭 Incorrect"
m.status = fmt.Sprintf("😭 Incorrect. The answer is %s", correctAns)
}
m.textInput.Reset()
m.currentWord = newWord(m.kanaType)

default:
m.textInput, cmd = m.textInput.Update(msg)
Expand Down

0 comments on commit 520687d

Please sign in to comment.