当前位置: 首页>>代码示例>>C++>>正文


C++ CCard::IsValid方法代码示例

本文整理汇总了C++中CCard::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ CCard::IsValid方法的具体用法?C++ CCard::IsValid怎么用?C++ CCard::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCard的用法示例。


在下文中一共展示了CCard::IsValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PlayFourth

//
// PlayFourth()
//
// default implementation
//
CCard* CPlayEngine::PlayFourth()
{
	CPlayerStatusDialog& status = *m_pStatusDlg;
	status << "5PLAY4! Playing fourth, using default player logic.\n";

	// use common code
	CCard* pCard = PlayBestCard(4);
	//
	ASSERT(pCard->IsValid());
	return pCard;
}
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:16,代码来源:PlayEngine.cpp

示例2: Wizard

/* takes top card from the slot and movies it (if possible) to the foundation */
void CTable::Wizard()
{

	CBuffer buffer;
	CCard	tmp;

	CSlot* slot = NULL;

	if( hand.GetCardsStored() ) return;


	unsigned char prev_slot = act_slot;

	switch( act_slot )
	{
	case BLOCK : this->DoAction(); break;
	case WASTEPILE : slot = &wastepile;	break;
	case FOUNDATION1 :  slot = &foundation[0]; break;
	case FOUNDATION2 :  slot = &foundation[1]; break;
	case FOUNDATION3 :  slot = &foundation[2]; break;
	case FOUNDATION4 :  slot = &foundation[3]; break;
	case TABLEAU1 :	slot = &tableau[0]; break;
	case TABLEAU2 :	slot = &tableau[1]; break;
	case TABLEAU3 :	slot = &tableau[2]; break;
	case TABLEAU4 :	slot = &tableau[3]; break;
	case TABLEAU5 :	slot = &tableau[4]; break;
	case TABLEAU6 :	slot = &tableau[5]; break;
	case TABLEAU7 :	slot = &tableau[6]; break;
	}

	if( slot )
	{
		tmp = slot->PeekCard();

		if( false == tmp.IsValid() ) return;

		for( unsigned char i = 0; i < 4; i++ )
		{
			if( foundation[i].PushCard( tmp ) )
			{
				changed[ FOUNDATION1 + i ] = true;
				changed[ prev_slot ] = true;

				slot->PopCard();

				CheckWin( true );

				return;
			}
		}
	}
}
开发者ID:Aristotong,项目名称:neutrino-mp-plugins-max,代码行数:53,代码来源:Table.cpp

示例3: PlayCard

//
// PlayCard()
//
// default implementation
//
CCard* CPlayEngine::PlayCard()
{
	int nOrdinal = pDOC->GetNumCardsPlayedInRound();
	CCard* pCard = NULL;
	switch(nOrdinal)
	{
		case 0:
			pCard =  PlayFirst();
			break;
		case 1:
			pCard =  PlaySecond();
			break;
		case 2:
			pCard =  PlayThird();
			break;
		case 3:
			pCard =  PlayFourth();
			break;
		default:
			pCard = NULL;
	}
	// do some sanity checks
	ASSERT(pCard->IsValid());
	if (!m_pPlayer->IsDeclarer())
	{
		// playing as defender (or dummy, potentially)
		ASSERT(m_pHand->HasCard(pCard));
	}
	else
	{
		// declarer  -- may be playing for dummy or self
		if (pDOC->GetCurrentPlayer() == m_pPartner)
			ASSERT(m_pPartnersHand->HasCard(pCard));
		else
			ASSERT(m_pHand->HasCard(pCard));
	}
	//
	return pCard;
}
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:44,代码来源:PlayEngine.cpp

示例4: PlayBestCard


