private static void ComputerDrawsOne(SuperCard[] computerHand, CardSet myDeck) { bool compFlush; compFlush = Flush(computerHand); SuperCard LowestValue = computerHand[0]; int sindex = 0; if (compFlush == false) { for (int index = 0; index < computerHand.Length; ++index) { if (computerHand[index].CardRank < LowestValue.CardRank) { LowestValue = computerHand[index]; sindex = index; } } if (Convert.ToInt32(LowestValue.CardRank) < 8) { computerHand[sindex] = myDeck.GetOneCard(); } } }
private static void ComputerDrawsOne(SuperCard[] computerHand, CardSet myDeck) { SuperCard lowestCard = computerHand[0]; if (Flush(computerHand)) { } else { int a = 0; for (int i = 1; i < computerHand.Length; i++) { if ((int)(computerHand[i].CardRank) < (int)(lowestCard.CardRank)) { lowestCard = computerHand[i]; a = i; } } if ((int)lowestCard.CardRank < 7) { computerHand[a] = myDeck.GetOneCard(); } } }
private static bool Flush(SuperCard[] hand) { SuperCard first = hand[0]; int count = 1; // Count the first card for (int card = 1; card < hand.Length; ++card) { if (first.Equals(hand[card])) { ++count; } } // If count matches hand's length, we've a flush return(count == hand.Length); }
public static bool Flush(SuperCard[] hand) // can be called passing in either //the players hand or the computers hand { bool flush = true; SuperCard firstCard = hand[0]; for (int i = 0; i < hand.Length; i++) { if (hand[i].CardSuit.Equals(firstCard.CardSuit)) { flush = true; } if (hand[i].CardSuit != firstCard.CardSuit) { flush = false; break; } } return(flush); }