30 lines
504 B
Go
30 lines
504 B
Go
package application
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"sirlab.de/go/knowyt/game"
|
|
"sirlab.de/go/knowyt/quote"
|
|
)
|
|
|
|
func (app Application) loadQuotes(gm *game.Game, dirName string) error {
|
|
quoteDirName := path.Join(dirName, "quotes")
|
|
files, err := os.ReadDir(quoteDirName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, file := range files {
|
|
fileName := path.Join(quoteDirName, file.Name())
|
|
|
|
quote, err := quote.NewQuoteFromFile(fileName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
gm.AddQuote(quote)
|
|
}
|
|
|
|
return nil
|
|
}
|