示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hall of Beorn Card Search\r\nHTML TemplateBuilder 0.0.1");

            var productRepo = new ProductRepository();
            var cardRepo    = new CardRepository(productRepo);

            statService = new StatService(cardRepo);

            const string file1 = "templates1.txt";
            const string file2 = "templates2.txt";

            foreach (var c in cardRepo.Cards())
            {
                if (string.IsNullOrEmpty(c.HtmlTemplate))
                {
                    Console.WriteLine("  Writing template1 for : " + c.Slug);
                    var text = string.Format("AddHtml(\"{0}\", \"{1}\");\r\n", c.Slug, GetTemplate(c, c.Text, c.Shadow, c.FlavorText));
                    File.AppendAllText(file1, text);
                }

                if (string.IsNullOrEmpty(c.HtmlTemplate2) && !string.IsNullOrEmpty(c.OppositeText))
                {
                    Console.WriteLine("  Writing template2 for : " + c.Slug);
                    var text = string.Format("AddHtml(\"{0}\", \"{1}\");\r\n", c.Slug, GetTemplate(c, c.OppositeText, string.Empty, c.OppositeFlavorText));
                    File.AppendAllText(file2, text);
                }
            }

            Console.WriteLine("DONE");
            Console.ReadLine();
        }
        public ActionResult Get(string name)
        {
            var result = new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            switch (name)
            {
            case "Cards":
                result.Data = "This method is no longer supported for performance reasons. Use export/PlayerCards, export/EncounterCards or export/QuestCards instead. Thanks for your support!";     //cardRepository.Cards().Where(x => x.CardSet.SetType != SetType.CUSTOM).Select(x => new SimpleCard(x)).ToList();
                break;

            case "PlayerCards":
                result.Data = cardRepository.Cards().Where(x => x.CardSet.SetType != SetType.CUSTOM && IsPlayerCard(x)).Select(y => new SimpleCard(y)).ToList();
                break;

            case "EncounterCards":
                result.Data = cardRepository.Cards().Where(x => x.CardSet.SetType != SetType.CUSTOM && IsEncounterCard(x)).Select(y => new SimpleCard(y)).ToList();
                break;

            case "QuestCards":
                result.Data = cardRepository.Cards().Where(x => x.CardSet.SetType != SetType.CUSTOM && IsQuestCard(x)).Select(y => new SimpleCard(y)).ToList();
                break;

            case "Scenarios":
                var scenarios = new List <SimpleScenario>();
                foreach (var group in scenarioService.ScenarioGroups())
                {
                    foreach (var item in group.Scenarios)
                    {
                        var scenario = new SimpleScenario()
                        {
                            Title = item.Title, Number = (uint)item.Number
                        };

                        foreach (var quest in item.QuestCards.Select(x => x.Quest))
                        {
                            scenario.QuestCards.Add(new SimpleCard(quest));
                        }

                        foreach (var card in item.ScenarioCards)
                        {
                            scenario.ScenarioCards.Add(new SimpleScenarioCard()
                            {
                                EncounterSet      = card.EncounterSet,
                                Title             = card.Title,
                                NormalQuantity    = (uint)card.NormalQuantity,
                                EasyQuantity      = (uint)card.EasyQuantity,
                                NightmareQuantity = (uint)card.NightmareQuantity
                            });
                        }

                        scenarios.Add(scenario);
                    }
                }

                result.Data = scenarios;
                break;

            case "CardSets":
                result.Data = scenarioService.CardSets().Select(x => new SimpleCardSet {
                    Name = x.Name, Cycle = x.Cycle, SetType = x.SetType.ToString()
                }).ToList();
                break;

            case "EncounterSets":
                result.Data = scenarioService.EncounterSetNames();
                break;

            default:
                if (!string.IsNullOrEmpty(name))
                {
                    result.Data = "Unknown record type: " + name;
                }
                else
                {
                    result.Data = "Undefined record type";
                }
                break;
            }

            return(result);
        }