// Deck Constructor
 public Deck()
 {
     Cards = new Card[52];
      int cardsPos = 0;
      foreach (string rank in Card.ValidRanks())
      {
     foreach (string suit in Card.ValidSuits())
     {
        Cards[cardsPos++] = new Card(suit, rank);
     }
      }
      Randomizer = new Random();
 }
Ejemplo n.º 2
0
        private void Hit_Click(object sender, EventArgs e)
        {
            thisGame.SetInsuranceAvailaible(false);
            InsuranceButton.Visible = false;
            SplitButton.Visible = false;
            if (thisGame.GetBet(currentPlayer) <= 0)
            {
                Output.Text = "Must bet to play!";
                return;
            }

            Output.Text = "Player " + currentPlayer.ToString() + " choose to hit.";

            Card hitCard = thisGame.GetDeck().GetCard();
            Hand hand = thisGame.GetPlayerHand(currentPlayer);
            Hand splitHand = thisGame.GetSplitHand(currentPlayer);

            if (!thisGame.HasSplit(currentPlayer))
            {
                hand.AddCard(hitCard);

                DisplayCards(true);
                PlayerCount.Text = hand.GetTotal().ToString();
                if (hand.HasBusted())
                {
                    Output.Text = "Player " + currentPlayer.ToString() + " busted!";
                    this.Hit.Visible = false;
                    this.Stay.Visible = false;
                    Who_Won();
                }
            }
            else if (!splitHandDone)
            {
                hand.AddCard(hitCard);
                DisplayCards(true);
                PlayerCount.Text = hand.GetTotal().ToString();
                if (hand.HasBusted())
                {
                    Output.Text = "Hand 1 busted!";
                    splitHandDone = true;
                }
            }
            else
            {
                splitHand.AddCard(hitCard);
                SplitCount.Text = splitHand.GetTotal().ToString();
                DisplayCards(true);
                if (splitHand.HasBusted())
                {
                    Output.Text = "Hand 2 busted!";
                    this.Hit.Visible = false;
                    this.Stay.Visible = false;
                    if (hand.HasBusted())
                    {
                        Who_Won();
                    }
                    else
                    {
                        Computer_Turn();
                    }

                }

            }
        }