本文整理汇总了C++中Card类的典型用法代码示例。如果您正苦于以下问题:C++ Card类的具体用法?C++ Card怎么用?C++ Card使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Card类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkCardPlayable
// Checks if the card is a legal card to be played
bool Player::checkCardPlayable(const Card* card, const std::vector<Card*> cardsOnTable) const {
// Seven of Spade
if(card->getRank() == SEVEN && card->getSuit() == SPADE) return true;
for(unsigned int index = 0; index < cardsOnTable.size(); index++){
Card* inGameCard = cardsOnTable[index];
//if the card is the same rank
if(card->getRank() == SEVEN) return true;
// If the card is the same suit but one rank below
if(card->getSuit() == inGameCard->getSuit() && card->getRank() == (inGameCard->getRank()-1)) return true;
// If the card is the same suit but one rank above
if(card->getSuit() == inGameCard->getSuit() && card->getRank() == (inGameCard->getRank()+1)) return true;
}
return false;
}
示例2: transfer
void Deposit_Card::transfer(Card& otherCard, const double money)
{
if (Deposit_Card::getBalance() < 0)
{
cout << "卡处于透支状态, 不能转出, 请充值" << endl;
return;
}
if (Deposit_Card::getBalance() < money)
{
cout << "卡里只有" << Deposit_Card::getBalance() << "元, 不足" << money << "元, 无法转账" << endl;
return;
}
Deposit_Card::setBalance(Deposit_Card::getBalance() - money);
otherCard.receiveMoney(money);
cout << "成功转给" << otherCard.getCardholderName() << " " << money << "元" << endl;
}
示例3: hasJack
Boolean Trick::hasJack() {
for ( CArray<PlayersCard*>::iterator i = book->BeginIterator() ;
i != book->EndIterator();
i++) {
Card *tmp = (*i)->c;
if ( tmp->Suit() == gManager->tbl->trump && tmp->Face() == Card::jack ) {
return true;
}
}
return false;
}
示例4: DrmObject
Property::Property(Card& card, uint32_t id)
: DrmObject(card, id, DRM_MODE_OBJECT_PROPERTY)
{
m_priv = new PropertyPriv();
m_priv->drm_prop = drmModeGetProperty(card.fd(), id);
m_name = m_priv->drm_prop->name;
}
示例5: Add_Card_no_empty
bool LayoutPiles::Add_Card_no_empty(int p, Card c) {
if(p >= 0 && p < 4) { //center piles
if(layout_piles[p].size()==0) {
return false;
}
else if(layout_piles[p].get_top_card().is_valid_move(c)) {
layout_piles[p].add_card(c);
return true;
}
}
else if(p >= 4 && p < 8) { //corner piles
if(layout_piles[p].size()==0 && c.get_rank() == 'K') {
layout_piles[p].add_card(c);
return true;
}
else if(layout_piles[p].size()==0) {
return false;
}
else if(layout_piles[p].get_top_card().is_valid_move(c)) {
layout_piles[p].add_card(c);
return true;
}
}
return false;
}
示例6: buildTower
void GameBoard::buildTower(Player& p, const Card& c, const BoardPosition& bp,int phase){
/*A player can build a tower at the current location of one of the player's pieces.
For building a tower, the player needs to play a cards with a number according to
the height of the tower and have enough blocks to build the tower.
The height of the tower is controlled by the phase of the game.
The player receives points corresponding to the number of blocks of the tower.
The player's piece is returned to the player's side of the board
(and can be re-added to the board in a future turn).
pays with the action card c for a tower to be build by the player on board position bp.
It will throw an exception illegalBuild if the tower cannot be built (invalid).
It must update a Player because of the construction.*/
int x=bp.x;
int y=bp.y;
if((((Piece*)myItem[x][y])->getName()==p.getInitial('x')))
{
if(p.increaseBlocks(0)>=phase&&c.getDistance()==phase+1)
{
p.decreaseBlocks(phase+1);
p.increasePoints(phase+1);
myItem[x][y]=new Tower(c);
p.addPiece();
}
else
throw myException("illegalBuild");
}
else
throw myException("illegalBuild");
};
示例7: Add_Card
bool LayoutPiles::Add_Card(int p, Card c) {
if(p >= 0 && p < 4) { //center piles
if(layout_piles[p].size()==0) {//if no card there
layout_piles[p].add_card(c);
return true;
}
else if(layout_piles[p].get_top_card().is_valid_move(c)) {//if valid move onto pile
layout_piles[p].add_card(c);
return true;
}
}
else if(p >= 4 && p < 8) { //corner piles
if(layout_piles[p].size()==0 && c.get_rank() == 'K') {//if adding a king to a corner pile
layout_piles[p].add_card(c);
return true;
}
else if(layout_piles[p].size()==0) {//can't add non kings to corners
return false;
}
else if(layout_piles[p].get_top_card().is_valid_move(c)) {//if valid move
layout_piles[p].add_card(c);
return true;
}
}
return false;
}
示例8: assert
void InterfaceDrawVisitor::DrawTableausInLine(std::vector<Tableau*>* tableaus,
const uint8_t& line) const
{
assert(tableaus);
for (auto tableau_it : *tableaus) {
Card* card = tableau_it->CardAt(line);
if(card) {
std::cout.width(6);
std::cout << std::right << card->ToShortString();
}
else {
std::cout.width(6);
std::cout << std::right << "";
}
}
}
示例9: return
bool Clock::checkAdd( int ci, const Pile *c1, const CardList& c2) const
{
Card *newone = c2.first();
if (ci == 0) {
if (c1->isEmpty())
return true;
return (newone->rank() == c1->top()->rank() - 1);
} else {
if (c1->top()->suit() != newone->suit())
return false;
if (c1->top()->rank() == Card::King)
return (newone->rank() == Card::Ace);
return (newone->rank() == c1->top()->rank() + 1);
}
}
示例10: main
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
QTextStream cout(stdout);
CardDeck deck;
CardHand *hand;
Card *aceCard = new Card(0, 0);
cout << "image to acecard: " << aceCard->getImage() << endl;
cout << "Deals to user 2 cards: " << flush;
hand = deck.deal(2);
cout << hand->toString() << endl;
cout << "value of deal: " << hand->getValue() << endl;
cout << "add ace card." << endl;
hand->append(aceCard);
cout << "now value of deal is: " << hand->getValue() <<endl;
return 0;
}
示例11: play
//
// Member Methods
//
// Post: Runs the game
void Dealer::play( )
{
deck_.shuffle();
for (short i = 0; i < game_->starting_hand(); ++i ) {
user_.take_card( deck_.deal( ) );
ai1_.take_card( deck_.deal( ) );
partner_.take_card( deck_.deal( ) );
ai2_.take_card( deck_.deal( ) );
}
Card trump = deck_.deal();
game_->trump( trump.suit() );
deck_.discard( trump );
print();
}
示例12: shuffle
// ---------------------------------------------------------------------------------
// shuffle - shuffles the deck
// Caller can specify the number of shuffles if more time shuffling is desired,
// but the results of a single shuffle should be sufficient.
// The default shuffle is 100 x deckSize_ random 2-card swaps
// ---------------------------------------------------------------------------------
void shuffle(unsigned int aNumberOfShuffles = 1)
{
// Seed the random number generator
srand((unsigned int)(time(NULL) & 0xFFFFFFFF));
for (unsigned int shuffleCount = 0; shuffleCount < aNumberOfShuffles; ++shuffleCount)
{
// Considering the deck size, perform 100x passes
// through a random selection of 2-card swaps
for (unsigned int passCount = 0; passCount < 100; ++passCount)
{
for (unsigned int cardCount = 0; cardCount < deckSize_; ++cardCount)
{
unsigned int indexA = rand() % deckSize_;
unsigned int indexB = rand() % deckSize_;
// Put card A before card B
ppCards_[indexB]->insertBefore(ppCards_[indexA]);
}
}
}
pTopOfDeck_ = pTopOfDeck_->getFirst();
}
示例13: OnActionPhase
void TributeCard::OnActionPhase( Engine* pEngine )
{
Player* pPlayer = pEngine->GetCurrentPlayer();
Player* pPlayerToLeft = pEngine->GetNextPlayer( pPlayer );
CardList cardsDrawnList =
pPlayerToLeft->RevealCardsFromDeck( 2 );
CardListIter cardIter;
Card* pFirstCard = *cardIter;
if( pFirstCard->IsActionCard() )
{
pPlayer->PlusActions( 2 );
}
if( pFirstCard->IsTreasureCard() )
{
pPlayer->PlusCoins( 2 );
}
if( pFirstCard->IsVictoryCard() )
{
pPlayer->DrawCardsToHand( 2 );
}
cardIter++;
Card* pSecondCard = *cardIter;
if( pSecondCard->CardId() != pFirstCard->CardId() )
{
if( pSecondCard->IsActionCard() )
{
pPlayer->PlusActions( 2 );
}
if( pSecondCard->IsTreasureCard() )
{
pPlayer->PlusCoins( 2 );
}
if( pSecondCard->IsVictoryCard() )
{
pPlayer->DrawCardsToHand( 2 );
}
}
}
示例14:
bool operator!=(Card & c1, Card & c2){
bool sameColor = (c1.get_color()==c2.get_color());
bool sameShading = (c1.get_shading() == c2.get_shading());
bool sameShape = (c1.get_shape() == c2.get_shape());
bool sameNumber = (c1.get_number() == c2.get_number());
return !(sameColor && sameShading && sameShape && sameNumber);
}
示例15: qDebug
/* Return the split card to be moved and reduced the current hand value */
const Card Box::MoveSplitCard()
{
Card TempCard;
TempCard = Hand.at(1);
qDebug() << "TempCard = " << TempCard.GetName() << " (" << TempCard.GetValue() << ") of " << TempCard.GetSuit();
HandValue -= Hand.at(1).GetValue();
Hand.pop_back();
/* AcesHeld must be reassessed after a split */
string CompareString = Hand.front().GetName();
if (CompareString.compare("Ace") == 0)
{
AcesHeld = 1;
HandValue = 11;
}
return TempCard;
}