//.........这里部分代码省略.........
					// high enuff to beat dummy
					if ((nCurrentSeat == 3) && (m_bLHDefender))
					{
						CSuitHoldings& dummySuit = GetDummySuit(nSuitLed);
						int nDummyTopCard = 0;
						if (dummySuit.GetNumCards() > 0)
							nDummyTopCard = dummySuit[0]->GetFaceValue();
						int nTopVal = Max(nDummyTopCard, pCurrTopCard->GetFaceValue());
						pCard = suit.GetLowestCardAbove(nTopVal);
						// see if we can beat the top card or dummy's top card
						if (pCard)
						{
							if (nTopVal == nDummyTopCard)
							{
								// dummy has the top card and we can beat it
								status << "PLAYB38A! Playing third ahead of dummy, need to beat dummy's " & 
										  CardValToString(nDummyTopCard) & ".\n";
							}
							else
							{
								// the top card is declarer's
								status << "PLAYB38B! Play high to win with the " & pCard->GetFaceName() & ".\n";
							}
						}
						else
						{
							// else we can't beat dummy's top card, but play
							// high anyway to force out his winner
							pCard = suit.GetLowestCardAbove(pCurrTopCard);
							status << "PLAYB38C! We top declarer's " & pCurrTopCard->GetFaceName() &
								      " to force a winner from dummy.\n";
						}
					}
					else if (nCurrentSeat == 3) 
					{
						// else we're playing 3rd, so play the lowest card from the top sequence
						pCard = suit.GetTopSequence().GetBottomCard();
						status << "PLAYB40! Play high to win with the " & pCard->GetFaceName() & ".\n";
					}
					else
					{
						// else we're playing last (4th)
						// play the cheapest card that will beat the top card
						pCard = suit.GetLowestCardAbove(pCurrTopCard);
						status << "PLAYB41! Play the " & pCard->GetFaceName() & " to win the trick.\n";
					}
				}
			}
			else
			{
				// we don't have a card to top the current high card
				if (bPartnerHigh)
				{
					// but partner's card is high, so we're OK
					pCard = GetDiscard();
					status << "PLAYB47! Partner's " & pCurrTopCard->GetFaceName() & 
							  " can win the trick, so discard the " & pCard->GetName() & ".\n";
				}
				else
				{
					// else we're screwed
					pCard = GetDiscard();
					status << "PLAYB48! We can't beat " & strTopCardPos & "'s " & pCurrTopCard->GetFaceName() & 
							  ", so discard the " & pCard->GetName() & ".\n";
				}
			}
		}
		else if (ISSUIT(nTrumpSuit) && (nSuitLed != nTrumpSuit) &&
							(m_pHand->GetNumCardsInSuit(nTrumpSuit) > 0))
		{
			// here, we can play a trump, so do so if appropriate 
			// see who has the top card in this round
			if (bPartnerHigh)
			{
				// let partner's card ride
				pCard = GetDiscard();
				status << "PLAYB52! Although we could trump this hand, partner's " & pCurrTopCard->GetName() & 
						  " is high, so discard the " & pCard->GetName() & ".\n";
			}
			else
			{
				// opponents have the high card (non-trump) -- so slam 'em
				pCard = m_pHand->GetSuit(nTrumpSuit).GetBottomCard();
				status << "PLAYB55! With no cards in " & SuitToString(nSuitLed) & 
						  ", trump with the " & pCard->GetName() & ".\n";
			}
		}
		else
		{
			// here we have zero cards in the suit and in trumps, so we're hosed
			pCard = GetDiscard();
			status << "PLAYB52! With no cards in the suit led and no trumps, we discard the " & pCard->GetName() & ".\n";
		}
	}
	//
	ASSERT(pCard->IsValid());
	ASSERT(m_pHand->HasCard(pCard));
	//
	return pCard;
}
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:101,代码来源:PlayEngine.cpp

示例5: PlaySecond


