예제 #1
0
void Deck::initialiseDeck()
{
  cleanOutDeck();

  for(int x = CLUBS; x < max_suits; ++x)
  {
    Suit *suit = new Suit{static_cast<suits>(x)};
    suits_.insert(suit);
  }

  if(!deckOrder_.isEmpty()) deckOrder_.clear();

  QSet<Suit*>::iterator i = suits_.begin();
  while(i != suits_.end())
  {
    Suit* currentSuit = *i; ++i;
    Suit::cardContainer& cards = currentSuit->getCards();
    Suit::cardContainer::iterator j = cards.begin();

    while(j != cards.end())
    {
      Card* card = *j; ++j;
      QPair<suits,Card*> pair{currentSuit->getSuit(), card};
      deckOrder_.append(pair);
    }
  }
  cardCount_ = deckOrder_.count();
}
예제 #2
0
// 测试的main函数
int main()
	{
	using namespace std;

	cPerson xc(string("小菜"));

	Sneaker pqx;
	BigTrouser kk;
	TShirt dtx;

	dtx.Decorate(kk.Decorate(pqx.Decorate(&xc)));
	cout<<endl<<"第一种装扮:"<<dtx.Show()<<endl;

	LeatherShoes px;
	Tie ld;
	Suit xz;

	xz.Decorate(ld.Decorate(px.Decorate(&xc)));
	cout<<endl<<"第二种装扮:"<<xz.Show()<<endl;

	Sneaker pqx2;
	LeatherShoes px2;
	BigTrouser kk2;
	Tie ld2;
	ld2.Decorate(kk2.Decorate(px2.Decorate(pqx2.Decorate(&xc))));
	cout<<endl<<"第三种装扮:"<<ld2.Show()<<endl;

	return 0;
}
예제 #3
0
int CardSet::suitMask(const Suit& s) const
{
    return SMASK(s.code());
}
예제 #4
0
bool CardSet::contains(const Suit& s) const
{
    if (SMASK(s.code()) > 0)
        return true;
    return false;
}
예제 #5
0
Rank CardSet::flushRank(const Suit& s) const
{
    return Rank(topRankTable[SMASK(s.code())]);
}
예제 #6
0
size_t CardSet::count(const Suit& s) const
{
    return nRanksTable[SMASK(s.code())];
}
예제 #7
0
uint8_t Card::encode(Rank r, Suit s)
{
    return r.code() + s.code() * Rank::NUM_RANK;
}
예제 #8
0
	/**
	 * Returns whether the suit of the provided card is the same as this card.
	 *
	 * @param Card c The card to compare with this card
	 * @return bool
	 */
	bool sameSuit(Card c) {
		return c.suit.getValue() == suit.getValue();
	}
예제 #9
0
	/**
	 * Returns a string representation of the card.
	 *
	 * @return string
	 */
	string toString() {
		string s("");
		s += to_string(value);
		s += toupper(suit.getDisplay());
		return s;
	}