Ejemplo n.º 1
0
        private async Task ReactionFeatureEvent(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            if (!IsDelveMessage(message))
            {
                return;
            }
            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            var delve = new DelveInfo().FromMessage(DelveService, message);

            await channel.SendMessageAsync(String.Format(DelveResources.RevealFeatureRoll, delve.SiteName), false, delve.RevealFeatureRoller().GetEmbed()).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
        private async Task ReactionIncreaseEvent(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            if (!IsDelveMessage(message))
            {
                return;
            }
            DelveInfo delve = new DelveInfo().FromMessage(DelveService, message);

            delve.Ticks += delve.TicksPerProgress;
            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            await message.ModifyAsync(msg => msg.Embed = delve.BuildEmbed() as Embed);
        }
Ejemplo n.º 3
0
        private async Task ReactionLocateObjectiveEvent(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            if (!IsDelveMessage(message))
            {
                return;
            }
            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            DelveInfo delve = new DelveInfo().FromMessage(DelveService, message);
            var       roll  = new ActionRoll(0, delve.ActionDie, String.Format(DelveResources.LocateObjectiveRoll, delve.SiteName));
            await channel.SendMessageAsync(roll.ToString()).ConfigureAwait(false);

            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);
        }
Ejemplo n.º 4
0
        public DelveInfo Build()
        {
            var delveInfo = new DelveInfo();

            delveInfo.SiteObjective = Objective;
            delveInfo.Description   = Objective;
            delveInfo.Rank          = Rank;
            delveInfo.Domains       = Domains;
            delveInfo.Themes        = Themes;

            //Just to be safe if things aren't added in the right order parse the name again
            if (randomAliases.Any(alias => alias.Equals(Name, StringComparison.OrdinalIgnoreCase)))
            {
                var roller = new OracleRoller(Oracles, GameName.Ironsworn);
                roller.BuildRollResults("Site Name Format");
                Name = roller.RollResultList.First().Result.Description;
                string place = roller.BuildRollResults($"Site Name Place {delveInfo.Domains.First().DelveSiteDomain}").RollResultList.First().Result.Description;
                Name = Name.Replace("{Place}", place);
            }
            delveInfo.SiteName = Name;

            return(delveInfo);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public async Task DelveSite()
        {
            var    delveService     = Services.GetRequiredService <DelveService>();
            string themeHelperText  = string.Empty;
            string domainHelperText = string.Empty;

            var builder = new DelveInfoBuilder(delveService, OracleService);

            for (int i = 0; i < delveService.Themes.Count; i++)
            {
                themeHelperText += String.Format(DelveResources.HelperTextFormat, i + 1, delveService.Themes[i].DelveSiteTheme) + "\n";
            }
            themeHelperText += "\n" + String.Format(DelveResources.HelperTextFormat, DelveResources.RandomAliases.Split(',')[0], DelveResources.RandomAliases.Split(',')[1]);

            for (int i = 0; i < delveService.Domains.Count; i++)
            {
                domainHelperText += String.Format(DelveResources.HelperTextFormat, i + 1, delveService.Domains[i].DelveSiteDomain) + "\n";
            }
            domainHelperText += "\n" + String.Format(DelveResources.HelperTextFormat, DelveResources.RandomAliases.Split(',')[0], DelveResources.RandomAliases.Split(',')[1]);

            var helperMessage = await ReplyAsync(embed : new EmbedBuilder()
                                                 .WithTitle(DelveResources.ThemeHelperTitle)
                                                 .WithDescription(themeHelperText)
                                                 .WithFooter(DelveResources.HelperFooterThemeDomain)
                                                 .Build());

            var themeResponse = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (themeResponse != null)
            {
                builder.WithThemes(themeResponse.Content);

                await themeResponse.DeleteAsync().ConfigureAwait(false);

                await helperMessage.ModifyAsync(msg => msg.Embed = new EmbedBuilder()
                                                .WithTitle(DelveResources.DomainHelperTitle)
                                                .WithDescription(domainHelperText)
                                                .AddField(DelveResources.HelperSelectionsTitle, builder)
                                                .WithFooter(DelveResources.HelperFooterThemeDomain)
                                                .Build());
            }
            else
            {
                await helperMessage.ModifyAsync(msg => msg.Embed = helperMessage.Embeds.First().ToEmbedBuilder().WithDescription(DelveResources.UserInputTimeoutError).Build());

                return;
            }

            var domainResponse = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (domainResponse != null)
            {
                builder.WithDomains(domainResponse.Content);
                await domainResponse.DeleteAsync().ConfigureAwait(false);

                await helperMessage.ModifyAsync(msg => msg.Embed = new EmbedBuilder()
                                                .WithTitle(DelveResources.HelperSiteNameTitle)
                                                .WithDescription(DelveResources.HelperSiteNameText)
                                                .AddField(DelveResources.HelperSelectionsTitle, builder)
                                                .Build());
            }
            else
            {
                await helperMessage.ModifyAsync(msg => msg.Embed = helperMessage.Embeds.First().ToEmbedBuilder().WithDescription(DelveResources.UserInputTimeoutError).Build());

                return;
            }

            var siteName = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (siteName != null)
            {
                builder.WithName(siteName.Content);
                await siteName.DeleteAsync().ConfigureAwait(false);

                await helperMessage.ModifyAsync(msg => msg.Embed = new EmbedBuilder()
                                                .WithTitle(DelveResources.HelperSiteObjectiveTitle)
                                                .WithDescription(DelveResources.HelperSiteObjectiveText)
                                                .AddField(DelveResources.HelperSelectionsTitle, builder)
                                                .Build());
            }
            else
            {
                await helperMessage.ModifyAsync(msg => msg.Embed = helperMessage.Embeds.First().ToEmbedBuilder().WithDescription(DelveResources.UserInputTimeoutError).Build());

                return;
            }

            var siteObjective = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (siteObjective != null)
            {
                builder.WithObjective(siteObjective.Content);
                await siteObjective.DeleteAsync().ConfigureAwait(false);

                await helperMessage.ModifyAsync(msg => msg.Embed = new EmbedBuilder()
                                                .WithTitle(DelveResources.HelperSiteRankTitle)
                                                .WithDescription(DelveResources.HelperSiteRankText)
                                                .AddField(DelveResources.HelperSelectionsTitle, builder)
                                                .Build());
            }
            else
            {
                await helperMessage.ModifyAsync(msg => msg.Embed = helperMessage.Embeds.First().ToEmbedBuilder().WithDescription(DelveResources.UserInputTimeoutError).Build());

                return;
            }

            var siteRank = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2));

            if (siteRank == null)
            {
                await siteRank.DeleteAsync().ConfigureAwait(false);

                await helperMessage.ModifyAsync(msg => msg.Embed = helperMessage.Embeds.First().ToEmbedBuilder().WithDescription(DelveResources.UserInputTimeoutError).Build());

                return;
            }

            builder.WithRank(siteRank.Content);
            await siteRank.DeleteAsync().ConfigureAwait(false);

            DelveInfo delve = builder.Build();
            await helperMessage.ModifyAsync(msg => { msg.Content = null; msg.Embed = delve.BuildEmbed() as Embed; });

            await helperMessage.AddReactionAsync(DecreaseEmoji);

            await helperMessage.AddReactionAsync(IncreaseEmoji);

            await helperMessage.AddReactionAsync(FullEmoji);

            await helperMessage.AddReactionAsync(FeatureEmoji);

            await helperMessage.AddReactionAsync(DangerEmoji);

            await helperMessage.AddReactionAsync(RollEmoji);
        }