30 lines
500 B
Go
30 lines
500 B
Go
|
package application
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"path"
|
||
|
"sirlab.de/go/knyt/game"
|
||
|
"sirlab.de/go/knyt/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
|
||
|
}
|