Example #1
0
        private void CardClicked(object sender, EventArgs e)
        {
            //Check if the Card is a valid card to play depending on the river

            //sets the creates a new card which will be added into the river
            PlayingCard clickedCard = (sender as CardImages.CardImage).Card;

            CardImages.CardImage myCard = new CardImages.CardImage(); //creates the card box
            myCard.Card = clickedCard;                                //sets the cardboxcard to the card created from the click



            //finds the card from the players hand
            PlayingCard cardRemoved = newGame.myGamePlayer.hand.Single(x => x.Rank == clickedCard.Rank && x.Suit == clickedCard.Suit);

            //removes the card from the players hand
            newGame.myGamePlayer.hand.Remove(cardRemoved);
            //adds the card to the river
            newGame.myGameRiver.hand.Add(cardRemoved);
            //updates the players hand
            UpdateHand();
        }
Example #2
0
        public void UpdateHand()
        {
            //clears the two flp containers
            flpPlayerHand.Controls.Clear();
            flpAIPlayer.Controls.Clear();
            fplRiver.Controls.Clear();

            //River Cards
            //updates the rivers cards played
            if (newGame.myGameRiver.hand != null)
            {
                foreach (PlayingCard Card in newGame.myGameRiver.hand)
                {
                    CardImages.CardImage myCard = new CardImages.CardImage();
                    myCard.Card = Card;
                    fplRiver.Controls.Add(myCard);
                }
            }


            // player cards
            foreach (PlayingCard Card in newGame.myGamePlayer.hand)
            {
                CardImages.CardImage myCard = new CardImages.CardImage();
                myCard.Card = Card;
                flpPlayerHand.Controls.Add(myCard);
                myCard.CardClicked += new EventHandler(CardClicked);
            }

            //AI Player cards
            foreach (PlayingCard Card in newGame.myAIPlayer.hand)
            {
                CardImages.CardImage myCard = new CardImages.CardImage();
                myCard.Card = Card;
                flpAIPlayer.Controls.Add(myCard);
            }
        }