Exemple #1
0
 protected override string ItemHtml(Feat item)
 {
     return(FeatHtmlCreator.CreateHtml(item));
 }
Exemple #2
0
        private Task ShowDatabasePage(IHttpContext context, string [] param)
        {
            if (!param.TryGetIndex(0, out var type))
            {
                return(ShowErrorPage(context, 404, "Not found"));
            }

            var  queryData = context.GetRequestQueryData();
            bool hasId     = queryData.TryGetInt("id", out int id);
            bool custom    = queryData.GetBool("custom");

            string text = "";

            if (!hasId && (new string [] { "monster", "spell", "feat", "magicitem" }).Contains(type))
            {
                return(ShowErrorPage(context, 404, "Not found"));
            }


            switch (type)
            {
            case "monster":
                if (!Monster.TryByID(custom, id, out Monster m))
                {
                    return(ShowErrorPage(context, 404, "Not found"));
                }

                text = MonsterHtmlCreator.CreateHtml(monster: m, completePage: true, css: "WebStyles", addDescription: true);
                break;

            case "spell":
                if (!Spell.TryByID(custom, id, out Spell s))
                {
                    return(ShowErrorPage(context, 404, "Not found"));
                }

                text = SpellHtmlCreator.CreateHtml(spell: s, completepage: true, css: "WebStyles");
                break;

            case "feat":
                if (!Feat.TryByID(custom, id, out Feat f))
                {
                    return(ShowErrorPage(context, 404, "Not found"));
                }

                text = FeatHtmlCreator.CreateHtml(feat: f, completepage: true, css: "WebStyles");
                break;

            case "magicitem":
                if (!MagicItem.TryByID(custom, id, out MagicItem mi))
                {
                    return(ShowErrorPage(context, 404, "Not found"));
                }

                text = MagicItemHtmlCreator.CreateHtml(item: mi, completepage: true, css: "WebStyles");
                break;

            default:
                return(ShowErrorPage(context, 404, "Not found"));
            }



            context.Response.StatusCode = 200;
            return(context.SendStringAsync(text, "text/html", Encoding.UTF8));
        }