Ejemplo n.º 1
0
 public static string ConditionHTML(Condition c)
 {
     if (c != null)
     {
         if (c.Spell != null)
         {
             return(SpellHtmlCreator.CreateHtml(c.Spell));
         }
         else if (c.Affliction != null)
         {
             return(GenericHtmlCreator.CreateHtml(c.Affliction.Name, c.Affliction.Text));
         }
         else
         {
             return(GenericHtmlCreator.CreateHtml(c.Name, c.Text));
         }
     }
     return("");
 }
Ejemplo n.º 2
0
 protected override string ItemHtml(Spell item)
 {
     return(SpellHtmlCreator.CreateHtml(item));
 }
Ejemplo n.º 3
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));
        }