bool Dealer::accept(CardSet & opened) { Card openedRank; if (discarded.isEmpty() && opened.isEmpty() ) return false; // regarded as "pass for empty discard pile." if (!discarded.isEmpty() && discarded.size() != opened.size()) // the number of cards must be match. no five cards w/ Jkr allowed. return false; if (!checkRankUniqueness(opened)) return false; openedRank = getCardRank(opened); if (!discarded.isEmpty()) // 場にカードがでていないのであれば無条件に受理 if (!openedRank.isGreaterThan(discardedRank)) return false; // passed all the checks. discarded.makeEmpty(); //clear(); discarded.insert(opened); // discarded.insertAll(opened); opened.makeEmpty(); //clear(); discardedRank=openedRank; return true; }
/* createDeck function which creates a full deck. */ struct deck createDeck() { /* Create an array of char pointers to the Unix suits. */ char *suits[NUMBER_OF_SUITS] = {SPADE, CLUB, HEART, DIAMOND}; int forSuits, forNum, counter = 0; struct deck theDeck; //theDeck.deckOfCards[CARD_TOTAL].index[CARD_TOTAL]; for (forSuits = 0; forSuits < NUMBER_OF_SUITS; ++forSuits) { for (forNum = 1; forNum <= NUMBER_OF_VALUES; ++forNum) { theDeck.deckOfCards[counter].suit = suits[forSuits]; theDeck.deckOfCards[counter].rank = getCardRank(forNum); //theDeck.deckOfCards[counter].index = counter; counter++; } printf("\n"); } return theDeck; }