Example #1
0
        public void Deal()
        {
            var deck      = Deck;
            int deckIndex = 0;

            FisherYatesAlgorithm.Shuffle(ref deck);
            for (int i = 0; i < NoOfCards; i++)
            {
                for (int j = 1; j <= NoOfPlayers; j++)
                {
                    //when dealing the first card, create the player
                    if (i == 0)
                    {
                        var player = new Player(j);
                        player.AddCard(deck.cards[deckIndex]);
                        Players.Add(player);
                        deckIndex++;
                    }
                    else
                    {
                        var player = Players.Where(x => x.PlayerId == j).First();
                        player.AddCard(deck.cards[deckIndex]);
                        deckIndex++;
                    }
                }
            }
        }
Example #2
0
 private void GiveCardsToPlayer(Player currentPlayer, int cardsNumber = 1)
 {
     for (int j = 0; j < cardsNumber; j++)
     {
         currentPlayer.AddCard(arrCards[cardDeckIndex++]);
     }
     ;
 }