Exemplo n.º 1
0
        /// <summary>
        /// Load the card image for a given card in a given player group
        /// </summary>
        /// <param name="card"></param>
        /// <param name="player"></param>
        private void loadCard(Card card, int player)
        {
            GroupBox grp = Controls.OfType<GroupBox>().FirstOrDefault(g => g.Tag.ToString() == player.ToString());
            PictureBox pb = grp.Controls.OfType<PictureBox>().First(p => p.Image == null);
            string cardPath = "";
            if (card.CardType == 1)
                cardPath += "cl";
            else if (card.CardType == 2)
                cardPath += "di";
            else if (card.CardType == 3)
                cardPath += "he";
            else if (card.CardType == 4)
                cardPath += "sp";
            cardPath += card.CardNum.ToString() + ".gif";
            if (card.Down)
            {
                cardPath = "Back.png";
            }
            String imagePath = string.Format("{0}\\{1}", ".\\images",cardPath);
            pb.Image = new Bitmap(imagePath);

        }
Exemplo n.º 2
0
        /// <summary>
        /// callback for getting a new card from server 
        /// </summary>
        /// <param name="cardNum"></param>
        /// <param name="cardType"></param>
        /// <param name="playerID"></param>
        public void OnGetCard(int cardNum, int cardType, int playerID)
        {
            Card card = new Card(cardNum, cardType);
            Thread t = null;
            if (playerID == 0)
            {
                // the dealer has his own card list to handle 
                dealerCards.Add(card);
                if (dealerCards.Count == 2)
                { 
                    // need to reload cards later
                    card.Down = true; 
                }
            }else if (playerID == myID)
            {
                myCards.Add(card);
                if (CalculateHand(myCards)> 21)
                {
                    // loading the cards images before going bust
                    t = new Thread(() =>  pipeProxy.bust(myID));

                }
            }
            loadCard(card ,playerID);
            if (t != null)
            {
                t.Start();
                btn_stand.Enabled = false;
                btn_hit.Enabled = false;
                MessageBox.Show("You are busted");
                busted = true;
            }
        }
Exemplo n.º 3
0
 public void AddCard(Card card)
 {
     cards.Add(card);
 }