Exemple #1
0
        public async Task Gtn(CommandContext ctx, int number)
        {
            int computer = ThreadLocalRandom.Instance.Next(100);
            int guesses  = 0;

            await ctx.RespondAsync(computer.ToString());

            if (computer == number)
            {
                await ctx.RespondAsync("You guesses it! Nice Job");
            }
            else
            {
                while ((computer != number) || (guesses < 5))
                {
                    if (computer < number)
                    {
                        await ctx.RespondAsync("Go lower. " + (5 - guesses) + " guesses remaining.");
                    }
                    else if (computer > number)
                    {
                        await ctx.RespondAsync("Go higher. " + (5 - guesses) + " guesses remaining.");
                    }

                    string num = Console.ReadLine();
                    number = Int32.Parse(num);

                    guesses++;
                }

                if ((guesses < 5) && (computer == number))
                {
                    await ctx.RespondAsync("You guesses it! Nice Job");
                }
                else if (guesses >= 10)
                {
                    await ctx.RespondAsync("Bad Luck :( Try again later");
                }
            }

            await ctx.RespondAsync("The Number was " + computer.ToString());
        }