diff options
author | joop <Joop Kiefte> | 2022-04-03 20:25:53 +0100 |
---|---|---|
committer | joop <Joop Kiefte> | 2022-04-03 20:25:53 +0100 |
commit | d5b4d3bb6da01428eef23ac1de23a58c5b652d4d (patch) | |
tree | 603ffb2f6907d29856e98f28f6a3ce8f35292487 | |
parent | fff66e2170e34ab0a3bd5076b371247f3f37711c (diff) |
Add progress counter; fix duplicate matches
-rw-r--r-- | main.go | 22 |
1 files changed, 7 insertions, 15 deletions
@@ -337,26 +337,18 @@ func main() { // Ask which language to complete languages := AskLanguages("Which languages do you want to complete? ") prayers = ReadPrayers(languages, false) - for { - // randomize the order of the prayers - for i := len(prayers) - 1; i > 0; i-- { - j := rand.Intn(i + 1) - prayers[i], prayers[j] = prayers[j], prayers[i] - } - // pick the first prayer from the resulting list that - // doesn't have a code in CodeList. - var prayer Prayer + // randomize the order of the prayers + for i := len(prayers) - 1; i > 0; i-- { + j := rand.Intn(i + 1) + prayers[i], prayers[j] = prayers[j], prayers[i] + } + for i, prayer := range prayers { var code string - for _, p := range prayers { - if CodeList[p.Id] == "" { - prayer = p - break - } - } for code == "" { // Clear the screen fmt.Print("\033[H\033[2J") // Present the text, id and author of the prayer + fmt.Println("Prayer " + strconv.Itoa(i+1) + " of " + strconv.Itoa(len(prayers))) fmt.Println(prayer.Text) fmt.Println("ID:", prayer.Id) fmt.Println("Author:", prayer.Author()) |