private async Task <UserSetting.Outcome> GetOutcome(CommandContext ctx, DiscordContext context) { Users user = await UserExtension.GetUser(Convert.ToInt64(ctx.Message.Author.Id), context); var wheelMode = await WheelSettingExtension.GetMode(ctx.Guild.Id, context); var wheelDifficultySetting = await UserSetting.GetSettingAsync(user.UserId, UserSetting.SettingID.WheelDifficulty, context); var difficulty = UserSettingExtensions.GetValue <UserSetting.WheelDifficultyPreference>(wheelDifficultySetting); WheelChances chances = await context.WheelChances.FindAsync((int)difficulty); var cumScore = await CalculateCumScore(context, user); var cumChance = Convert.ToInt32(cumScore * chances.O****m); if (wheelMode.HasFlag(WheelSettingExtension.WheelMode.NoCum)) { cumChance = 0; } var ruinChance = Convert.ToInt32(cumScore * chances.Ruin); if (wheelMode.HasFlag(WheelSettingExtension.WheelMode.NoRuin)) { ruinChance = 0; } var denialChance = chances.Denial; if (wheelMode.HasFlag(WheelSettingExtension.WheelMode.NoDenial)) { denialChance = 0; } var outcomeChanceValue = Helpers.RandomGenerator.RandomInt( 0, denialChance + chances.Task + chances.Edge + ruinChance + cumChance); UserSetting.Outcome outcome; if (outcomeChanceValue < denialChance) { outcome = UserSetting.Outcome.Denial; } else if (outcomeChanceValue < denialChance + chances.Edge) { outcome = UserSetting.Outcome.Edge; } else if (outcomeChanceValue < denialChance + chances.Edge + chances.Task) { outcome = UserSetting.Outcome.Task; } else if (outcomeChanceValue < denialChance + chances.Edge + chances.Task + cumChance) { outcome = UserSetting.Outcome.Ruin; } else { outcome = UserSetting.Outcome.O****m; } return(outcome); }
public async Task SpinNewWheelAsync(CommandContext ctx) { DiscordContext context = new DiscordContext(); Users user = await context.Users.FindAsync(Convert.ToInt64(ctx.Message.Author.Id)); UserSettings userSettings = await context.UserSettings.FindAsync(Convert.ToInt64(ctx.Message.Author.Id)); SabrinaSettings sabrinaSettings = await context.SabrinaSettings.FindAsync(Convert.ToInt64(ctx.Guild.Id)); if (sabrinaSettings == null) { sabrinaSettings = new SabrinaSettings { GuildId = Convert.ToInt64(ctx.Guild.Id), WheelChannel = Convert.ToInt64(ctx.Channel.Id) }; await context.SabrinaSettings.AddAsync(sabrinaSettings); await context.SaveChangesAsync(); } if (sabrinaSettings.WheelChannel == null) { sabrinaSettings.WheelChannel = Convert.ToInt64(ctx.Channel.Id); await context.SaveChangesAsync(); } if (Convert.ToInt64(ctx.Channel.Id) != sabrinaSettings.WheelChannel.Value) { DiscordChannel channel = await ctx.Client.GetChannelAsync(Convert.ToUInt64(sabrinaSettings.WheelChannel)); await ctx.RespondAsync( $"You cannot issue this command from this Channel. Please use {channel.Mention}"); return; } if (user == null) { user = new Users(); } if (userSettings == null) { userSettings = new UserSettings(); } WheelChances chances = await context.WheelChances.FindAsync(userSettings.WheelDifficulty ?? 2); if (user.LockTime != null && user.LockTime > DateTime.Now) { TimeSpan?timeUntilFree = user.LockTime - DateTime.Now; TimeSpan newTimeUntilFree = TimeSpan.FromTicks(timeUntilFree.Value.Ticks * Helpers.RandomGenerator.RandomInt(1, 4)); if (newTimeUntilFree > TimeSpan.FromDays(365)) { await ctx.RespondAsync("F**k off"); return; } if (Helpers.RandomGenerator.RandomInt(0, 4) > 0) { await ctx.RespondAsync( "Oho, it seems like I told you to stay away from spinning the wheel...\n" + $"That means you get some more extra time of no spinning {DiscordEmoji.FromName(ctx.Client, Config.Emojis.Blush)}"); user.LockTime += newTimeUntilFree; await context.SaveChangesAsync(); return; } await ctx.RespondAsync( "I believe i have told you not to spin the wheel.\n" + $"But since i'm awesome, you won't get punishment for it... Today. {DiscordEmoji.FromName(ctx.Client, Config.Emojis.Blush)}"); } var addedChance = 0; var outcomeChanceValue = Helpers.RandomGenerator.RandomInt( 0, chances.Denial + chances.Task + chances.Ruin + chances.O****m); Console.WriteLine("Chance Rolled: " + outcomeChanceValue); Console.WriteLine("Denial Chance: " + chances.Denial); Console.WriteLine("TaskChance Chance: " + chances.Task); Console.WriteLine("RuinChance Chance: " + chances.Ruin); Console.WriteLine("OrgasmChance Chance: " + chances.O****m); Console.WriteLine("addedChance Chance: " + addedChance); SlaveReportsExtension.Outcome outcome = SlaveReportsExtension.Outcome.Task; if (outcomeChanceValue < chances.Denial) { outcome = SlaveReportsExtension.Outcome.Denial; } else if (outcomeChanceValue < chances.Denial + chances.Task) { outcome = SlaveReportsExtension.Outcome.Task; } else if (outcomeChanceValue < chances.Denial + chances.Task + chances.Ruin) { outcome = SlaveReportsExtension.Outcome.Ruin; } else { outcome = SlaveReportsExtension.Outcome.O****m; } if (user.DenialTime != null && user.DenialTime > DateTime.Now) { TimeSpan?timeUntilFree = user.DenialTime - DateTime.Now; if (outcome.HasFlag(SlaveReportsExtension.Outcome.O****m) || outcome.HasFlag(SlaveReportsExtension.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? Then here you go." + $"\nAnd as a bonus, if i decide so, you'll get even more denial! {DiscordEmoji.FromName(ctx.Client, Config.Emojis.Blush)}"); } await Task.Delay(1500); outcome = SlaveReportsExtension.Outcome.Denial | SlaveReportsExtension.Outcome.Task; } WheelOutcome wheelOutcome = null; while (wheelOutcome == null) { wheelOutcomes = ReflectiveEnumerator.GetEnumerableOfType <WheelOutcome>(outcome, userSettings, context) .ToList(); wheelOutcomes = wheelOutcomes.Where(e => outcome.HasFlag(e.Outcome)).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; } } } if (user.DenialTime == null) { user.DenialTime = DateTime.Now; } if (user.LockTime == null) { user.LockTime = DateTime.Now; } if (user.DenialTime < DateTime.Now) { user.DenialTime = DateTime.Now; } if (user.LockTime < DateTime.Now) { user.LockTime = DateTime.Now; } user.DenialTime += wheelOutcome.DenialTime; user.LockTime += wheelOutcome.WheelLockedTime; await context.SaveChangesAsync(); if (wheelOutcome.Embed != null) { await ctx.RespondAsync(embed : wheelOutcome.Embed); } else { await ctx.RespondAsync(wheelOutcome.Text); } }
public async Task SpinNewWheelAsync(CommandContext ctx) { DiscordContext context = new DiscordContext(); Users user = await UserExtension.GetUser(Convert.ToInt64(ctx.Message.Author.Id), context); SabrinaSettings sabrinaSettings = await context.SabrinaSettings.FindAsync(Convert.ToInt64(ctx.Guild.Id)); if (sabrinaSettings == null) { sabrinaSettings = new SabrinaSettings { GuildId = Convert.ToInt64(ctx.Guild.Id), WheelChannel = Convert.ToInt64(ctx.Channel.Id) }; await context.SabrinaSettings.AddAsync(sabrinaSettings); await context.SaveChangesAsync(); } if (sabrinaSettings.WheelChannel == null) { sabrinaSettings.WheelChannel = Convert.ToInt64(ctx.Channel.Id); await context.SaveChangesAsync(); } if (Convert.ToInt64(ctx.Channel.Id) != sabrinaSettings.WheelChannel.Value) { DiscordChannel channel = await ctx.Client.GetChannelAsync(Convert.ToUInt64(sabrinaSettings.WheelChannel)); await ctx.RespondAsync( $"You cannot issue this command from this Channel. Please use {channel.Mention}"); return; } var wheelDifficultySetting = await UserSettingExtension.GetSettingAsync(user.UserId, UserSettingExtension.SettingID.WheelDifficulty, context); var difficulty = WheelExtension.WheelDifficultyPreference.Default; if (wheelDifficultySetting != null) { difficulty = (WheelExtension.WheelDifficultyPreference) int.Parse(wheelDifficultySetting.Value); } WheelChances chances = await context.WheelChances.FindAsync((int)difficulty); if (user.LockTime != null && user.LockTime > DateTime.Now) { TimeSpan?timeUntilFree = user.LockTime - DateTime.Now; TimeSpan newTimeUntilFree = TimeSpan.FromTicks(timeUntilFree.Value.Ticks * Helpers.RandomGenerator.RandomInt(1, 4)); if (newTimeUntilFree > TimeSpan.FromDays(365)) { await ctx.RespondAsync("F**k off"); return; } var responseText = "Oho, it seems like I told you to stay away from spinning the wheel...\n" + $"That means you get some more extra time of no spinning {DiscordEmoji.FromName(ctx.Client, Config.Emojis.Blush)}"; if (int.TryParse(user.LockReason, out int reasonInt)) { var reason = (UserSettingExtension.LockReason)reasonInt; switch (reason) { case UserSettingExtension.LockReason.Cooldown: responseText = "Oho, it seems like I told you to stay away from spinning the wheel...\n" + $"That means you get some more extra time of no spinning {DiscordEmoji.FromName(ctx.Client, Config.Emojis.Blush)}"; user.LockTime += newTimeUntilFree; break; case UserSettingExtension.LockReason.Extension: responseText = "Hey! I already told you, that you'd get a longer lock on the Wheel! You still want more? Sure!"; user.LockTime += TimeSpan.FromMinutes(1); break; case UserSettingExtension.LockReason.Task: responseText = "Haha, there's no way you were able to finish your Task so quickly. Do your Task, " + "and then I'll give you another minute to think about your Actions."; user.LockTime += TimeSpan.FromMinutes(1); break; } } user.LockReason = ((int)UserSettingExtension.LockReason.Extension).ToString(); await ctx.RespondAsync(responseText); await context.SaveChangesAsync().ConfigureAwait(false); return; } float cumScore = 1; var lastOrgasm = await WheelOutcomeExtension.GetLastOutcome(WheelExtension.Outcome.O****m, user.UserId, null, context); var lastRuin = await WheelOutcomeExtension.GetLastOutcome(WheelExtension.Outcome.Ruin, user.UserId, null, context); if (lastOrgasm != null || lastRuin != null) { DbWheelOutcome lastCum = null; if (lastOrgasm != null && lastRuin != null) { lastCum = lastOrgasm?.Time > lastRuin?.Time ? lastOrgasm : lastRuin; } else { lastCum = lastOrgasm != null ? lastOrgasm : lastRuin; } var allSinceLastCum = (await WheelOutcomeExtension.GetLastOutcomesUntil(lastCum, context)).ToList(); var denialSinceLastCum = allSinceLastCum.Where(cOutcome => cOutcome.Type == (int)WheelExtension.Outcome.Denial); var taskSinceLastCum = allSinceLastCum.Where(cOutcome => cOutcome.Type == (int)WheelExtension.Outcome.Task); var edgeSinceLastCum = allSinceLastCum.Where(cOutcome => cOutcome.Type == (int)WheelExtension.Outcome.Edge); cumScore = (denialSinceLastCum.Count() * 6 + taskSinceLastCum.Count() * 2 + edgeSinceLastCum.Count()) / 4f; cumScore = cumScore == 0 ? 1 : cumScore; } var outcomeChanceValue = Helpers.RandomGenerator.RandomInt( 0, chances.Denial + chances.Task + chances.Edge + Convert.ToInt32(cumScore * chances.Ruin) + Convert.ToInt32(cumScore * chances.O****m)); WheelExtension.Outcome outcome = WheelExtension.Outcome.Edge; if (outcomeChanceValue < chances.Denial) { outcome = WheelExtension.Outcome.Denial; } else if (outcomeChanceValue < chances.Denial + chances.Edge) { outcome = WheelExtension.Outcome.Edge; } else if (outcomeChanceValue < chances.Denial + chances.Edge + chances.Task) { outcome = WheelExtension.Outcome.Task; } else if (outcomeChanceValue < chances.Denial + chances.Edge + chances.Task + Convert.ToInt32(cumScore * chances.Ruin)) { outcome = WheelExtension.Outcome.Ruin; } else { outcome = WheelExtension.Outcome.O****m; } if (user.DenialTime != null && user.DenialTime > DateTime.Now) { TimeSpan?timeUntilFree = user.DenialTime - DateTime.Now; if (outcome.HasFlag(WheelExtension.Outcome.O****m) || outcome.HasFlag(WheelExtension.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..."); } await Task.Delay(1500); outcome = WheelExtension.Outcome.Denial | WheelExtension.Outcome.Edge; } WheelOutcome wheelOutcome = null; while (wheelOutcome == null) { try { wheelOutcomes = ReflectiveEnumerator.GetEnumerableOfType <WheelOutcome>(outcome, UserSettingExtension.GetAllSettings(user.UserId, context).ToDictionary(setting => (UserSettingExtension.SettingID)setting.SettingId), await WheelItemExtension.GetUserItemsAsync(user.UserId, context), _dependencies) .ToList(); } catch (Exception e) { Console.WriteLine(e); } foreach (var wheeloutcome in wheelOutcomes) { await wheeloutcome.BuildAsync(); } wheelOutcomes = wheelOutcomes.Where(e => !e.Outcome.HasFlag(WheelExtension.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; } } } if (wheelOutcome.Embed != null) { await ctx.RespondAsync(embed : wheelOutcome.Embed); } else { await ctx.RespondAsync(wheelOutcome.Text); } DbWheelOutcome dbOutcome = new DbWheelOutcome() { IsUserReport = 0, Time = DateTime.Now, Type = (int)outcome, UserId = user.UserId }; context.WheelOutcome.Add(dbOutcome); if (wheelOutcome.GetType() == typeof(Entities.WheelOutcomes.Content)) { ((Entities.WheelOutcomes.Content)wheelOutcome).CleanUp(context); } if (user.DenialTime == null) { user.DenialTime = DateTime.Now; } if (user.LockTime == null) { user.LockTime = DateTime.Now; } if (user.DenialTime < DateTime.Now) { user.DenialTime = DateTime.Now; } if (user.LockTime < DateTime.Now) { user.LockTime = DateTime.Now; } if (wheelOutcome.WheelLockedTime != null && wheelOutcome.WheelLockedTime > TimeSpan.Zero) { switch (outcome) { case WheelExtension.Outcome.Edge: case WheelExtension.Outcome.Task: user.LockReason = ((int)UserSettingExtension.LockReason.Task).ToString(); break; default: user.LockReason = ((int)UserSettingExtension.LockReason.Cooldown).ToString(); break; } } user.DenialTime += wheelOutcome.DenialTime; user.LockTime += wheelOutcome.WheelLockedTime; await Task.Run(async() => await context.SaveChangesAsync()); if (outcome == WheelExtension.Outcome.O****m || outcome == WheelExtension.Outcome.Ruin) { var m = await ctx.Client.GetInteractivityModule().WaitForMessageAsync( x => x.Channel.Id == ctx.Channel.Id && x.Author.Id == ctx.Member.Id && x.Content.Contains(@"//ruin") || x.Content.Contains(@"//cum") || x.Content.Contains(@"//came"), TimeSpan.FromSeconds(120)); if (m == null) { string text = outcome == WheelExtension.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()); } } }