示例#1
0
        public static DelveService Load(string[] themeJsonFiles, string[] domainJsonFiles)
        {
            var delveService = new DelveService();

            foreach (var file in themeJsonFiles)
            {
                string json = File.ReadAllText(file);
                delveService.Themes.AddRange(JsonConvert.DeserializeObject <List <Theme> >(json));
            }
            foreach (var file in domainJsonFiles)
            {
                string json = File.ReadAllText(file);
                delveService.Domains.AddRange(JsonConvert.DeserializeObject <List <Domain> >(json));
            }

            return(delveService);
        }
示例#2
0
        internal DelveInfo FromMessage(DelveService delveService, IUserMessage message)
        {
            var embed = message.Embeds.First();

            base.PopulateFromMessage(message);

            if (!Enum.TryParse(embed.Fields.FirstOrDefault(f => f.Name == DifficultyFieldTitle).Value, out ChallengeRank challengeRank))
            {
                throw new ArgumentException("Unknown delve post format, unable to parse difficulty");
            }

            Rank = challengeRank;

            if (embed.Footer.HasValue)
            {
                Ticks = (Int32.TryParse(embed.Footer.Value.Text.Replace(ProgressResources.Ticks, "").Replace(":", ""), out int temp)) ? temp : 0;
            }
            Description   = embed.Description;
            SiteObjective = embed.Description;
            if (!Utilities.UndoFormatString(embed.Title, DelveResources.CardSiteNameFormat, out string[] titleValues))
示例#3
0
        public static DelveInfo FromInput(DelveService delveService, OracleService oracles, string themeInput, string domainInput, string siteNameInput, string siteObjective, string siteRankInput)
        {
            var delveInfo     = new DelveInfo();
            var themeItems    = themeInput.Split(',');
            var domainItems   = domainInput.Split(',');
            var randomAliases = DelveResources.RandomAliases.Split(',').ToList();
            int randomThemes  = 0;
            int randomDomains = 0;

            delveInfo.SiteObjective = siteObjective;

            ChallengeRankHelper.TryParse(siteRankInput, out ChallengeRank cr);
            if (cr == ChallengeRank.None && int.TryParse(siteRankInput, out int rankNumber))
            {
                if (rankNumber == 1)
                {
                    cr = ChallengeRank.Troublesome;
                }
                if (rankNumber == 2)
                {
                    cr = ChallengeRank.Dangerous;
                }
                if (rankNumber == 3)
                {
                    cr = ChallengeRank.Formidable;
                }
                if (rankNumber == 4)
                {
                    cr = ChallengeRank.Extreme;
                }
                if (rankNumber == 5)
                {
                    cr = ChallengeRank.Epic;
                }
            }
            delveInfo.Rank = cr;

            for (int i = 0; i < themeItems.Length; i++)
            {
                themeItems[i] = themeItems[i].Trim();
                if (randomAliases.Any(alias => alias.Equals(themeItems[i], StringComparison.OrdinalIgnoreCase)))
                {
                    randomThemes++;
                    continue;
                }

                var matchingTheme = delveService.Themes.Find(t => t.DelveSiteTheme.Equals(themeItems[i], StringComparison.OrdinalIgnoreCase));
                if (matchingTheme != null)
                {
                    delveInfo.Themes.Add(matchingTheme);
                    continue;
                }

                if (int.TryParse(themeItems[i], out int themeValue) && themeValue - 1 < delveService.Themes.Count)
                {
                    delveInfo.Themes.Add(delveService.Themes[themeValue - 1]);
                    continue;
                }

                throw new ArgumentException(String.Format(DelveResources.UnknownThemeError, themeItems[i]));
            }

            for (int i = 0; i < domainItems.Length; i++)
            {
                domainItems[i] = domainItems[i].Trim();
                if (randomAliases.Any(alias => alias.Equals(domainItems[i], StringComparison.OrdinalIgnoreCase)))
                {
                    randomDomains++;
                    continue;
                }

                var matchingDomain = delveService.Domains.Find(d => d.DelveSiteDomain.Equals(domainItems[i], StringComparison.OrdinalIgnoreCase));
                if (matchingDomain != null)
                {
                    delveInfo.Domains.Add(matchingDomain);
                    continue;
                }

                if (int.TryParse(domainItems[i], out int domainValue) && domainValue - 1 < delveService.Domains.Count)
                {
                    delveInfo.Domains.Add(delveService.Domains[domainValue - 1]);
                    continue;
                }

                throw new ArgumentException(String.Format(DelveResources.UnknownDomainError, domainItems[i]));
            }

            for (int i = 0; i < randomThemes; i++)
            {
                delveInfo.AddRandomTheme(delveService);
            }
            for (int i = 0; i < randomDomains; i++)
            {
                delveInfo.AddRandomDomain(delveService);
            }

            if (randomAliases.Any(alias => alias.Equals(siteNameInput, StringComparison.OrdinalIgnoreCase)))
            {
                var roller = new OracleRoller(oracles, GameName.Ironsworn);
                roller.BuildRollResults("Site Name Format");
                siteNameInput = roller.RollResultList.First().Result.Description;
                string place = roller.BuildRollResults($"Site Name Place {delveInfo.Domains.First().DelveSiteDomain}").RollResultList.First().Result.Description;
                siteNameInput = siteNameInput.Replace("{Place}", place);
            }
            delveInfo.SiteName = siteNameInput;

            return(delveInfo);
        }
示例#4
0
 public DelveInfoBuilder(DelveService delveService, OracleService oracles)
 {
     DelveService = delveService;
     Oracles      = oracles;
 }