예제 #1
0
        public async Task FlipCoin(CommandContext ctx, [Description("Heads or Tails")] string headsOrTails, [Description("How much gold do you want to bet on the coin")] int bet)
        {
            var random = new Random().Next(0, 2);

            HeadsOrTails coinResult = (HeadsOrTails)random;

            if (bet < 1)
            {
                await ctx.Channel.SendMessageAsync("You're a dip shit, you cant bet less than 1 Gold.");

                return;
            }

            var profile = await _profileService.GetOrCreateProfileAsync(ctx.Member.Id, ctx.Guild.Id);

            var botProfile = await _profileService.GetOrCreateProfileAsync(ctx.Client.CurrentUser.Id, ctx.Guild.Id);

            if (profile.Gold < bet)
            {
                throw new Exception($"You do not have enough gold to bet, you only have {profile.Gold}.");
            }

            bool memberWon = coinResult == Enum.Parse <HeadsOrTails>(headsOrTails.ToLower());

            await _goldService.ProccessMemberCoinFlip(profile, botProfile, bet, memberWon);

            if (memberWon)
            {
                await ctx.RespondAsync($"You won {bet} gold!");
            }
            else
            {
                await ctx.RespondAsync($"You lost {bet} gold.");
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            int option;

            do
            {
                Console.WriteLine("Which game do you want to play\n" +
                                  "1. Higher/Lower\n" +
                                  "2. Heads/Tails");

                option = Convert.ToInt16(Console.ReadLine());
                switch (option)
                {
                case 1:
                    bool  success;
                    int   guess;
                    HiLow game = new HiLow();
                    do
                    {
                        Console.WriteLine("You chose Higher/Lower!\n" +
                                          "Guess a number(0 - 9999):");
                        guess   = Convert.ToInt16(Console.ReadLine());
                        success = game.CheckGuess(guess);
                    } while (!success);

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    break;

                case 2:
                    HeadsOrTails game1 = new HeadsOrTails();
                    do
                    {
                        Console.WriteLine("You chose Heads/Tails!\n" +
                                          "Heads(0) or tails(1):");

                        guess   = Convert.ToInt16(Console.ReadLine());
                        success = game1.CheckIfGuessed(guess);
                    } while (!success);

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();

                    break;
                }
            } while (true);
        }
예제 #3
0
 public PlayerWinsFlip(Player player, HeadsOrTails outcome)
     : base(outcome)
 {
     this.Player = player;
 }
예제 #4
0
 public CoinFlip(HeadsOrTails outcome)
     : base(string.Format("Coin flipped = {0}", outcome))
 {
     this.Outcome = outcome;
 }