Пример #1
0
func ShowCharacter(res http.ResponseWriter, req *http.Request, base *BaseController) {
	logged_bool := CheckIfLogged(base)
	name, err := url.QueryUnescape(mux.Vars(req)["name"])
	if err != nil {
		http.Error(res, "Error getting character name", 500)
		return
	}
	if !models.CheckCharacterName(name) {
		http.Redirect(res, req, "/", 301)
		return
	}
	character_info := models.GetCharacterByName(name)
	character_list, err := models.GetAccountCharacters(character_info.Account_id)
	if err != nil {
		http.Error(res, "Error getting character list", 500)
		return
	}
	character_deaths, err := models.GetCharacterDeaths(name)
	if err != nil {
		http.Error(res, "Error getting character deaths", 500)
		return
	}
	views.Parser.ExecuteTemplate(res, "character_view.html", &CharacterviewResponse{
		"character_view",
		logged_bool,
		character_info,
		character_list,
		character_deaths,
	})
}
Пример #2
0
func (c *Module) characterDeaths(L *lua.LState) int {
	name := L.ToString(1)
	deaths, err := models.GetCharacterDeaths(name)
	if err != nil {
		L.Push(lua.LString(err.Error()))
		L.Push(lua.LNil)
		return 2
	}
	deathList := &lua.LTable{}
	for _, val := range deaths {
		t := general.ParseStruct(val)
		deathList.Append(t)
	}
	L.Push(lua.LBool(true))
	L.Push(deathList)
	return 2
}