public static void RandomCards(Game play)
 {
     Random rnd = new Random();
     byte[] ost = new byte[208];//запоминает перемешанные
     int kol = 103;
     int start = 104;
     for (int i = 0; i < 207; i++) ost[i] = 1;
     for (int i = 0; i < 103; i++)
     {
         int pl = rnd.Next(kol - i);
         int control = 0;
         while (control != pl + 1)
         {
             if (ost[start] == 1)
             {
                 start++; control++;
             }
             else
             {
                 start++;
             }
         }
         start--;
         infcard m = play.cld[i];
         play.cld[i] = play.cld[start];
         play.cld[start] = m;
         ost[i] = ost[start] = 0;
         start = 0;
         //bot.num = 0;
     }
     Console.WriteLine();
     play.bot.num = 0;
     play.peek = 0;
 }
示例#2
0
 static void Main(string[] args)
 {
     int coins = 0;
     Exception exc;
     Console.Write("How much money did you get home: ");
     do
     {
         try
         {
             exc = null;
             coins = int.Parse(Console.ReadLine());
             if (coins <= 0) throw exc;
             Console.WriteLine();
             Game play = new Game(coins);
             Game.BlackJack(play);
         }
         catch (Exception EXCParse)
         {
             exc = EXCParse;
             Console.WriteLine("Repeat please!");
             Console.WriteLine();
             Console.Write("How much money did you get home: ");
         }
     }
     while (exc != null);
 }
示例#3
0
        public void GivePlayer(Game play)
        {
            if (play.cld[play.peek].val != 1)
            {
                kol_player += play.cld[play.peek].val;
            }
            else
            {
                kol_player += 11;
            }
            Console.WriteLine("Your Points: " + play.cld[play.peek].name + " " + play.cld[play.peek].suit + " (summa: " + kol_player + ")");
            play.bot.num = play.cld[play.peek].val;
            play.peek++;

            while (BotControl.TakeCards(play.bot.num, kol_player))
            {
                //Console.Write(" " + cld[peek].name + " " + cld[peek].suit);
                if (((play.cld[play.peek].val == 1) && (play.diller.kol_diller + 11 > 21)) || (play.cld[play.peek].val != 1))
                {
                    kol_player += play.cld[play.peek].val;
                    play.bot.num = play.cld[play.peek].val;
                    play.peek++;
                    Console.WriteLine("Your Points: " + play.cld[play.peek - 1].name + " " + play.cld[play.peek - 1].suit + " (summa: " + kol_player + ")");
                }
                else
                {
                    kol_player += 11;
                    play.bot.num = play.cld[play.peek].val;
                    play.peek++;
                    Console.WriteLine("Your Points: " + play.cld[play.peek - 1].name + " " + play.cld[play.peek - 1].suit + " (summa: " + kol_player + ")");
                }
            }
        }
示例#4
0
        public void GivePlayer(Game play)
        {
            if (play.cld[play.peek].val != 1)
            {
                kol_player += play.cld[play.peek].val;
            }
            else
            {
                kol_player += 11;
            }
            Console.WriteLine("Your Points: " + play.cld[play.peek].name + " " + play.cld[play.peek].suit + " (summa: " + kol_player + ")");
            play.peek++;
            Console.Write("Do you want to continue take cards? ");

            while ((String.Compare(Console.ReadLine(), "yes", true) == 0) && (kol_player <= 21))
            {
                //Console.Write(" " + cld[peek].name + " " + cld[peek].suit);
                if (((play.cld[play.peek].val == 1) && (play.diller.kol_diller + 11 > 21)) || (play.cld[play.peek].val != 1))
                {
                    kol_player += play.cld[play.peek].val;
                    play.peek++;
                    Console.WriteLine("Your Points: " + play.cld[play.peek - 1].name + " " + play.cld[play.peek - 1].suit + " (summa: " + play.player.kol_player + ")");
                    if (kol_player == 21) break;
                }
                else
                {
                    kol_player += 11;
                    play.peek++;
                    Console.WriteLine("Your Points: " + play.cld[play.peek - 1].name + " " + play.cld[play.peek - 1].suit + " (summa: " + kol_player + ")");
                    if (kol_player == 21) break;
                }
                if (kol_player <= 21) Console.Write("Do you want to continue take cards? ");
            }
        }
