本文整理汇总了C++中CardList类的典型用法代码示例。如果您正苦于以下问题:C++ CardList类的具体用法?C++ CardList怎么用?C++ CardList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CardList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deal
void Kings::deal() {
CardList cards = deck->cards();
CardList::Iterator it = cards.begin();
int cn = 0;
for (int stack = -1; stack < 8; )
{
while (it != cards.end() && (*it)->rank() != Card::King) {
if (stack >= 0) {
store[stack]->add(*it, false, true);
cn++;
}
++it;
}
if (it == cards.end())
break;
cn++;
store[++stack]->add(*it, false, true);
if (stack == 0) {
cards = deck->cards(); // reset to start
it = cards.begin();
} else
++it;
}
assert(cn == 104);
}
示例2: main
void main()
{
BeastCubeManager beastCube;
for(CubeID cube : CubeSet::connected())
{
//LOG("###---Player %i---\n", cube);
CardList c = (CardFactory::getCards(2));
for(int i = 0; i < c.count(); i++)
{
LOG("###%i %i\n", c[i].type, c[i].power);
}
Card beastCards[] = {c.pop_back(), c.pop_back()};
Beast m = BeastFactory::createBeast(beastCards, 2);
LOG("###Player %i beast\nType: %i\nAttack:%i\nHealth:%i\nResolve:%i\nAnger:%i\n\n",
-1, m.type, m.attack, m.health, m.resolve, m.anger);
beastCube.init(cube, m);
}
while(1)
System::paint();
}
示例3: childrenWithTag
void Card::removeChildrenWithTag(Tag *tag)
{
CardList *children = childrenWithTag(tag);
for (CardList::iterator cardIter = children->begin(); cardIter != children->end(); cardIter++) {
Card *child = *cardIter;
if (child->parent != NULL) {
child->parent->remove(child);
}
}
delete children;
}
示例4: legalMoves
// Discards the given card
void Role::discardCard(const Card& card) {
const CardList legalCards = legalMoves(); // Gets the cards which are legal to play
// Determines whether the user is in a situation that they had to discard, if not throws exception
if(legalCards.size() != 0) {
throw IllegalDiscardException();
}
// Removes card from hand, and adds to discard pile
const Card* deletedCard = player_->hand_.remove(card);
player_->discards_.add(deletedCard);
triggerPlayerUpdate(true);
}
示例5: OnCleanUpPhase
void TalismanCard::OnCleanUpPhase( Engine* pEngine )
{
Player* pPlayer = pEngine->GetCurrentPlayer();
CardList buyList = pPlayer->GetBuyList();
for( CardListIter iter = buyList.begin();
iter != buyList.end();
iter++ )
{
if( !(*iter)->IsVictoryCard() )
{
pPlayer->GainCardOnDiscard( (*iter) );
}
}
}
示例6: dealPlayerHand
// returns a vector of 13 cards for a player to use
CardList Deck::dealPlayerHand() {
CardList hand;
// grab next 13 cards and copy them to hand vector
for (int i = 0; i < HAND_SIZE; i++) {
int index = CARD_COUNT - cards_left_ + i;
if (index >= 0) {
hand.add(cards_[index]);
}
}
// mark those 13 cards as used
cards_left_ -= HAND_SIZE;
return hand;
}
示例7: ToCardList
CardList Cards::ToCardList(SortType sorttype)const
{
CardList cardlist;
for(QSet<Card>::ConstIterator it=m_cards.begin();it!=m_cards.end();it++)
{
cardlist<<*it;
}
if(sorttype==Asc)
{
qSort(cardlist.begin(),cardlist.end(),qLess<Card>());
}
if(sorttype==Desc)
{
qSort(cardlist.begin(),cardlist.end(),qGreater<Card>());
}
return cardlist;
}
示例8: redeal
// Add cards from pile to deck, in reverse direction
void Klondike::redeal() {
CardList pilecards = pile->cards();
if (EasyRules)
// the remaining cards in deck should be on top
// of the new deck
pilecards += deck->cards();
for (int count = pilecards.count() - 1; count >= 0; --count)
{
Card *card = pilecards[count];
card->setAnimated(false);
deck->add(card, true, false); // facedown, nospread
}
redealt = true;
}
示例9: checkAdd
bool Fortyeight::checkAdd(int, const Pile *c1, const CardList &c2) const
{
if (c1->isEmpty())
return true;
// ok if in sequence, same suit
return (c1->top()->suit() == c2.first()->suit())
&& (c1->top()->rank() == (c2.first()->rank()+1));
}
示例10: OnActionPhase
void CellarCard::OnActionPhase( Engine* pEngine )
{
Player* pPlayer = pEngine->GetCurrentPlayer();
IAI* pAI = pPlayer->GetAI();
CardList cardsToDiscard;
cardsToDiscard = pAI->OnCellar();
if( pPlayer->AreCardsInHand( cardsToDiscard ) )
{
pPlayer->DiscardFromHand( cardsToDiscard );
pPlayer->DrawCardsToHand( cardsToDiscard.size() );
}
else
{
// TODO: Add error
throw std::wstring( L"Error: CellarCard::OnActionPhase()" );
}
}
示例11:
int CardList::operator==(CardList& list){
if(this->length() != list.length()){
return 0;
}
for(int i=0;i<this->length();i++){
if((*this)[i] != list[i]){
return 0;
}
}
return 1;
}
示例12: Q_ASSERT
void GameLogDialog::showDeal(const int row)
{
Q_ASSERT(row < model->gameLog().size());
QString output;
for (int i=1; i<=3; i++)
{
output += QString("%1: ").arg(model->player(i)->nick());
CardList cl;
foreach(const Card& c, model->gameLog().at(row).cardList[i-1])
cl.insert(const_cast<Card*>(&c));
cl.mySort();
for( int ci = 0; ci < cl.count(); ci++ )
{
output += cl.at(ci)->toUniString();
output += ' ';
}
output += '\n';
}
QMessageBox::about(0, tr("Deal #") + QString::number(row + 1), output);
}
示例13: checkAdd
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);
}
}
示例14: CardList
CardList *Card::childrenWithTag(Tag *tag)
{
CardList *matches = new CardList();
for(CardList::iterator iter = attached.begin(); iter != attached.end(); iter++) {
Card *child = *iter;
if (child->match(tag) != NULL) {
if (rand()%2 == 0)
matches->push_back(child);
else
matches->push_front(child);
}
if (child != this) {
CardList *childMatches = child->childrenWithTag(tag);
for(CardList::iterator childIter = childMatches->begin(); childIter != childMatches->end(); childIter++) {
matches->push_back(*childIter);
}
delete childMatches;
}
}
return matches;
}
示例15: kdDebug
bool Klondike::isGameLost() const
{
kdDebug( 11111 ) << "Is the game lost?" << endl;
if (!deck->isEmpty()) {
kdDebug( 11111 ) << "We should only check this when the deck is exhausted." << endl;
return false;
}
// Check whether top of the pile can be added to any of the target piles.
if ( !pile->isEmpty() ) {
for ( int i = 0; i < 4; ++i ) {
if ( target[ i ]->isEmpty() ) {
continue;
}
if ( pile->top()->suit() == target[ i ]->top()->suit() &&
pile->top()->rank() - 1 == target[ i ]->top()->rank() ) {
kdDebug( 11111 ) << "No, the source pile's top card could be added to target pile " << i << endl;
return false;
}
}
}
// Create a card list - srcPileCards - that contains all accessible
// cards in the pile and the deck.
CardList srcPileCards;
if ( EasyRules ) {
srcPileCards = pile->cards();
} else {
/* In the draw3 mode, not every card in the source pile is
* accessible, but only every third one.
*/
for ( unsigned int i = 2; i < pile->cards().count(); i += 3 ) {
kdDebug( 11111 ) << "Found card "<< pile->cards()[i]->name()<< endl;
srcPileCards += pile->cards()[ i ];
}
if ( !pile->cards().isEmpty() && pile->cards().count() % 3 != 0 ) {
kdDebug( 11111 ) << "Found last card "<< pile->cards()[pile->cards().count() - 1]->name()<< endl;
srcPileCards += pile->cards()[ pile->cards().count() - 1 ];
}
}
// Check all seven stores
for ( int i = 0; i < 7; ++i ) {
// If this store is empty...
if ( play[ i ]->isEmpty() ) {
// ...check whether the pile contains a king we could move here.
CardList::ConstIterator it = srcPileCards.begin();
CardList::ConstIterator end = srcPileCards.end();
for ( ; it != end; ++it ) {
if ( ( *it )->rank() == Card::King ) {
kdDebug( 11111 ) << "No, the pile contains a king which we could move onto store " << i << endl;
return false;
}
}
// ...check whether any of the other stores contains a (visible)
// king we could move here.
for ( int j = 0; j < 7; ++j ) {
if ( j == i || play[ j ]->isEmpty() ) {
continue;
}
const CardList cards = play[ j ]->cards();
CardList::ConstIterator it = ++cards.begin();
CardList::ConstIterator end = cards.end();
for ( ; it != end; ++it ) {
if ( ( *it )->realFace() && ( *it )->rank() == Card::King ) {
kdDebug( 11111 ) << "No, store " << j << " contains a visible king which we could move onto store " << i << endl;
return false;
}
}
}
} else { // This store is not empty...
Card *topCard = play[ i ]->top();
// ...check whether the top card is an Ace (we can start a target)
if ( topCard->rank() == Card::Ace ) {
kdDebug( 11111 ) << "No, store " << i << " has an Ace, we could start a target pile." << endl;
return false;
}
// ...check whether the top card can be added to any target pile
for ( int targetIdx = 0; targetIdx < 4; ++targetIdx ) {
if ( target[ targetIdx ]->isEmpty() ) {
continue;
}
if ( target[ targetIdx ]->top()->suit() == topCard->suit() &&
target[ targetIdx ]->top()->rank() == topCard->rank() - 1 ) {
kdDebug( 11111 ) << "No, store " << i << "'s top card could be added to target pile " << targetIdx << endl;
return false;
}
}
// ...check whether the source pile contains a card which can be
// put onto this store.
CardList::ConstIterator it = srcPileCards.begin();
CardList::ConstIterator end = srcPileCards.end();
for ( ; it != end; ++it ) {
if ( ( *it )->isRed() != topCard->isRed() &&
//.........这里部分代码省略.........