Ejemplo n.º 1
0
        //plays the end game scenario, playing the dealers role.
        public void Hold()
        {
            form.toggleButtons();

            house_image_util.Unflip(0);
            while (Sum(house_hand) <= HOUSE_THRESHOLD && house_hand.currentCardCount() < TOTAL_CARDS_ALLOWED)
            {
                house_hand.drawCard();
                house_image_util.Draw();
            }

            if (Sum(house_hand) > TWENTY_ONE)
            {
                if (Sum(user_hand) == TWENTY_ONE)
                {
                    MessageBox.Show("You got Blackjack!", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBox.Show("House went bust, you win!", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
            }
            else
            {
                calculateScore();
            }
        }
Ejemplo n.º 2
0
 //used for drawing the cards in hand to the screen
 public void Draw()
 {
     if (picture_boxes.Count < hand.currentCardCount())               //check to make sure we haven't already drawn the cards
     {
         List <string> names = genCardName();
         for (int i = picture_boxes.Count; i < hand.currentCardCount(); i++)                   //create a picturebox and then draw the card to it according to its number and suit
         {
             picture_boxes.Add(new PictureBox());
             for (int j = 0; j < image_list.Images.Count; j++)
             {
                 if (image_list.Images.Keys[j].ToString() == names[i])
                 {
                     picture_boxes[i].Location = new Point(card_point.X + (x_offset * i), card_point.Y - (y_offset * i));
                     picture_boxes[i].Size     = CARD_SIZE;
                     picture_boxes[i].Image    = image_list.Images[j];
                     picture_boxes[i].SizeMode = PictureBoxSizeMode.StretchImage;
                     form.Controls.Add(picture_boxes[i]);
                     picture_boxes[i].BringToFront();
                     break;
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        //generates a new card and give it to the player
        public void Hit()
        {
            user_hand.drawCard();
            user_image_util.Draw();

            if (Sum(user_hand) == TWENTY_ONE)
            {
                Hold();
            }
            else if (Sum(user_hand) > TWENTY_ONE)
            {
                form.toggleButtons();
                MessageBox.Show("You went bust, you lose.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
            else if (user_hand.currentCardCount() >= TOTAL_CARDS_ALLOWED)
            {
                form.toggleButtons();
                MessageBox.Show("You got a five-card Charlie, you win!", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
        }