2021-10-15 21:07:41 +00:00
|
|
|
package game
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-10-16 18:14:58 +00:00
|
|
|
"sirlab.de/go/knyt/quote"
|
2021-10-15 21:07:41 +00:00
|
|
|
)
|
|
|
|
|
2021-10-16 18:14:58 +00:00
|
|
|
func (gm *Game) CreateQuote(fileName, usrId, quoteId, quoteText string) error {
|
|
|
|
qu := quote.NewQuote(quoteId, usrId, quoteText)
|
2021-10-16 19:35:31 +00:00
|
|
|
gm.AddQuote(qu)
|
2021-10-16 18:14:58 +00:00
|
|
|
return qu.Save(fileName)
|
|
|
|
}
|
|
|
|
|
2021-10-16 14:57:28 +00:00
|
|
|
func (gm *Game) SaveQuote(fileName, usrId, quoteId, quoteText string) error {
|
2021-10-16 18:14:58 +00:00
|
|
|
qu, err := gm.getQuoteById(quoteId)
|
2021-10-15 21:07:41 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-10-16 18:14:58 +00:00
|
|
|
if qu.GetSourceId() != usrId {
|
2021-10-15 21:07:41 +00:00
|
|
|
return fmt.Errorf("usrId does not match quote source id")
|
|
|
|
}
|
|
|
|
|
2021-10-16 18:14:58 +00:00
|
|
|
qu.SetQuote(quoteText)
|
2021-10-15 21:07:41 +00:00
|
|
|
|
2021-10-16 18:14:58 +00:00
|
|
|
return qu.Save(fileName)
|
2021-10-15 21:07:41 +00:00
|
|
|
}
|