knowyt/server/src/game/saveQuote.go

28 lines
535 B
Go

package game
import (
"fmt"
"sirlab.de/go/knowyt/quote"
)
func (gm *Game) CreateQuote(fileName, usrId, quoteId, quoteText string) error {
qu := quote.NewQuote(quoteId, usrId, quoteText)
gm.AddQuote(qu)
return qu.Save(fileName)
}
func (gm *Game) SaveQuote(fileName, usrId, quoteId, quoteText string) error {
qu, err := gm.getQuoteById(quoteId)
if err != nil {
return err
}
if qu.GetSourceId() != usrId {
return fmt.Errorf("usrId does not match quote source id")
}
qu.SetQuote(quoteText)
return qu.Save(fileName)
}