Example #1
0
Hand* OldMaid::createTrump()
{
  static Hand trump ;
  
  // 各スート53枚のカードを生成する
  for ( int number = 1 ; number <= 13 ; ++number )
  {
    trump.addCard( new Card( Card::SUIT_CLUB,    number ) ) ;
    trump.addCard( new Card( Card::SUIT_DIAMOND, number ) ) ;
    trump.addCard( new Card( Card::SUIT_HEART,   number ) ) ;
    trump.addCard( new Card( Card::SUIT_SPADE,   number ) ) ;
  }
  
  // ジョーカーの作成
  trump.addCard( new Card( Card::JOKER, 0 ) ) ;
  
  return &trump ;
}
Example #2
0
// 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
}