public Card DiscardCard(Card parent)
        {
            if (Name == "Human Player")
            {
                Card cardToRemove = null;
                var cardNames = parent == null ? new string[Hand.Count] : new string[Hand.Count - 1];
                var counter = 0;
                foreach (var card in Hand)
                {
                    if (!card.Equals(parent))
                    {
                        cardNames[counter] = card.Name;
                        counter++;
                    }
                }
                var form = new UserChoiceForm("Choose the card you want to discard", cardNames);
                form.ShowDialog();

                if (form.DialogResult == DialogResult.OK)
                {
                    foreach (var card in Hand)
                    {
                        if (card.Name == form.GetCmbBoxSelectedContent())
                            cardToRemove = card;
                    }
                    Hand.Remove(cardToRemove);
                    _gameEngine.DiscardedDeck.Add(cardToRemove);
                }
                return cardToRemove;
            }
            LoseCard(parent);
            return null;
        }
 private void UpdateCurrentPlayPanel(int playerIndex, Card cardPlayed, int success)
 {
     // Display the card played in the Current Play panel.
     var previousText = textBoxCurrentPlay.Text;
     textBoxCurrentPlay.Text = _gameEngine.PlayersList[playerIndex].Name + " played \"" +
                                cardPlayed.Name;
     if (success == 0) textBoxCurrentPlay.Text += "\" in the wrong room" + "\r\n";
     else if (success == 1) textBoxCurrentPlay.Text += "\" but failed" + "\r\n";
     else if (success == 2) textBoxCurrentPlay.Text += "\" for " + cardPlayed.Reward + "\r\n";
     textBoxCurrentPlay.Text += previousText;
 }
        public bool PassToSophomoreYearIfNeeded()
        {
            int totalQp = 0;
            foreach (var player in PlayersList)
            {
                totalQp += player.QualityPoints;
            }
            if (totalQp >= 60)
            {
                CurrentYear = 2;
                Deck.AddRange(DiscardedDeck);
                DiscardedDeck = new List<Card>();
                foreach (var player in PlayersList)
                {
                    Deck.AddRange(player.Hand);
                    player.Hand = new List<Card>();
                }

                var tempDeck = new Card[Deck.Count];
                Deck.CopyTo(tempDeck);
                // Remove some Freshman cards.
                foreach (var card in tempDeck)
                {
                    if (new[]
                    {
                        "CECS 105", "CECS 100", "Math 122", "Professor Murgolo's CECS 174 Class",
                        "Math 123", "Physics 151", "KIN 253", "Pass Soccer Class", "Elective Class",
                        "Oral Communication", "CHEM 111"
                    }.Contains(card.Name))
                        Deck.Remove(card);
                }

                // Add some Sophomore cards.
                foreach (Type type in AppDomain.CurrentDomain.GetAssemblies()
                       .SelectMany(assembly => assembly.GetTypes())
                       .Where(type => type.IsSubclassOf(typeof(Card))))
                {
                    var card = (Card)Activator.CreateInstance(type);
                    if (card.Year == 2) Deck.Add(card);
                }

                ShuffleDeck();

                AssignRandomHands();

                return true;
            }
            return false;
        }
        private void ShuffleDeck()
        {
            var tmpDeck = new Card[Deck.Count];
            Deck.CopyTo(tmpDeck);
            var tmpDeckList = tmpDeck.ToList();
            Deck.Clear();
            Random rnd = new Random();

            foreach (var card in tmpDeck)
            {
                int index = rnd.Next(tmpDeckList.Count);
                Deck.Add(tmpDeckList.ElementAt(index));
                tmpDeckList.RemoveAt(index);
            }
        }
 public void LoseCard(Card parent)
 {
     Card card;
     do
     {
         card = Hand.ElementAt(new Random().Next(Hand.Count));
     } while (card.Equals(parent));
     Hand.Remove(card);
     _gameEngine.DiscardedDeck.Add(card);
 }