knowyt/server/src/application/continueGame.go

32 lines
606 B
Go
Raw Normal View History

2021-08-30 16:21:14 +00:00
package application
import (
"fmt"
"net/http"
2022-11-06 14:41:13 +00:00
"sirlab.de/go/knowyt/log"
"sirlab.de/go/knowyt/user"
2021-08-30 16:21:14 +00:00
)
func (app *Application) ContinueGame(usr *user.User, w http.ResponseWriter, r *http.Request) {
gameRef := r.URL.Query().Get("g")
gm, err := app.GetGameById(gameRef)
if err != nil {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "game not found")
return
}
if usr.GetGameId() != gameRef || !usr.IsGamemaster() {
w.WriteHeader(http.StatusForbidden)
fmt.Fprintf(w, "forbidden")
return
}
gm.ContinueGame()
2021-09-19 21:31:24 +00:00
2021-09-26 21:36:47 +00:00
if err := app.saveGameState(gm); err != nil {
2022-11-06 14:41:13 +00:00
log.ErrorLog(err)
2021-09-19 21:31:24 +00:00
}
2021-08-30 16:21:14 +00:00
}