func deleteAI(c common.Context) { if c.Authenticated() { if ai := models.GetAIById(c, common.MustDecodeKey(c.Vars["ai_id"])); ai != nil && ai.Owner == c.User.Email { ai.Delete(c) } } }
func getAIErrors(c common.Context) { if c.Authenticated() { if ai := models.GetAIById(c, common.MustDecodeKey(c.Vars["ai_id"])); ai != nil && ai.Owner == c.User.Email { c.RenderJSON(ai.GetErrors(c)) } } }
func createGame(c common.Context) { if c.Authenticated() { var game models.Game aiCommon.MustDecodeJSON(c.Req.Body, &game) if len(game.Players) > 0 { c.RenderJSON(game.Save(c)) } } }
func createAI(c common.Context) { if c.Authenticated() { var ai models.AI aiCommon.MustDecodeJSON(c.Req.Body, &ai) if ai.Name != "" && ai.URL != "" { ai.Owner = c.User.Email ai.Id = nil c.RenderJSON(ai.Save(c)) } } }