From d5b4d3bb6da01428eef23ac1de23a58c5b652d4d Mon Sep 17 00:00:00 2001 From: joop Date: Sun, 3 Apr 2022 20:25:53 +0100 Subject: Add progress counter; fix duplicate matches --- main.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 6d0deff..f619a58 100644 --- a/main.go +++ b/main.go @@ -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()) -- cgit v1.2.3-70-g09d2