public void All_Predictions_Provided_Within_100_Requests() { const int MaxAttempts = 100; var eightBall = new EightBall(); var answersReceived = new HashSet <string>(); var attempts = 0; while (answersReceived.Count < EightBall.Predictions.Length && attempts < MaxAttempts) { var currentAnswer = eightBall.Shake(); answersReceived.Add(currentAnswer); attempts++; } if (attempts < MaxAttempts) { Assert.Pass($"All possible answers received in {attempts} iterations."); } else { Assert.Fail($"Did not receive all possible answers within {MaxAttempts} attempts."); } }
public void Shaking_EightBall_Returns_Answer() { var eightBall = new EightBall(); var answer = eightBall.Shake(); Assert.IsInstanceOf <string>(answer); Assert.IsFalse(string.IsNullOrWhiteSpace(answer)); }
public async Task AskEightBall([Summary("question")][Remainder] string question) { EmbedBuilder builder = new EmbedBuilder(); builder.Title = "Magic 8 Ball"; builder.AddField("Question", question); builder.AddField("Answer", EightBall.GetRandomResponse()); builder.Color = EMBED_COLOR; await SendEmbed(builder.Build()); }
public Task EightBallAsync(CommandContext ctx, [RemainingText, Description("A question for the almighty ball.")] string question) { if (string.IsNullOrWhiteSpace(question)) { throw new InvalidCommandUsageException("The almighty ball requires a question."); } return(this.InformAsync(ctx, $"{ctx.User.Mention} {EightBall.GenerateAnswer(question, ctx.Channel.Users)}", ":8ball:")); }
public async Task Command([Remainder] string question) { List <EightBall> responses = await DatabaseQueries.GetAllAsync <EightBall>(); var r = new Random(); int val = r.Next(responses.Count); EightBall response = responses[val]; var suicidePreventionRegexArray = new[] { new Regex(@"should i \b(?:kill|end|hang)\b \b(myself|it all)\b"), new Regex(@"should i \b(commit|hang)\b \b(?:myself|suicide)\b"), new Regex(@"\b(hang|kill|suicide)\b \b(myself)\b"), new Regex(@"suicide"), new Regex(@"i \b(end)\b \b(it all|my life|myself)\b") }; var embed = new KaguyaEmbedBuilder { Title = $"Magic 8Ball | {new Emoji("🔮")}", Description = response.Response }; if (suicidePreventionRegexArray.Any(x => x.IsMatch(question.ToLower()))) { embed = new KaguyaEmbedBuilder(EmbedColor.VIOLET) { Title = $"Magic 8Ball | {new Emoji("🔮")}", Description = $"Hey, friend. I'm not really sure how to answer this " + $"one. These resources may be able to help you figure this out:\n\n" + $"[[USA Suicide Prevention Hotline: 1-800-273-8255]](https://suicidepreventionlifeline.org/)\n" + $"[[USA Suicide Prevention Website]](https://suicidepreventionlifeline.org/)\n" + $"[[International Suicide Prevention Website]](https://www.supportisp.org/)" }; } await SendEmbedAsync(embed); }
public async Task EightBall([Remainder] string message) { EightBall ball = new EightBall(); await Context.Channel.SendMessageAsync(ball.GrabRandomAnswer()); }
public void Can_Construct_EightBall() { var eightBall = new EightBall(); Assert.IsNotNull(eightBall); }
// Use this for initialization void Start() { queball = GetComponent <QueBall>(); winBall = GetComponent <EightBall>(); }
public async Task Shake(params string[] text) { await ReplyAsync(EightBall.Shake()); }
public void Setup() { eightBall = new EightBall(); }