Ejemplo n.º 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++;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void TestShuffle()
        {
            var deck     = new Deck();
            var oldValue = deck.cards[0].Value;
            var oldSuit  = deck.cards[0].Suit;

            FisherYatesAlgorithm.Shuffle(ref deck);
            Assert.AreNotEqual(deck.cards[0].Value, oldValue);
            Assert.AreNotEqual(deck.cards[0].Suit, oldSuit);
        }