示例#5
0
        public void GiveDiller(Game play)
        {
            while (kol_diller <= 17)
            {
                if ((all_cards_diller == 0))
                {
                    cards_for_diller[all_cards_diller] = play.cld[play.peek];
                    if (play.cld[play.peek].val == 1)
                    {
                        kol_diller += 11;
                    }
                    else
                    {
                        kol_diller += play.cld[play.peek].val;
                    }
                    Console.WriteLine("first card: " + play.cld[play.peek].name + " " + play.cld[play.peek].suit + " (summa: " + kol_diller + " )");
                    all_cards_diller++;
                    play.bot.Num = play.cld[play.peek].val;
                    play.peek++;
                    cards_for_diller[all_cards_diller] = play.cld[play.peek];

                }
                else
                {
                    if (((play.cld[play.peek].val == 1) && (kol_diller + 11 > 21)) || (play.cld[play.peek].val != 1))
                    {
                        cards_for_diller[all_cards_diller] = play.cld[play.peek];
                    }
                    else
                    {
                        cards_for_diller[all_cards_diller] = play.cld[play.peek];
                        cards_for_diller[all_cards_diller].val = 11;
                    }
                }
                if (((play.cld[play.peek].val == 1) && (kol_diller + 11 > 21)) || (play.cld[play.peek].val != 1))
                {
                    kol_diller += cards_for_diller[all_cards_diller].val;
                }
                else
                {
                    kol_diller += 11;
                }

                Console.WriteLine("SECRET card for diller: " + play.cld[play.peek].name + " " + play.cld[play.peek].suit + " (summa: " + kol_diller + " )");
                all_cards_diller++;
                play.bot.Num = play.cld[play.peek].val;
                play.peek++;
                if (all_cards_diller == 2) break;
            }
        }
示例#6
0
        static void Main(string[] args)
        {
            int coins=0;
            Exception exc;
            Console.Write("How much money did you get home: ");
            do
            {
               
                    exc = null;
                    coins = int.Parse(Console.ReadLine());
                    //if (coins <= 0) throw exc;
                    Console.WriteLine();
                    Game play = new Game((double)coins);
                    Game.BlackJack(play);

                
            }
            while (exc!=null); 
        }
