protected override void ProcessDeck(CompleteDeckData deck)
        {
            // Finding min/max strengths
            int minStrength = int.MaxValue;
            int maxStrength = int.MinValue;

            foreach (var card in deck.Cards)
            {
                minStrength = Math.Min(minStrength, card.StrengthValue);
                maxStrength = Math.Max(maxStrength, card.StrengthValue);
            }

            m_MinStrength = minStrength;
            m_MaxStrength = maxStrength;

            // Counting number of types of suits
            List <CompleteCardData> copy = new List <CompleteCardData>(deck.Cards);
            int suitCount = 0;

            for (int i = 0; i < copy.Count; i++)
            {
                if (copy[i] == null)
                {
                    continue;
                }

                Suit suit = copy[i].Suit1;
                suitCount++;

                // Removing cards that have the same suit
                for (int j = i; j < copy.Count; j++)
                {
                    if (copy[j] == null)
                    {
                        continue;
                    }

                    if (copy[j].Suit1 == suit)
                    {
                        copy[j] = null;
                    }
                }
            }

            m_NumSuits = suitCount;
        }
        public void Run()
        {
            m_CurrentSimNumber = 0;

            // Initialize Players
            for (int i = 0; i < NumberOfPlayers; i++)
            {
                m_PlayerCards.Add(new PlayerGameData());
            }

            for (int i = 0; i < NumberOfSimulations; i++)
            {
                ++m_CurrentSimNumber;
                // Setup deck, shuffle deck.
                m_ShuffleDeck.Shuffle();
                Deck = new CompleteDeckData(m_ShuffleDeck);

                // Distribute cards to players
                for (int turn = 0; turn < NumberOfCardsPerPlayer; turn++)
                {
                    foreach (PlayerGameData player in m_PlayerCards)
                    {
                        player.AddCardToHand(Deck.Cards.Dequeue());
                    }
                }

                // Add cards to common pool
                for (int drawNumber = 0; drawNumber < NumberOfCommonCards; drawNumber++)
                {
                    m_CommonCards.Add(Deck.Cards.Dequeue());
                }

                // todo: Add checking of rules for every player, and determine the winner.
                for (int player = 0; player < NumberOfPlayers; player++)
                {
                }

                ClearSimulation();
            }
        }
Esempio n. 3
0
 public CompleteDeckData(CompleteDeckData toCopy)
 {
     Cards = new Queue <CompleteCardData>(toCopy.Cards);
 }
 public PokerGameRules(CompleteDeckData deck) : base(deck)
 {
 }
 public GameRulesBase(CompleteDeckData deck)
 {
     ProcessDeck(deck);
 }
 /// <summary>
 /// Processes the deck for metadata, like number of types of suits, number of cards, etc.
 /// </summary>
 /// <param name="deck">The deck to analyze</param>
 protected virtual void ProcessDeck(CompleteDeckData deck)
 {
 }