Пример #1
0
        public void calculateStatistics()
        {
            int total = 2000;
            int count = 0;

            for (int j = 0; j < 2000; j++)
            {
                List<List<string>> hands = new List<List<string>>();
                Deck deck = new Deck();
                deleteDeadCard(deck);
                deleteUserCards(deck);
                deck.shuffle();

                for (int i = 0; i < playerUsernames.Count; i++) //only deal one card if corresponding user only has one card.
                {
                    List<Card> tempHand = new List<Card>();
                    List<string> stringHand = new List<string>();
                    if(playerCardCounts[i] == 0)
                    {
                        deck.dealHand(tempHand, 2); //doing 2 here cause if player has no cards the will automatically by marked as true so it won't mess up the numbers
                        //translate to a list of strings

                        stringHand.Add(tempHand[0].getCardType());
                        stringHand.Add(tempHand[1].getCardType());
                        hands.Add(stringHand);
                    }
                    else if(playerCardCounts[i] == 1)
                    {
                        deck.dealHand(tempHand, 1);
                        //translate to a list of strings

                        stringHand.Add(tempHand[0].getCardType());
                        hands.Add(stringHand);
                    }
                    else if (playerCardCounts[i] == 2)
                    {
                        deck.dealHand(tempHand, 2);
                        //translate to a list of strings

                        stringHand.Add(tempHand[0].getCardType());
                        stringHand.Add(tempHand[1].getCardType());
                        hands.Add(stringHand);
                    }
                }

                if(checkIfCardsMatch(hands))
                {
                    count++;
                }
            }

            Globals.Stats = ((float)count / (float)total) * 100.0f;
        }
Пример #2
0
 private void deleteDeadCard(Deck d)
 {
     foreach(Card c in getDeadCards())
     {
         foreach(Card c1 in d.getCards())
         {
             if(c.getCardType() == c1.getCardType())
             {
                 d.getCards().Remove(c1);
                 break;
             }
         }
     }
 }
Пример #3
0
 private void deleteUserCards(Deck d)
 {
     foreach(Card c in getCardsInHand())
     {
         foreach(Card c1 in d.getCards())
         {
             if(c.getCardType() == c1.getCardType())
             {
                 d.getCards().Remove(c1);
                 break;
             }
         }
     }
 }
Пример #4
0
        public void calculateStatistics()
        {
            int total = 2000;
            int count = 0;

            for (int j = 0; j < 2000; j++)
            {
                List<List<string>> hands = new List<List<string>>();
                Deck deck = new Deck();
                deleteDeadCard(deck);
                deleteUserCards(deck);
                deck.shuffle();

                for (int i = 0; i < playerUsernames.Count; i++) //only deal one card if corresponding user only has one card.
                {
                    List<Card> tempHand = new List<Card>();
                    deck.dealHand(tempHand);
                    //translate to a list of strings
                    List<string> stringHand = new List<string>();
                    stringHand.Add(tempHand[0].getCardType());
                    stringHand.Add(tempHand[1].getCardType());
                    hands.Add(stringHand);
                }

                if(checkIfCardsMatch(hands))
                {
                    count++;
                }
            }

            Globals.Stats = ((float)count / (float)total) * 100.0f;
        }