示例#7
0
        public static void this_black_jack(Game play1)
        {
            Console.WriteLine("Do you play?");
            Console.Write("If true, so write 'yes', else other. ");
            while ((String.Compare(Console.ReadLine(), "Yes", true) == 0) && (play1.player.coins > 0))
            {
                Console.WriteLine();
                play1.player.kol_player = play1.diller.kol_diller = play1.diller.all_cards_diller = 0;
                play1.player.bid = 0;
                if (play1.startgame == 1)
                {
                    play1.random_cards();
                }
                else
                {
                    Console.WriteLine("Hey, we play!");
                }
                play1.startgame = 0;
                play1.give_diller();
                play1.give_player();

                if (play1.player.kol_player > 21)
                {
                    play1.player.coins -= play1.player.bid;
                    Console.WriteLine("diller win");
                    play1.Show_coins();
                    if (play1.player.coins > 0)
                    {
                        Console.WriteLine("Play again?");
                        Console.Write("If true, so write 'yes', else other. ");
                    }
                }
                else
                {
                    if (play1.player.kol_player == 21)
                    {
                        if (play1.diller.cards_for_diller[0].val >= 10)
                        {
                            Console.WriteLine("This push. Do you want to continue?");
                            if (String.Compare(Console.ReadLine(), "yes", true) != 0)
                            {
                                if (play1.diller.cards_for_diller[0].val + play1.diller.cards_for_diller[1].val == 21)
                                {
                                    play1.player.coins -= play1.player.bid;
                                    Console.WriteLine("dealer's cards: " + play1.diller.cards_for_diller[0].suit + play1.diller.cards_for_diller[0].name +
                                                                         play1.diller.cards_for_diller[1].suit + play1.diller.cards_for_diller[1].name);
                                    Console.WriteLine("diller win( black jack)");
                                    play1.Show_coins();
                                }
                                else
                                {
                                    play1.player.coins += (int)(0.5 * play1.player.bid);
                                    Console.WriteLine("dealer's cards: " + play1.diller.cards_for_diller[0].suit + play1.diller.cards_for_diller[0].name +
                                                                         play1.diller.cards_for_diller[1].suit + play1.diller.cards_for_diller[1].name);
                                    Console.WriteLine("You win( black jack)");
                                    play1.Show_coins();
                                }
                            }
                            else
                            {
                                if (play1.diller.cards_for_diller[0].val + play1.diller.cards_for_diller[1].val == 21)
                                {
                                    Console.WriteLine("dealer's cards: " + play1.diller.cards_for_diller[0].suit + play1.diller.cards_for_diller[0].name +
                                                                         play1.diller.cards_for_diller[1].suit + play1.diller.cards_for_diller[1].name);
                                    Console.WriteLine("Push");
                                    play1.Show_coins();
                                }
                            }
                        }
                    }
                    else
                    {
                        play1.give_diller();
                        if ((play1.diller.kol_diller > play1.player.kol_player) && (play1.diller.kol_diller <= 21))
                        {
                            play1.player.coins -= play1.player.bid;
                            Console.WriteLine("diller win");
                            play1.Show_coins();
                        }
                        else
                        {
                            if (play1.diller.kol_diller != play1.player.kol_player)
                            {
                                play1.player.coins += (int)(0.5 * play1.player.bid);
                                Console.WriteLine("player win");
                                if (play1.player.bid % 2 == 1) play1.player.coins++;
                                play1.Show_coins();
                            }
                            else
                            {
                                Console.WriteLine("Both win");
                                play1.Show_coins();
                            }
                        }
                    }

                    if (play1.player.coins > 0)
                    {
                        Console.WriteLine("Do you play?");
                        Console.Write("If true, so write 'yes', else other. ");
                    }
                    else
                    {
                        Console.WriteLine("No money");
                    }
                }
                if (play1.peek > 156)
                {
                    play1.random_cards();
                    play1.peek = 0;
                }
            }
            Console.WriteLine();
            Console.WriteLine("Goodbye!");
            Console.ReadKey();
        }
        public static void BlackJack(Game play1)
        {
            int play = 0;
            while (play1.player.coins >= 1)
            {
                Console.WriteLine();
                play1.player.kol_player = play1.diller.kol_diller = play1.diller.all_cards_diller = 0;
                play1.player.bid = play1.bot.Bid(play1.player.coins, play1.peek, ref play1.player.win);
                if (play1.player.bid >= 1)
                {
                    Console.WriteLine("Bid: {0:.#}", play1.player.bid);
                }
                else
                {
                    Console.WriteLine("Bid: 0{0:.#}", play1.player.bid);
                }
                if (play1.startgame == 1)
                {
                    play1.RandomCards();
                }
                play1.startgame = 0;
                play1.GiveDiller();
                play1.GivePlayer();

                if (play1.player.kol_player > 21)
                {
                    play1.player.coins -= play1.player.bid;
                    Console.WriteLine("diller win");
                    play1.player.win++;
                    play1.ShowCoins();
                }
                else
                {
                    if (play1.player.kol_player == 21)
                    {
                        if (play1.diller.cards_for_diller[0].val >= 10)
                        {
                            Console.WriteLine("This push.");
                            if ((play1.bot.Num <= 0) && (Math.Abs(play1.bot.Num) > 4))
                            {
                                if (play1.diller.cards_for_diller[0].val + play1.diller.cards_for_diller[1].val == 21)
                                {
                                    play1.player.coins -= play1.player.bid;
                                    Console.WriteLine("dealer's cards: " + play1.diller.cards_for_diller[0].suit + play1.diller.cards_for_diller[0].name +
                                                                         play1.diller.cards_for_diller[1].suit + play1.diller.cards_for_diller[1].name);
                                    Console.WriteLine("diller win( black jack)");
                                    play1.player.win++;
                                    play1.ShowCoins();
                                }
                                else
                                {
                                    play1.player.coins += (0.5 * play1.player.bid);
                                    Console.WriteLine("dealer's cards: " + play1.diller.cards_for_diller[0].suit + play1.diller.cards_for_diller[0].name +
                                                                         play1.diller.cards_for_diller[1].suit + play1.diller.cards_for_diller[1].name);
                                    Console.WriteLine("You win( black jack)");
                                    play1.player.win = 0;
                                    play1.ShowCoins();
                                }
                            }
                            else
                            {
                                if (play1.diller.cards_for_diller[0].val + play1.diller.cards_for_diller[1].val == 21)
                                {
                                    Console.WriteLine("dealer's cards: " + play1.diller.cards_for_diller[0].suit + play1.diller.cards_for_diller[0].name +
                                                                         play1.diller.cards_for_diller[1].suit + play1.diller.cards_for_diller[1].name);
                                    Console.WriteLine("Push");
                                    play1.player.win++;
                                    play1.ShowCoins();
                                }
                            }
                        }
                    }
                    else
                    {
                        play1.GiveDiller();
                        if ((play1.diller.kol_diller > play1.player.kol_player) && (play1.diller.kol_diller <= 21))
                        {
                            play1.player.coins -= play1.player.bid;
                            play1.player.win++;
                            Console.WriteLine("diller win");
                            play1.ShowCoins();
                        }
                        else
                        {
                            if (play1.diller.kol_diller != play1.player.kol_player)
                            {
                                play1.player.coins += (0.5 * play1.player.bid);
                                Console.WriteLine("player win");
                                play1.player.win = 0;
                                play1.ShowCoins();
                            }
                            else
                            {
                                Console.WriteLine("Both win");
                                play1.player.win++;
                                play1.ShowCoins();
                            }
                        }
                    }
                    if (play1.player.coins > 1)
                    {
                        play++;
                        if (play == 10)
                        {
                            Console.ReadKey();
                        }
                    }
                    else
                    {
                        Console.WriteLine("No money");
                    }
                }
                if (play1.peek > 156)
                {
                    play1.RandomCards();
                    play1.peek = 0;
                }
            }
            Console.WriteLine();
            Console.WriteLine("Goodbye!");
            Console.ReadKey();
        }
示例#9
0
 public static void BlackJack(Game play1)
 {
     BasisBlackJack.BlackJack(play1);
 }