Dominion.ListOfCards.Shuffle C# (CSharp) Метод

Shuffle() публичный Метод

public Shuffle ( Random random ) : void
random System.Random
Результат void
        public void Shuffle(Random random)
        {
            int lastIndex = this.cards.Count - 1;
            for (int currentIndex = 0; currentIndex < lastIndex; ++currentIndex)
            {
                int swapIndex = NumberBetweenInclusive(random, currentIndex, lastIndex);
                Swap(currentIndex, swapIndex);
            }

            this.countKnownCard = 0;
        }

Usage Example

Пример #1
0
        private static PileOfCards CreateRuins(CardGameSubset gameSubset, int ruinsCount, Random random)
        {
            int ruinCountPerPile = 10;
            var allRuinsCards    = new ListOfCards(gameSubset);

            allRuinsCards.AddNCardsToTop(Cards.AbandonedMine, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.RuinedMarket, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.RuinedLibrary, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.RuinedVillage, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.Survivors, ruinCountPerPile);

            allRuinsCards.Shuffle(random);

            var result = new PileOfCards(gameSubset, Cards.Ruins);

            for (int i = 0; i < ruinsCount; ++i)
            {
                Card card = allRuinsCards.DrawCardFromTop();
                if (card == null)
                {
                    throw new Exception("Not enough ruins available.");
                }
                result.AddCardToTop(card);
            }
            result.EraseKnownCountKnowledge();

            return(result);
        }
All Usage Examples Of Dominion.ListOfCards::Shuffle