Compare commits

...

1 Commits
v0.2.0 ... main

Author SHA1 Message Date
c8d4b9ef81 Add reset for global stats and fix wpm for stats 2025-02-17 13:48:02 +02:00
2 changed files with 9 additions and 1 deletions

View File

@ -24,7 +24,7 @@ func finish(start time.Time, stat *db.Stat, finished bool) {
stat.Words = globalStat.Words
stat.Finished = finished
stat.CPM = float64(globalStat.Correct) / past.Minutes()
stat.WPM = float64(globalStat.Words+1) / past.Minutes()
stat.WPM = float64(globalStat.Words) / past.Minutes()
stat.TimeTaken = past.Milliseconds()
fmt.Printf("\r\n%s", colorizer.Colors.Reset())
fmt.Print(past)
@ -176,5 +176,6 @@ outer:
log.Printf("ERROR: dbc.Create: %v", err)
}
}
globalStat.Reset()
}
}

View File

@ -8,3 +8,10 @@ type Stat struct {
}
var globalStat Stat
func (s *Stat) Reset() {
s.Skipped = 0
s.Correct = 0
s.False = 0
s.Words = 0
}