GR.Gambling.Blackjack.CardSet.CheatToDealPair C# (CSharp) Method

CheatToDealPair() public method

public CheatToDealPair ( Random rand ) : void
rand System.Random
return void
        public void CheatToDealPair(Random rand)
        {
            int top = card_set[card_set.Count-1].PointValue;

            if (card_set[card_set.Count-3].PointValue != top)
            {
                int top_count = card_counts[top - 1] - 1;

                int random_number = rand.Next(top_count);

                int random_index = 0;

                int matches = 0;

                for (int i = card_set.Count-2; i >= 0; i--)
                {
                    if (card_set[i].PointValue == top)
                    {
                        random_index = i;

                        if (matches == random_number) break;

                        matches++;
                    }
                }

                Card tmp = card_set[card_set.Count - 3];
                card_set[card_set.Count - 3] = card_set[random_index];
                card_set[random_index] = tmp;
            }
        }