//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); }
public Card CompAttackSameCardValue(CompHand ch, Card c) { Card atckCard = new Card(); for (int i = 0; i < ch.NumCards; i++) { if (cards[i].HasMatchingValue(c)) { atckCard = cards[i]; cards.Remove(atckCard); } else { atckCard = null; } } return(atckCard); }
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); }