Beispiel #1
0
        // Helper function
        private Card DealOneCard(bool shouldBeFaceUp)
        {
            Card drawnCard = null;

            if (AllCards.Count > 0)
            {
                drawnCard = AllCards[0];
                drawnCard.Flip(shouldBeFaceUp);
                AllCards.Remove(drawnCard);
            }
            return(drawnCard);
        }
        public Card DealCard()
        {
            if (AllCards.FirstOrDefault().Value == 0)
            {
                ShuffleAllCards();
            }

            var card = AllCards.FirstOrDefault();

            AllCards.Remove(card);
            DiscardPile.Add(card);
            return(card);
        }
Beispiel #3
0
        public void CardsForPlayers(int playersInGame)
        {
            int numberOfPlayerCards = AllCards.Count / playersInGame;

            for (int i = 0; i < numberOfPlayerCards; i++)
            {
                for (int j = 0; j < playersInGame; j++)
                {
                    AllPlayer[j].PlayerCards.Add(AllCards.Last());
                    AllCards.Remove(AllCards.Last());
                }
            }
        }
Beispiel #4
0
        private void ShuffleCards()
        {
            Player1Cards = new List <Car>();
            Player2Cards = new List <Car>();
            var    cardsPerPlayer = 20;
            var    allCardsTotal  = 40;
            Random random         = new Random();
            var    value          = 0;

            for (int i = 1; i <= cardsPerPlayer; i++)
            {
                do
                {
                    value = random.Next(allCardsTotal);
                }while(!AllCards.Any(obj => obj.Id == value));
                Player1Cards.Add((Car)AllCards.Where(obj => obj.Id == value).FirstOrDefault());
                AllCards.Remove((Car)AllCards.Where(obj => obj.Id == value).FirstOrDefault());
            }
            Player2Cards = AllCards;
        }