Add progress counter; fix duplicate matches

master
joop 2 years ago
parent fff66e2170
commit d5b4d3bb6d

@ -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())

Loading…
Cancel
Save