Example #1
0
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)
		}
	}
}
Example #2
0
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))
		}
	}
}
Example #3
0
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))
		}
	}
}
Example #4
0
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))
		}
	}
}