/* Display a single card. */ void displayCard(Card card){ int i; int nameLength; char *suit = suitName(card.suit); char *rank = rankName(card.rank); nameLength = strlen(suit) + strlen(rank) + 4; /* print spaces to right align */ printSpaces(MAX_CARD_NAME - nameLength); /* print card */ printf("%s OF %s", rank, suit); }
/// \brief /// Decides what bid for the player to make depending on their hand strength and shape values. /// /// \return string - the bid that the player should make. string Hand::makeBid() { int longestNum = calculateLongestSuit(); bool handBalanced = calculateShape(); if (!handBalanced) { if (handStrength <= 12) { switch(longestNum) { case 6: // Bid highest suit if there are two suits of size 6 if (longestSuit.size() == 2) { bid = "2" + suitName(longestSuit.back()); break; } // Passes if clubs suit is of size 6 if (longestSuit.front() == 0) { bid = "PASS"; break; } bid = "2" + suitName(longestSuit.front()); break; case 7: bid = "3" + suitName(longestSuit.front()); break; case 8: bid = "4" + suitName(longestSuit.front()); break; default: bid = "PASS"; break; } } else if (handStrength <= 21) { // Bid the longest suit if (longestSuit.size() == 1) { bid = "1" + suitName(longestSuit.front()); } // Bids highest suit if two suits have a size of four or lowest // suit if two suits have a size of 5 or more. else { if (longestNum == 4) { bid = "1" + suitName(longestSuit.front()); } else { bid = "1" + suitName(longestSuit.back()); } } } else { bid = "2C"; } } else { if (handStrength <= 12) { bid = "PASS"; } else if (handStrength <= 14) { bidMinorSuit(); } else if (handStrength <= 17) { bid = "1NT"; } else if (handStrength <= 19) { bidMinorSuit(); } else if (handStrength <= 21) { bid = "2NT"; } else { bid = "2C"; } } return bid; }