예제 #1
0
        private async Task CreatureReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            var CreatureHelperEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureHelper) ?? false);

            if (CreatureHelperEmbed != null)
            {
                CreatureEnvironment environment = StarforgedUtilites.CreatureEnvironmentFromEmote(reaction.Emote.Name);
                if (reaction.Emote.IsSameAs(randomEmoji))
                {
                    string lookupValue = Services.GetRequiredService <OracleService>().RandomRow("Creature Environment").Description;
                    environment = StarforgedUtilites.GetAnyEnvironment(lookupValue);
                }
                if (environment == CreatureEnvironment.None)
                {
                    return;
                }

                var newCreature = Creature.GenerateNewCreature(Services, channel.Id, environment);
                Task.WaitAll(message.RemoveAllReactionsAsync());

                await message.ModifyAsync(msg =>
                {
                    msg.Content = string.Empty;
                    msg.Embed   = newCreature.GetEmbedBuilder().Build();
                }).ConfigureAwait(false);

                await Task.Run(async() =>
                {
                    if (message.Reactions.Count > 0)
                    {
                        await Task.Delay(1500); //wait just in case we are still adding more reactions. Impatient users deserve to wait!!!
                        await message.RemoveAllReactionsAsync();
                    }

                    await message.AddReactionAsync(revealAspectEmoji).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return;
            }

            var creatureEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureTitle) ?? false);

            if (creatureEmbed == null)
            {
                return;
            }

            var creature = Creature.FromEmbed(creatureEmbed, Services, channel.Id);

            if (reaction.Emote.IsSameAs(revealAspectEmoji))
            {
                creature.AddRandomAspect();
            }

            await message.ModifyAsync(msg => msg.Embed = creature.GetEmbedBuilder().Build()).ConfigureAwait(false);

            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            return;
        }
예제 #2
0
        public async Task CreaturePost([Remainder] string CreatureCommand = "")
        {
            CreatureEnvironment environment = StarforgedUtilites.GetAnyEnvironment(CreatureCommand);

            if (environment == CreatureEnvironment.None)
            {
                EmbedBuilder builder = new EmbedBuilder()
                                       .WithTitle(CreatureResources.CreatureHelper)
                                       .WithDescription(CreatureResources.PickCreatureEnvironmentMessage);

                var msg = await ReplyAsync(embed : builder.Build());

                _ = Task.Run(async() =>
                {
                    await msg.AddReactionAsync(oneEmoji);
                    await msg.AddReactionAsync(twoEmoji);
                    await msg.AddReactionAsync(threeEmoji);
                    await msg.AddReactionAsync(fourEmoji);
                    await msg.AddReactionAsync(fiveEmoji);
                    await msg.AddReactionAsync(randomEmoji);
                }).ConfigureAwait(false);

                return;
            }

            var creature = Creature.GenerateCreature(Services, Context.Channel.Id, environment);

            var message = await ReplyAsync("", false, creature.GetEmbedBuilder().Build());

            await message.AddReactionAsync(revealAspectEmoji);
        }
예제 #3
0
        private async Task CreatureReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user)
        {
            var CreatureHelperEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureHelper) ?? false);

            if (CreatureHelperEmbed != null)
            {
                CreatureEnvironment environment = StarforgedUtilites.CreatureEnvironmentFromEmote(reaction.Emote.Name);
                if (reaction.Emote.Name == randomEmoji.Name)
                {
                    string lookupValue = Services.GetRequiredService <OracleService>().RandomRow("Creature Environment").Description;
                    environment = StarforgedUtilites.GetAnyEnvironment(lookupValue);
                }
                if (environment == CreatureEnvironment.None)
                {
                    return;
                }

                var newCreature = Creature.GenerateCreature(Services, channel.Id, environment);
                Task.WaitAll(message.RemoveAllReactionsAsync());

                await message.ModifyAsync(msg =>
                {
                    msg.Content = string.Empty;
                    msg.Embed   = newCreature.GetEmbedBuilder().Build();
                }).ConfigureAwait(false);

                await message.AddReactionAsync(revealAspectEmoji).ConfigureAwait(false);

                return;
            }

            var creatureEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureTitle) ?? false);

            if (creatureEmbed == null)
            {
                return;
            }

            var creature = Creature.FromEmbed(creatureEmbed, Services, channel.Id);

            if (reaction.Emote.Name == revealAspectEmoji.Name)
            {
                creature.RevealedAspectsToShow++;
            }

            await message.ModifyAsync(msg => msg.Embed = creature.GetEmbedBuilder().Build()).ConfigureAwait(false);

            await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false);

            return;
        }
예제 #4
0
        public static Creature GenerateNewCreature(IServiceProvider serviceProvider, ulong ChannelId, CreatureEnvironment environment)
        {
            var           creature = new Creature(serviceProvider, ChannelId);
            OracleService oracles  = serviceProvider.GetRequiredService <OracleService>();
            Random        rnd      = BotRandom.Instance;

            if (environment == CreatureEnvironment.None)
            {
                Enum.TryParse(oracles.RandomRow("Creature Environment", GameName.Starforged, rnd).Description, out environment);
            }

            creature.BasicForm           = oracles.RandomOracleResult($"Basic Form {environment}", serviceProvider, GameName.Starforged, rnd);
            creature.Environment         = environment;
            creature.EncounteredBehavior = oracles.RandomOracleResult("Creature Behavior", serviceProvider, GameName.Starforged, rnd);

            int firstLookCount = rnd.Next(2, 4); //random.Next doesn't include the max value

            for (int i = 0; i < firstLookCount; i++)
            {
                creature.FirstLook.AddRandomOracleRow("Creature First Look", GameName.Starforged, serviceProvider, ChannelId, rnd);
            }

            creature.Scale = oracles.RandomOracleResult($"Creature Scale", serviceProvider, GameName.Starforged, rnd);

            return(creature);
        }