private void findImage()
        {
            switch (CardBack.Kind)
            {
            case (CardBack.BackType.HALLOWEEN):
            {
                backgroundImage = CardImageHelper.getResource("halloween_back");
            }
            break;

            case (CardBack.BackType.NINJA):
            {
                backgroundImage = CardImageHelper.getResource("ninja_back");
            }
            break;

            case (CardBack.BackType.WALUIGI):
            {
                backgroundImage = CardImageHelper.getResource("waluigi_back");
            }
            break;

            case (CardBack.BackType.GEORGE):
            {
                backgroundImage = CardImageHelper.getResource("washington_back");
            }
            break;

            case (CardBack.BackType.CANADA):
            {
                backgroundImage = CardImageHelper.getResource("canada_back");
            }
            break;
            }
        }
예제 #2
0
        private void dealCards()
        {
            deck.shuffleDeck();
            Tuple <int, int>[] cards = new Tuple <int, int> [5];
            int index = 0;

            foreach (PictureBox playerCardPic in playerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                playerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            dealerHand = new Hand(cards);
            cards      = new CardType[5];
            index      = 0;
            foreach (PictureBox dealerCardPic in dealerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                dealerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            playerHand       = new Hand(cards);
            lblHandType.Text = playerHand.getHandType().ToString();
            Dlhandtype.Text  = "D : " + dealerHand.getHandType().ToString();
            checkWin(playerHand.getHandType(), dealerHand.getHandType());
        }
 /// <summary>
 /// Hides all of participants cards
 /// </summary>
 public void hideCards()
 {
     CardType[] cards = hand.getCards();
     for (int i = 0; i < cards.Length; i++)
     {
         cardPics[i].BackgroundImage = CardImageHelper.cardBackToBitmap();
     }
     showHand          = false;
     handLabel.Visible = false;
 }
        // deal cards to the player and dealer
        private void dealCards()
        {
            // first shuffle the deck
            deck.shuffleDeck();

            //set dealer's bet
            if (dealerPoints >= blind)
            {
                Random uhh = new Random();
                dealerBet = uhh.Next(blind, dealerPoints);
            }
            //If he doesn't have enough, he's all in
            else
            {
                dealerBet = dealerPoints;
            }

            bet = 0;

            // create an array of tuple that represents a card - the first integer is the face while the second
            // integer is the suit
            Tuple <int, int>[] cards = new Tuple <int, int> [5];

            // grab a new card for each card the player needs and give the card its respective image
            int index = 0;

            foreach (PictureBox playerCardPic in playerCardPics)
            {
                CardType card = deck.nextCard();
                cards[index++] = card;
                playerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }

            // set these cards as the player's hand, then start creating the dealer's hand
            playerHand = new Hand(cards);
            cards      = new CardType[5];
            index      = 0;

            // grab a new card for each card the dealer needs and give the card its respective image
            foreach (PictureBox dealerCardPic in dealerCardPics)
            {
                CardType card = deck.nextCard();
                cards[index++] = card;

                // change the dealer's card back depending on the theme selected from settings
                dealerCardPic.BackgroundImage = backgroundImage;
            }

            // set those cards as the dealer's hand and then determine the best combination of cards in the
            // player's hand
            dealerHand           = new Hand(cards);
            label1.Text          = playerPoints.ToString();
            label_hand_type.Text = playerHand.getHandType().ToString();
        }
        private void revealDealerHand()
        {
            Tuple <int, int>[] cards = new Tuple <int, int> [5];
            cards = dealerHand.getCurrentHand();
            int index = 0;

            foreach (PictureBox dealerCardPic in dealerCardPics)
            {
                dealerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(cards[index]);
                index++;
            }
            roundUpdate();
        }
예제 #6
0
        private void dealCards()
        {
            deck.shuffleDeck();
            Tuple <int, int>[] cards = new Tuple <int, int> [5];
            int index = 0;

            foreach (PictureBox playerCardPic in playerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                playerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            dealerHand = new Hand(cards);
            cards      = new CardType[5];
            index      = 0;
            foreach (PictureBox dealerCardPic in dealerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                dealerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            playerHand       = new Hand(cards);
            lblHandType.Text = "P: " + playerHand.getHandType().ToString();
            Dlhandtype.Text  = "D: " + dealerHand.getHandType().ToString();
            //call for checkWin function
            checkWin(playerHand.getHandType(), dealerHand.getHandType());
            if (bal == 0)
            {
                button1.Enabled = false;
            }


            //code that's probably useless now

            /*if (playerHand.getHandType() < dealerHand.getHandType())
             * {
             *  handwinloss.Text = "Player win";
             * }
             * else
             *  handwinloss.Text = "Player Lose";*/
        }
예제 #7
0
        private void dealCards()
        {
            deck.shuffleDeck();
            Tuple <int, int>[] cards = new Tuple <int, int> [5];
            int index = 0;

            foreach (PictureBox playerCardPic in playerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                playerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            playerHand       = new Hand(cards);
            lblHandType.Text = playerHand.getHandType().ToString();

            cards = new CardType[5];
            index = 0;
            foreach (PictureBox dealerCardPic in dealerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                dealerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            dealerHand             = new Hand(cards);
            lblHandTypeDealer.Text = dealerHand.getHandType().ToString();

            if (playerHand.getHandType() == dealerHand.getHandType())
            {
                lblWin.Text = "Draw";
            }
            else if (playerHand.getHandType() < dealerHand.getHandType())
            {
                lblWin.Text = "You Win!";
            }
            else
            {
                lblWin.Text = "You Lose";
            }
        }
예제 #8
0
        private void dealCards()
        {
            deck.shuffleDeck();
            Tuple <int, int>[] cards = new Tuple <int, int> [5];
            int index = 0;

            foreach (PictureBox playerCardPic in playerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                playerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            dealerHand = new Hand(cards);
            cards      = new CardType[5];
            index      = 0;
            foreach (PictureBox dealerCardPic in dealerCardPics)
            {
                CardType card = deck.nextCard();
                //CardType card = new CardType(index, inde);
                cards[index++] = card;
                dealerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
            }
            playerHand       = new Hand(cards);
            lblHandType.Text = playerHand.getHandType().ToString();

            // set up timer
            MyTimer.Stop();
            TimerLabel.ForeColor = System.Drawing.Color.Black;
            TimerLabel.Text      = "30 seconds remaining";
            startTime            = DateTime.Now;
            lblHandType.Text     = playerHand.getHandType().ToString();
            // start timer
            MyTimer.Tick    += (s, ev) => { TimerLabel.Text = String.Format("{0:00} seconds remaining", 30 - (DateTime.Now - startTime).Seconds); };
            MyTimer.Interval = 1000;
            MyTimer.Tick    += new EventHandler(MyTimer_Tick);
            MyTimer.Start();
        }
예제 #9
0
        public void refreshCardPics(String p)
        {
            int index = 0;

            if (p == "player")
            {
                foreach (PictureBox playerCardPic in playerCardPics)
                {
                    CardType card = deck.nextCard();
                    cards[index++] = card;
                    playerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
            }
            else if (p == "dealer")
            {
                foreach (PictureBox dealerCardPic in dealerCardPics)
                {
                    CardType card = deck.nextCard();
                    cards[index++] = card;
                    dealerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
            }
        }
예제 #10
0
        // MadG: Moved discard logic to its own method
        private void discard(Hand x)
        {
            cards = new Tuple <int, int> [5];
            if (!dealerDiscard)
            {
                if (picHilight1.Visible)
                {
                    picHilight1.Visible = !picHilight1.Visible;
                    CardType card = deck.nextCard();
                    cards[0] = card;
                    picCard1.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[0] = playerCards[0];
                }

                if (picHilight2.Visible)
                {
                    picHilight2.Visible = !picHilight2.Visible;
                    CardType card = deck.nextCard();
                    cards[1] = card;
                    picCard2.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[1] = playerCards[1];
                }

                if (picHilight3.Visible)
                {
                    picHilight3.Visible = !picHilight3.Visible;
                    CardType card = deck.nextCard();
                    cards[2] = card;
                    picCard3.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[2] = playerCards[2];
                }

                if (picHilight4.Visible)
                {
                    picHilight4.Visible = !picHilight4.Visible;
                    CardType card = deck.nextCard();
                    cards[3] = card;
                    picCard4.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[3] = playerCards[3];
                }

                if (picHilight5.Visible)
                {
                    picHilight5.Visible = !picHilight5.Visible;
                    CardType card = deck.nextCard();
                    cards[4] = card;
                    picCard5.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[4] = playerCards[4];
                }

                x                = new Hand(cards);
                playerHand       = x;
                lblHandType.Text = x.getHandType().ToString();
            }
            else
            {
                if (willDiscard[0])
                {
                    CardType card = deck.nextCard();
                    cards[0] = card;
                    pictureBox1.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[0] = dealerCards[0];
                }

                if (willDiscard[1])
                {
                    CardType card = deck.nextCard();
                    cards[1] = card;
                    pictureBox2.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[1] = dealerCards[1];
                }

                if (willDiscard[2])
                {
                    CardType card = deck.nextCard();
                    cards[2] = card;
                    pictureBox3.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[2] = dealerCards[2];
                }

                if (willDiscard[3])
                {
                    CardType card = deck.nextCard();
                    cards[3] = card;
                    pictureBox4.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[3] = dealerCards[3];
                }

                if (willDiscard[4])
                {
                    CardType card = deck.nextCard();
                    cards[4] = card;
                    pictureBox5.BackgroundImage = CardImageHelper.cardToBitmap(card);
                }
                else
                {
                    cards[4] = dealerCards[4];
                }

                x                  = new Hand(cards);
                dealerHand         = x;
                lblDealerHand.Text = x.getHandType().ToString();
                dealerDiscard      = false;
            }
        }
        private void discardCards()
        {
            Tuple <int, int>[] playerCards = new Tuple <int, int> [5];
            playerCards = playerHand.getCurrentHand();

            if (checkBox1.Checked == true)
            {
                CardType playerCard = deck.nextCard();
                playerCards[0]    = playerCard;
                checkBox1.Checked = false;
            }
            if (checkBox2.Checked == true)
            {
                CardType playerCard = deck.nextCard();
                playerCards[1]    = playerCard;
                checkBox2.Checked = false;
            }
            if (checkBox3.Checked == true)
            {
                CardType playerCard = deck.nextCard();
                playerCards[2]    = playerCard;
                checkBox3.Checked = false;
            }
            if (checkBox4.Checked == true)
            {
                CardType playerCard = deck.nextCard();
                playerCards[3]    = playerCard;
                checkBox4.Checked = false;
            }
            if (checkBox5.Checked == true)
            {
                CardType playerCard = deck.nextCard();
                playerCards[4]    = playerCard;
                checkBox5.Checked = false;
            }

            int playerIndex = 0;

            foreach (PictureBox playerCardPic in playerCardPics)
            {
                playerCardPic.BackgroundImage = CardImageHelper.cardToBitmap(playerCards[playerIndex]);
                playerIndex++;
            }

            playerHand           = new Hand(playerCards);
            label_hand_type.Text = playerHand.getHandType().ToString();

            Random RNG = new Random();

            // create an array of tuple that represents a card - the first integer is the face while the second
            // integer is the suit
            Tuple <int, int>[] cards  = new Tuple <int, int> [5];
            int numberDealerToDiscard = RNG.Next(1, 6);

            //Create the array based off of the amount of cards the RNG  gave us
            int index = 0;

            cards = dealerHand.getCurrentHand();

            // grab a new card for each card the dealer needs
            for (int l = 0; l < numberDealerToDiscard; l++)
            {
                CardType card = deck.nextCard();
                cards[index++] = card;
            }

            foreach (PictureBox dealerCardPic in dealerCardPics)
            {
                // change the dealer's card back depending on the theme selected from settings
                dealerCardPic.BackgroundImage = backgroundImage;
            }
            // set those cards as the dealer's hand
            dealerHand = new Hand(cards);

            button_discard.Enabled = false;
        }