Exemplo n.º 1
0
        public static async Task <WheelOutcome> GetLastOutcome(UserSetting.Outcome type, long userId, bool?isUserReport = null, DiscordContext context = null)
        {
            var dispose = context == null;

            if (context == null)
            {
#pragma warning disable IDE0068 // Use recommended dispose pattern
                context = new DiscordContext();
#pragma warning restore IDE0068 // Use recommended dispose pattern
            }

            WheelOutcome outcome;

            if (isUserReport != null)
            {
                outcome = await context.WheelOutcome.OrderByDescending(outcome => outcome.Time)
                          .FirstOrDefaultAsync(outcome => outcome.UserId == userId &&
                                               outcome.IsUserReport == (isUserReport.Value == false ? 0 : 1) &&
                                               type.HasFlag((UserSetting.Outcome)outcome.Type));
            }
            else
            {
                outcome = await context.WheelOutcome.OrderByDescending(outcome => outcome.Time)
                          .FirstOrDefaultAsync(outcome => outcome.UserId == userId &&
                                               type.HasFlag((UserSetting.Outcome)outcome.Type));
            }

            if (dispose)
            {
                context.Dispose();
            }

            return(outcome);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WheelOutcome"/> class.
 /// </summary>
 /// <param name="outcome">The outcome.</param>
 /// <param name="settings">The settings.</param>
 protected WheelOutcome(UserSetting.Outcome outcome, Dictionary <UserSetting.SettingID, UserSetting> settings, List <WheelUserItem> items, IServiceProvider services)
 {
     Outcome   = outcome;
     _settings = settings;
     _services = services;
     _items    = items;
 }
Exemplo n.º 3
0
 public Bondage(UserSetting.Outcome outcome,
                Dictionary <UserSetting.SettingID, UserSetting> settings,
                List <WheelUserItem> items,
                IServiceProvider services)
     : base(outcome, settings, items, services)
 {
 }
Exemplo n.º 4
0
        private async Task CheckUserHasOrgasm(CommandContext ctx, UserSetting.Outcome outcome)
        {
            if (outcome == UserSetting.Outcome.O****m || outcome == UserSetting.Outcome.Ruin)
            {
                var m = await ctx.Client.GetInteractivity().WaitForMessageAsync(
                    x => x.Channel.Id == ctx.Channel.Id && x.Author.Id == ctx.Member.Id &&
                    x.Content.Contains(@"//ruin") || x.Content.Contains(@"//ruined") || x.Content.Contains(@"//cum") || x.Content.Contains(@"//came"),
                    TimeSpan.FromSeconds(120));

                if (m.TimedOut)
                {
                    string text = outcome == UserSetting.Outcome.Ruin ? "ruin it like a good boy" : "cum in the end";

                    var builder = new DiscordEmbedBuilder()
                    {
                        Title       = $"Did you {text}?",
                        Description = $"{ctx.Message.Author.Mention} You didn't tell me, if you properly did {text} :(" + Environment.NewLine
                                      + "Please use either ``//ruined`` or ``//came`` depending on what you did"
                    };

                    await ctx.RespondAsync(embed : builder.Build());
                }
            }
        }
Exemplo n.º 5
0
        private async Task <UserSetting.Outcome> CheckDenial(CommandContext ctx, Users user, UserSetting.Outcome outcome)
        {
            if (user.DenialTime != null && user.DenialTime > DateTime.Now)
            {
                if (outcome.HasFlag(UserSetting.Outcome.O****m) ||
                    outcome.HasFlag(UserSetting.Outcome.Ruin))
                {
                    await ctx.RespondAsync(
                        "Haha, I would\'ve let you cum this time, but since you\'re still denied, "
                        + $"that won't happen {DiscordEmoji.FromName(ctx.Client, Config.Emojis.Blush)}.\n" +
                        "As a punishment, you\'re gonna do your Task anyways though:");
                }
                else
                {
                    await ctx.RespondAsync(
                        "Well, i told you, that you\'d be denied now.\n"
                        + "You still want to do something? Hmm... let's see...");
                }

                outcome = UserSetting.Outcome.Denial | UserSetting.Outcome.Edge;
            }

            return(outcome);
        }
Exemplo n.º 6
0
        private async Task <WheelOutcome> GetWheelOutcome(DiscordContext context, Users user, UserSetting.Outcome outcome)
        {
            WheelOutcome wheelOutcome = null;
            var          userItems    = await WheelItemExtension.GetUserItemsAsync(user.UserId, context);

            while (wheelOutcome == null)
            {
                try
                {
                    wheelOutcomes = ReflectiveEnumerator.GetEnumerableOfType <WheelOutcome>(outcome, UserSetting.GetAllSettings(user.UserId, context).ToDictionary(setting => (UserSetting.SettingID)setting.SettingId), userItems, _services)
                                    .ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                foreach (var wheeloutcome in wheelOutcomes)
                {
                    await wheeloutcome.BuildAsync();
                }

                wheelOutcomes = wheelOutcomes.Where(e => !e.Outcome.HasFlag(UserSetting.Outcome.NotSet)).ToList();

                if (wheelOutcomes.Count < 1)
                {
                    continue;
                }

                // Choose an outcome by summing up the chance values of all possible outcomes and
                // then generating a random number inside those.
                var combinedChance = 0;

                foreach (WheelOutcome currentOutcome in wheelOutcomes)
                {
                    combinedChance += currentOutcome.Chance;
                }

                var chance    = 0;
                var minChance = Helpers.RandomGenerator.RandomInt(0, combinedChance);

                foreach (WheelOutcome currentOutcome in wheelOutcomes)
                {
                    chance += currentOutcome.Chance;
                    if (minChance < chance)
                    {
                        wheelOutcome = currentOutcome;
                        break;
                    }
                }
            }

            return(wheelOutcome);
        }