void AddCardsToDeck (cardSet** deck, cardType ct, int count) { if(ct < MAX_CARD_TYPES) { if (count > 0 && count <= MAX_CARDS_PER_SET) { if ((GetNumCards(deck[ct]) + count) <= MAX_CARDS_PER_SET) { AddCards(deck[ct], count); } } } }
int RemoveCardsFromDeck (cardSet** deck, cardType ct) { int countRemoved = 0; if(ct < MAX_CARD_TYPES) { countRemoved = GetNumCards(deck[ct]); RemoveCards(deck[ct],countRemoved); } return countRemoved; }
int DeckHasType (cardSet** deck, cardType ct) { int hasType = 0; if(ct < MAX_CARD_TYPES) { if(GetNumCards(deck[ct]) > 0) { hasType = 1; } } return hasType; }
cardType GetRandomCardFromDeck(cardSet** deck) { cardType randType = 0; do { randType = rand() % MAX_CARD_TYPES; } while (GetNumCards(deck[randType]) <= 0); RemoveCards(deck[randType],1); return randType; }
void Player::Sort() { Card temp; const int numcards = GetNumCards(); Card* CardArr = new Card[GetNumCards()]; for (int i = GetNumCards() - 1; GetNumCards(); i--) { Discard(i, CardArr[i]); } for (int i = 0; i < numcards; i++) { for (int j = 1; j < numcards; j++) { if (CardArr[j].GetSuit() < CardArr[j - 1].GetSuit()) { temp = CardArr[j]; CardArr[j] = CardArr[j - 1]; CardArr[j - 1] = temp; } } } for (int i = 0; i < numcards; i++) { for (int j = 1; j < numcards; j++) { if (CardArr[j].GetFace() < CardArr[j - 1].GetFace()) { if (CardArr[j].GetSuit() == CardArr[j - 1].GetSuit()) { temp = CardArr[j]; CardArr[j] = CardArr[j - 1]; CardArr[j - 1] = temp; } } } } for (int i = 0; i < numcards; i++) { AddCard(CardArr[i]); } delete[] CardArr; }
void PrintDeck (cardSet **deck) { for(cardType i = 0; i < MAX_CARD_TYPES; i++) { printf("%d %ss\n", GetNumCards(deck[i]), GetCardName(deck[i])); } }