Ejemplo n.º 1
0
        public void TakeBestCards(List <Card> tablecards)
        {
            List <Card> allcards = new List <Card>(7);

            allcards.AddRange(tablecards);
            allcards.AddRange(hand);

            if (tablecards.Count > 3)
            {
                Combination buffer;

                if (allcards.Count == 6)
                {
                    buffer = new Combination();
                    for (int i = 0; i < 5; i++)
                    {
                        buffer.InsertCard(allcards[i]);
                    }
                    buffer = buffer.ImproveIfPossible(allcards[5]);
                    cards.CleanCombination();
                    cards.InsertCard(buffer.GetCards());
                    buffer = null;
                }
                else
                {
                    Combination strongest = new Combination(cards.GetCards());
                    int         j         = 1;
                    for (int i = 0; i < allcards.Count - 1; i++)
                    {
                        while (i + j < allcards.Count)
                        {
                            buffer = new Combination();
                            for (int k = 0; k < allcards.Count; k++)
                            {
                                if ((k != i) && (k != j))
                                {
                                    buffer.InsertCard(allcards[k]);
                                }
                            }
                            if (Combination.Compare(buffer, strongest) > 0)
                            {
                                strongest.CleanCombination();
                                strongest.InsertCard(buffer.GetCards());
                            }
                            buffer = null;
                            j++;
                        }
                    }
                    List <Card> leftcards = new List <Card>();
                    foreach (Card c in allcards)
                    {
                        if (!strongest.GetCards().Contains(c))
                        {
                            leftcards.Add(c);
                        }
                    }
                    strongest = strongest.ImproveIfPossible(leftcards[0]);
                    strongest = strongest.ImproveIfPossible(leftcards[1]);
                    cards.InsertCard(strongest.GetCards());
                }
            }
            else
            {
                List <Card> buffer = new List <Card>(5);
                buffer = cards.GetCards();
                for (int i = 0; i < allcards.Count; i++)
                {
                    if (!buffer.Contains(allcards[i]))
                    {
                        cards.InsertCard(allcards[i]);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void foldcards()
 {
     cards.CleanCombination();
     hand.Clear();
 }