//.........这里部分代码省略.........
// default implementation, generally should be overridden in derived classes
//
CCard* CPlayEngine::PlaySecond()
{
	CPlayerStatusDialog& status = *m_pStatusDlg;
	status << "5PLAY2! Playing second, using default player logic.\n";

	// get play info
	int nDummyPos = pDOC->GetDummyPosition();
	CCard* pCardLed = pDOC->GetCurrentTrickCardLed();
	int nSuitLed = pCardLed->GetSuit();
	int nFaceValue = pCardLed->GetFaceValue();
	CCard* pCurrTopCard = pDOC->GetCurrentTrickHighCard();
	int nTrumpSuit = pDOC->GetTrumpSuit();
	CSuitHoldings& suit = m_pHand->GetSuit(nSuitLed);
	// card to play
	CCard* pCard = NULL;

	// second hand low
	int numCardsInSuit = suit.GetNumCards();
	if (numCardsInSuit > 0)
	{
		// default behavior -- just play the low card
		pCard = m_pHand->GetSuit(nSuitLed).GetBottomCard();
		if (numCardsInSuit > 1)
		{
			if (*pCard < *pCurrTopCard)
				status << "PLY2C1! Play second hand low with the " & pCard->GetFaceName() & ".\n";
			else
				status << "PLY2C2! As second hand, we play the lowest card we have in the suit, the " & pCard->GetFaceName() & ".\n";
		}
		else
		{
			status << "PLY2C4! Play our only " & STSS(nSuitLed) & ", the " & pCard->GetFaceName() & ".\n";
		}
	}
	else
	{
		// no cards in the suit led
		// trump here if possible
		if (m_pHand->GetNumTrumps() > 0)
		{
			//
			CSuitHoldings& trumpSuit = m_pHand->GetSuit(nTrumpSuit);

			// see if partner would win the suit otherwise
			CGuessedSuitHoldings& partnerSuit = m_pPlayer->GetGuessedHand(m_nPartnerPosition)->GetSuit(nSuitLed);
			CCardList outstandingCards;
			GetOutstandingCards(nSuitLed, outstandingCards);
			if (partnerSuit.AreAllCardsIdentified() && partnerSuit.HasCard(outstandingCards[0]->GetFaceValue()))
			{
				// partner may win the trick, so discard
				status << "PLY2K1! We could trump here, but we know partner holds the " & outstandingCards[0]->GetName() &
						  " and can win the trick, so discard the " & pCard->GetName() & ".\n";
			}
			else
			{
				// trump here if possible
				// but first see if we're playing ahead of dummy (dummy is to our left), 
				// and dummy is also void in the suit
				CGuessedHandHoldings* pDummyHand = m_pPlayer->GetGuessedHand(nDummyPos);
				if ((m_pLHOpponent == pDOC->GetDummyPlayer()) &&
					(pDummyHand->GetSuit(nSuitLed).GetNumRemainingCards() == 0) &&
					(pDummyHand->GetSuit(nTrumpSuit).GetNumRemainingCards() > 0))
				{
					// dummy is also void, so trump if we have a trump higher than dummy's
					CGuessedCard* pDummyTopTrump = pDummyHand->GetSuit(nTrumpSuit).GetAt(0);
					if (trumpSuit.GetNumCardsAbove(pDummyTopTrump->GetFaceValue()) > 0)
					{
						// go ahead and ruff
						pCard = trumpSuit.GetLowestCardAbove(pDummyTopTrump->GetFaceValue());
						status << "PLY2M1! Trump here, making sure to thwart dummy's " & pDummyTopTrump->GetFaceName() &
								  " of trumps by playing the " & pCard->GetFaceName() & ".\n";
					}
					else
					{
						// dummy would overtrump
						pCard = GetDiscard();
						status << "PLY2M2! We'd like to trump here, but Dummy may overruff, so discard the " & pCard->GetName() & ".\n";
					}
				}
				else
				{
					// safe to trump -- play the lowest trump
					pCard = trumpSuit.GetBottomCard();
					status << "PLY2P1! Trump with the " & pCard->GetFaceName() & ".\n";
				}
			}
		}
		else
		{
			// discard
			pCard = GetDiscard();
			status << "PLY2Y! We have no " & SuitToString(nSuitLed) & ", so discard the " & pCard->GetName() & ".\n";
		}
	}
	//
	ASSERT(pCard->IsValid());
	return pCard;
}
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:101,代码来源:PlayEngine.cpp

示例6: DoAction

void CTable::DoAction()
{

	CBuffer buffer;
	CCard	tmp;

	CSlot* fnd = NULL;
	CSlot* tab = NULL;

	switch( act_slot )
	{
	case BLOCK :
		/* move 3 cards to wastepile */

		//check IncreaseSelection and DecreaseSelection
		//regarding increaseSelection (all) or (+1)

		if( 0 != hand.GetCardsStored() ) return;

		buffer.RemoveAll();

		if( block.GetCardsStored() != 0 )
		{
			tmp = block.PopCard();
			tmp.Flip();
			wastepile.PushCard( tmp );

			if( 3 == ShowCards )
			{
				tmp = block.PopCard();
				tmp.Flip();
				wastepile.PushCard( tmp );

				tmp = block.PopCard();
				tmp.Flip();
				wastepile.PushCard( tmp );
			}

			act_slot = WASTEPILE;

		}
		else
		{
			if( wastepile.GetCardsStored() )
			{
				tmp = wastepile.PopCard();

				while( tmp.IsValid() )
				{
					tmp.Flip();
					block.PushCard( tmp, true );
					tmp = wastepile.PopCard();
				}

			}
		}
		changed[ WASTEPILE ] = true;
		changed[ BLOCK ] = true;

		ChangeSelection( );

		return;

	case WASTEPILE :
		/* put one card to hand */
		/* or put back from the hand */

		if( hand.GetCardsStored() )
		{
			if( hand.GetSource() == &wastepile )
			{
				tmp = hand.PopCard();
				wastepile.PushCard( tmp, true );

				hand.SetSource( NULL );
			}

		}
		else
		{
			tmp = wastepile.PopCard();
			if( false == tmp.IsValid() ) break;

			if( false == hand.PushCard( tmp ) )
			{
				wastepile.PushCard( tmp, true );
			}

			hand.SetSource( &wastepile );
		}

		changed[ WASTEPILE ] = true;
		changed[ HAND ] = true;

		return;

	case FOUNDATION1 :
	case FOUNDATION2 :
	case FOUNDATION3 :
	case FOUNDATION4 :  fnd = &foundation[act_slot - FOUNDATION1];	break;
//.........这里部分代码省略.........
开发者ID:Aristotong,项目名称:neutrino-mp-plugins-max,代码行数:101,代码来源:Table.cpp


注:本文中的CCard::IsValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。