// Check for legal plays a player have // A legal play is: // - Card in player's hand // - 7 of anything // - Card with the same suit and adjecent rank as any card on board Hand Player::getLegalPlays (const Deck& deck, const Board& board) const { Hand hand; for (int i=0; i<deck.size(); i++) { Card temp = deck.cardAt(i); if (currentHand_.hasCard(temp)){ // Check if player has card if (board.isLegalPlay(temp)){ // Check if it's a legal play in the board hand.addCard(temp); // Add card to possible legal plays } } } return hand; // Return legal plays }
// distribute the deck's cards to players void Model::dealCardsToPlayers() { Deck* deck = this->deck(); Card startingCard{SPADE, SEVEN}; for (int i = 0; i < 4; i++) { for (int j = 13 * i; j < 13 * (i + 1); j++) { Card& card = deck->cardAt(j); // we're figuring out which person should go first if (card == startingCard) { this->activePlayerId(i); } this->players_.at(i)->takeCard(&card); } } }