// // Can only drop a card onto a suit-stack if the // card is 1 higher, and is the same suit // bool CanDrop(CardRegion &stackobj, Card card) { TRACE("ENTER CanDrop()\n"); int topval; const CardStack &cardstack = stackobj.GetCardStack(); if(cardstack.NumCards() > 0) { if(card.Suit() != cardstack[0].Suit()) { TRACE("EXIT CanDrop()\n"); return false; } topval = cardstack[0].LoVal(); } else { topval = 0; } //make sure 1 higher if(card.LoVal() != (topval + 1)) { TRACE("EXIT CanDrop()\n"); return false; } TRACE("EXIT CanDrop()\n"); return true; }
/* Cards dropped to a stack */ bool CARDLIBPROC StackDropProc(CardRegion &stackobj, CardStack &dragcards) { Card dragcard = dragcards[dragcards.NumCards() - 1]; int faceup, facedown; /* Only drop our cards on other stacks */ if (stackobj.Id() == from->Id()) { return false; } /* If stack is empty, everything can be dropped */ if (stackobj.NumCards() != 0) { const CardStack &mystack = stackobj.GetCardStack(); /* Can only drop if card is 1 less */ if (mystack[0].LoVal() != dragcard.LoVal() + 1) { return false; } /* Check if stack complete */ stackobj.GetFaceDirection(&facedown); faceup = stackobj.NumCards() - facedown; if (faceup + dragcards.NumCards() >= NUM_ONECOLOR_CARDS) { int i, max = NUM_ONECOLOR_CARDS - dragcards.NumCards() - 1; /* Dragged cards have been checked to be in order, check stack cards */ if (mystack[0].Suit() == dragcard.Suit() && stackLookingGood(mystack, max)) { CardStack s = stackobj.GetCardStack(); CardStack f; /* Remove from card stack */ for (i = 0; i < max + 1; i++) { s.RemoveCard(0); } /* Remove dragged cards */ dragcards = f; stackobj.SetCardStack(s); cardsFinished += NUM_ONECOLOR_CARDS; /* Flip top card of the dest stack */ TurnStackCard(stackobj); } } } /* Flip the top card of the source stack */ TurnStackCard(*from); fGameStarted = true; return true; }
int Hand::ConvertCardToPokerEvalCard(const Card& card) const { int rank, suit; // We must convert our hand from our format (8-bit): // | 7 6 5 4 3 2 1 0 | // | rank | suit | // // to the poker-eval format (16-bit) // (rank*4)+suit // rank = card.Rank()-2; suit = card.Suit() == Card::CLUBS ? StdDeck_Suit_CLUBS : card.Suit() == Card::DIAMONDS ? StdDeck_Suit_DIAMONDS : card.Suit() == Card::HEARTS ? StdDeck_Suit_HEARTS : card.Suit() == Card::SPADES ? StdDeck_Suit_SPADES : 0; return (StdDeck_MAKE_CARD(rank, suit)); }
bool PlayingCards::HasCard(const Card &cCardInQuestion) const { for (const Card &cCard : m_vCards) { if (cCard.Suit() == cCardInQuestion.Suit() && cCard.Rank() == cCardInQuestion.Rank()) { return true; } } return false; }
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; }
Card PlayingCards::RemoveCard(const Card &cCard) { return RemoveCard(cCard.Rank(), cCard.Suit()); }