Пример #1
0
 public void Play()
 {
     deck  = new CardDeck();
     gamer = new Gamer();
     gamer.TakeCard();
     ShowHands(gamer);
     if (gamer.Sum == 21)
     {
         Console.WriteLine("Black Jack, You WIN!");
         task = Task.Factory.StartNew(() => StatInsert("Black Jack"));
         //StatInsert("Black Jack");
         Console.ReadKey();
     }
     else
     {
         bool flag = false;
         do
         {
             if (flag)
             {
                 gamer.TakeCard();
                 ShowHands(gamer);
             }
             if (gamer.Sum > 21)
             {
                 Console.WriteLine("Bust! You lose");
                 task = Task.Factory.StartNew(() => StatInsert("Bust"));
                 //StatInsert("Bust");
                 break;
             }
             else if (gamer.Sum == 21)
             {
                 break;
             }
             Answer("More card?", out flag);
         } while (flag);
         if (gamer.Sum <= 21)
         {
             dealer = new Dealer();
             dealer.DealerPlay();
             if (dealer.Sum > 21)
             {
                 ShowHands(dealer);
                 Console.WriteLine("You win!");
                 task = Task.Factory.StartNew(() => StatInsert("Win"));
                 //StatInsert("Win");
             }
             else if (dealer.Sum <= 21 && dealer.Sum > gamer.Sum)
             {
                 ShowHands(dealer);
                 Console.WriteLine("Dealer wins, you lose");
                 task = Task.Factory.StartNew(() => StatInsert("Lose"));
                 //StatInsert("Lose");
             }
             else if (dealer.Sum < 21 && dealer.Sum < gamer.Sum)
             {
                 ShowHands(dealer);
                 Console.WriteLine("You Win!");
                 task = Task.Factory.StartNew(() => StatInsert("Win"));
                 //StatInsert("Win");
             }
             else
             {
                 ShowHands(dealer);
                 Console.WriteLine("Push!");
                 task = Task.Factory.StartNew(() => StatInsert("Push"));
                 //StatInsert("Push");
             }
         }
     }
 }