Пример #1
0
        public Card DefendWithSpecifiedCard(int index, Card c) //NEEDS TESTING
        {
            Card c1 = cards[index];

            if (c1.HasMatchingSuit(c) && c1.Value > c.Value ||
                (c1.HasMatchingSuit(c) && c1.Value == 1 && c.Value != 1))
            {
                cards.Remove(c1);
                return(c1);
            }
            return(null);
        }
Пример #2
0
        public bool CanDefendWithSpecificCard(Card attkCard, Card defCard, Card trump) //checking if a plyer-chosen card can beat the attacking card
        {
            bool canDefend = false;

            if ((defCard.HasMatchingSuit(attkCard) && defCard.Value > attkCard.Value) ||
                defCard.HasMatchingSuit(trump) && attkCard.Suit != trump.Suit ||
                defCard.HasMatchingSuit(attkCard) && defCard.Value == 1 && attkCard.Value != 1)
            {
                canDefend = true;
            }

            return(canDefend);
        }
Пример #3
0
        public Card Defend(FoolHand fh, Card c, Card tc) //NEEDS TESTING
        {
            Card c1 = new Card();

            for (int i = 0; i < fh.NumCards; i++)
            {
                c1 = cards[i];
                if ((c1.HasMatchingSuit(c) && c1.Value > c.Value && c.Value != 1) ||
                    (c1.HasMatchingSuit(c) && c1.Value == 1 && c.Value != 1) ||
                    (c1.HasMatchingSuit(tc) && c.Suit != tc.Suit) ||
                    (c1.HasMatchingSuit(tc) && c.HasMatchingSuit(tc) && (c1.Value > c.Value)))
                {
                    cards.Remove(c1);
                    return(c1);
                }
            }
            return(null);
        }
Пример #4
0
        public Card CompDefend(CompHand ch, Card c, Card tc) //SAME SUIT CARD BEATS ACE BECAUSE ACE IS OF VALUE '1' -- THATS NOT RIGHT, NEEDS CHANGING
        {
            Card c1 = new Card();

            for (int i = 0; i < ch.NumCards; i++)
            {
                c1 = cards[i];
                if ((c1.HasMatchingSuit(c) && c1.Value > c.Value) ||
                    (c1.HasMatchingSuit(c) && c1.Value == 1 && c.Value != 1) ||
                    (c1.HasMatchingSuit(tc) && c.Suit != tc.Suit) ||
                    (c1.HasMatchingSuit(tc) && c.HasMatchingSuit(tc) && (c1.Value > c.Value ||
                                                                         (c1.HasMatchingSuit(c) && c1.Value == 1 && c.Value != 1))))
                {
                    cards.Remove(c1);
                    return(c1);
                }
            }
            return(null);
        }
Пример #5
0
        //attack with any VALUE displayed within the PlayHand

        public CompHand CompSortCards(CompHand ch, Card tc)
        {
            List <Card> cards2 = new List <Card>(); //helper list for sorting trump cards
            CompHand    ch1    = new CompHand();

            cards.Sort();

            for (int i = 0; i < ch.NumCards; i++) //placing all Aces to the bottom of the hand
            {
                Card c = cards[0];
                if (c.Value == 1)
                {
                    cards.Remove(c);
                    cards.Add(c);
                }
            }

            for (int i = 0; i < cards.Count; i++)
            {
                Card c = cards[i];
                if (!c.HasMatchingSuit(tc))
                {
                    cards2.Add(c);
                }
            }

            for (int i = 0; i < cards.Count; i++)
            {
                Card c = cards[i];
                if (c.HasMatchingSuit(tc))
                {
                    cards2.Add(c);
                }
            }

            cards.Clear();

            for (int i = 0; i < cards2.Count; i++)
            {
                Card c = cards2[i];
                cards.Add(c);
                ch1.AddCard(c);
            }

            return(ch1);
        }