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


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

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


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

示例1: PlaySecond

//
// 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";
		}
	}
	//
//.........这里部分代码省略.........
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:101,代码来源:PlayEngine.cpp

示例2: PlayBestCard

//
// PlayBestCard()
//
// called on the third and fourth hand plays to try to win the trick
//
CCard* CPlayEngine::PlayBestCard(int nPosition)
{
	CPlayerStatusDialog& status = *m_pStatusDlg;
//	status << "2PLAY3! Playing best card.\n";

	// get play info
	CCard* pCurrentCard = pDOC->GetCurrentTrickCardLed();
	int nSuitLed = pCurrentCard->GetSuit();
	int nTopPos;
	CCard* pCurrTopCard = pDOC->GetCurrentTrickHighCard(&nTopPos);
	CString strTopCardPos = PositionToString(nTopPos);
	BOOL bPartnerHigh = FALSE;
	int nCurrentRound = pDOC->GetPlayRound();
	int nCurrentSeat = pDOC->GetNumCardsPlayedInRound() + 1;
	CCard* pPartnersCard = pDOC->GetCurrentTrickCard(m_pPartner->GetPosition());
	if (pPartnersCard == pCurrTopCard)
		bPartnerHigh = TRUE;
	// 
	int nTrumpSuit = pDOC->GetTrumpSuit();
	int numCardsInSuitLed = m_pHand->GetNumCardsInSuit(nSuitLed);
	// card to play
	CCard* pCard = NULL;

	// 
	// first see if somebody trumped in this hand
	//
	if ((pDOC->WasTrumpPlayed()) && (nTrumpSuit != nSuitLed))
	{
		// a trump has been played 
		// see whether it was played by partner or by an opponent
		if (bPartnerHigh)
		{
			// partner trumped -- leave it alone for now
			pCard = GetDiscard();
			status << "PLAYB10! We let partner's " & pCurrTopCard->GetName() & " trump ride and discard the " &
					  pCard->GetName() & ".\n";
		}
		else
		{
			// it was an opponent that did the trumping
			// see if we can overtrump
			CSuitHoldings& trumpSuit = m_pHand->GetSuit(nTrumpSuit);
			CCard* pTopTrump = NULL;
			if (trumpSuit.GetNumCards() > 0)
				pTopTrump = trumpSuit.GetTopCard();
			if ((numCardsInSuitLed == 0) && (pTopTrump) && (*pTopTrump > *pCurrTopCard))
			{
				// get the lowest trump that wil top the current top trump
				int numTopCards = trumpSuit.GetNumCardsAbove(pCurrTopCard);
				pCard = trumpSuit[numTopCards-1];
				status << "PLAYB20! We can overtrump " & strTopCardPos & "'s " & pCurrTopCard->GetName() &
						  " with the " & pCard->GetFaceName() & ".\n";
			}
			else
			{
				// no chance to win, so discard
				pCard = GetDiscard();
				if ((numCardsInSuitLed == 0) && (trumpSuit.GetNumCards() > 0))
					status << "PLAYB22! We can't overtrump " & strTopCardPos & "'s " & 
							  pCurrTopCard->GetFaceName() & ", so discard the " & pCard->GetName() & ".\n";
				else
					status << "PLAYB23! We can't beat the opponent's " & pCurrTopCard->GetFaceName() & 
							  " of trumps, so discard the " & pCard->GetName() & ".\n";
			}							
		}
	}
	else
	{
		// else nobody has played a trump this round, _or_ a trump was led
		// see if we can play trumps
		if (numCardsInSuitLed > 0)
		{
			// nope, gotta follow the suit that was led, trumps or otherwise
			// if we can beat the current top card, do so with the cheapest card
			CSuitHoldings& suit = m_pHand->GetSuit(nSuitLed);
			if (*(suit.GetTopCard()) > *pCurrTopCard)
			{
				// but see if the top card is partner's
				if (bPartnerHigh) 
				{
					// see if we should unblock here
					if (ISSUIT(nTrumpSuit) && (nCurrentRound == 0) &&
						(suit.GetNumHonors() == 1))
					{
						// first round in an NT contract, with one honor 
						// in the suit -- unblock
						pCard = suit.GetTopCard();
						if (suit.GetNumCards() > 1)
							status << "PLAYB30! Drop the " & pCard->GetFaceName() & 
									  " here to unblock the suit for partner.\n";
					}
					else
					{
						// else this is not an unblocking situation
						if (nCurrentSeat == 4)
//.........这里部分代码省略.........
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:101,代码来源:PlayEngine.cpp

示例3: Update

void CStatusPlayPlanPage::Update()
{
	// return if not all inits are complete
	if ((!m_bInitialized) || (pDOC == NULL))
		return;
	if (!theApp.IsGameInProgress())
	{
		m_strDeclarer = "None";
		UpdateData(FALSE);
		return;
	}

	// clear existing items
	m_listPlayPlan.DeleteAllItems();

	// get the declarer & his play engine
	int nDeclarer = pDOC->GetDeclarerPosition();
	if (!ISPLAYER(nDeclarer))
		return;
	CPlayer* pPlayer = pDOC->GetDeclarer();
	CDeclarerPlayEngine* pPlayEngine = pPlayer->GetDeclarerEngine();
	CPlayList& playPlan = pPlayEngine->GetPlayPlan();

	// list declarer
	m_strDeclarer.Format("%s", PositionToString(pPlayer->GetPosition()));

	// & number of available plays
	int nCount = playPlan.GetSize();
	m_strNumPlays.Format("%d",nCount);

	// also list the current play
	const CPlay* pPlay = pPlayEngine->GetCurrentPlay();
	CString strFailedPlay = pPlayEngine->GetFailedPlayName();
	if (pPlay)
		m_strCurrentPlay = (const_cast<CPlay*>(pPlay))->GetDescription();
	else if (!strFailedPlay.IsEmpty())
		m_strCurrentPlay = strFailedPlay;
	else
		m_strCurrentPlay = "None";

	// now list the plays
	for(int i=0;i<nCount;i++)
	{
		CPlay* pPlay = playPlan[i];
		// set number
		m_listPlayPlan.InsertItem(i, FormString(i+1));
		// set name
		m_listPlayPlan.SetItem(i, 1, LVIF_TEXT, pPlay->GetPlayTypeName(), 0, 0, 0, 0L);
		// add description
		m_listPlayPlan.SetItem(i, 2, LVIF_TEXT, pPlay->GetDescription(), 0, 0, 0, 0L);
		// add winner coded
		int nProspect = pPlay->GetPlayProspect();
		m_listPlayPlan.SetItem(i, 3, LVIF_TEXT, szProspectDescription[nProspect], 0, 0, 0, 0L);
		// add consumed card
		CCard* pConsumedCard = pPlay->GetConsumedCard();
		m_listPlayPlan.SetItem(i, 4, LVIF_TEXT, (pConsumedCard? pConsumedCard->GetName() : ""), 0, 0, 0, 0L);
		// add target card
		CCard* pTargetCard = pPlay->GetTargetCard();
		m_listPlayPlan.SetItem(i, 5, LVIF_TEXT, (pTargetCard? pTargetCard->GetName() : ""), 0, 0, 0, 0L);
		// add key cards
		CCardList* pKeyCards = pPlay->GetKeyCardsList();
		m_listPlayPlan.SetItem(i, 6, LVIF_TEXT, (pKeyCards? pKeyCards->GetHoldingsString() : ""), 0, 0, 0, 0L);
		// add OR-Key cards
		CCardList* pORKeyCards = pPlay->GetOrKeyCardsList();
		m_listPlayPlan.SetItem(i, 7, LVIF_TEXT, (pORKeyCards? pORKeyCards->GetHoldingsString() : ""), 0, 0, 0, 0L);
		// add OR-Key cards 2
		CCardList* pORKeyCards2 = pPlay->GetOrKeyCardsList2();
		m_listPlayPlan.SetItem(i, 8, LVIF_TEXT, (pORKeyCards2? pORKeyCards2->GetHoldingsString() : ""), 0, 0, 0, 0L);
		// add opponents' key cards
		CCardList* pOppKeyCards = pPlay->GetEnemyKeyCardsList();
		m_listPlayPlan.SetItem(i, 9, LVIF_TEXT, (pOppKeyCards? pOppKeyCards->GetHoldingsString() : ""), 0, 0, 0, 0L);
		// add opponents' OR-Key cards
		CCardList* pOppORKeyCards = pPlay->GetEnemyOrKeyCardsList();
		m_listPlayPlan.SetItem(i, 10, LVIF_TEXT, (pOppORKeyCards? pOppORKeyCards->GetHoldingsString() : ""), 0, 0, 0, 0L);
		// add required played cards
		CCardList* pReqPlayedCards = pPlay->GetRequiredPlayedCardsList();
		m_listPlayPlan.SetItem(i, 11, LVIF_TEXT, (pReqPlayedCards? pReqPlayedCards->GetHoldingsString() : ""), 0, 0, 0, 0L);
	}

	// done
	UpdateData(FALSE);
	m_nPrevTooltipIndex = -1;
}
开发者ID:azureskydiver,项目名称:EasyBridge,代码行数:83,代码来源:StatusPlayPlanPage.cpp

示例4: GetLeadCard

//
// GetLeadCard()
//
CCard* CPlayEngine::GetLeadCard()
{
	// default implementation 
	CPlayerStatusDialog& status = *m_pStatusDlg;
	CCard* pLeadCard = NULL;
	int nTrumpSuit = pDOC->GetTrumpSuit();
	
	// look to see if we have any winners
	if (m_pHand->GetNumWinners() > 0)
	{
		// return the first winner found
		// but avoid the trump suit unless there are no other winners
		int nSuit = NONE;
		if (ISSUIT(nTrumpSuit))
			nSuit = GetNextSuit(nTrumpSuit);
		else
			nSuit= CLUBS;	// else start with the club suit
		//
		for(int i=0;i<4;i++)
		{
			CSuitHoldings& suit = m_pHand->GetSuit(nSuit);
			if ((suit.GetNumTopCards() > 0) && (nSuit != nTrumpSuit))
			{
				pLeadCard = suit.GetTopSequence().GetBottomCard();
				status << "PLYLDA! With no other obvious plays, cash a winner with the " & pLeadCard->GetName() & ".\n";
				ASSERT(m_pHand->HasCard(pLeadCard));
				return pLeadCard;
			}
			// else look at the next suit
			nSuit = GetNextSuit(nSuit);
		}
	}

	// if we have a card in an unbid suit, lead from that suit.
	CArray<int,int> suitsUnbid;
	int numSuitsUnbid = pDOC->GetSuitsUnbid(suitsUnbid);
	for(int i=0;i<numSuitsUnbid;i++)
	{
		CSuitHoldings& suit = m_pHand->GetSuit(suitsUnbid[i]);
		if (suit.GetNumCards() > 0)
		{
			pLeadCard = suit.GetBottomCard();
			status << "PLYLDB! With no other clear plays available, lead a card from the unbid " &
					  STSS(pLeadCard->GetSuit()) & " suit.\n";
			ASSERT(m_pHand->HasCard(pLeadCard));
			return pLeadCard;
		}
	}

	// no winners in hand, so just lead anything
	if (ISSUIT(nTrumpSuit))
	{
		// playing in a suit contract
		// if we have any trumps left, _and_ have a singleton, then lead it
		if ((m_pHand->GetNumTrumps() > 0) && (m_pHand->GetNumSingletons() > 0))
		{
			// search for the singleton suit
			BOOL bSuitFound = FALSE;
			int nSuit;
			for(int i=3;i>=0;i--)
			{
				nSuit = m_pHand->GetSuitsByLength(3);
				if (m_pHand->GetNumCardsInSuit(nSuit) > 1)
					break;	// oops, no more singletons
				// check if this is a non-trump singleton suit
				if ((m_pHand->GetNumCardsInSuit(nSuit) == 1) && (nSuit != nTrumpSuit))
				{
					bSuitFound = TRUE;
					break;
				}
			}
			// lead a card from the suit
			if (bSuitFound)
			{
				CSuitHoldings& suit = m_pHand->GetSuit(nSuit);
				pLeadCard = suit[0];
				status << "PLYLDC! Lead the singleton " & pLeadCard->GetName() & " in the hopes of setting up a ruff later.\n";
				ASSERT(m_pHand->HasCard(pLeadCard));
				return pLeadCard;
			}
		}

		// else we're stuck -- just lead a card from the worst suit
		// (i.e., keep the "good" suits alive)
		for(int i=3;i>=0;i--)
		{
			int nSuit = m_pHand->GetSuitsByPreference(i);
			// avoid leading from the trump suit if we can help it
			if (nSuit == nTrumpSuit)
				continue;
			// else lead from this suit
			if (m_pHand->GetNumCardsInSuit(nSuit) > 0)
			{
				pLeadCard = m_pHand->GetSuit(nSuit).GetBottomCard();
				ASSERT(m_pHand->HasCard(pLeadCard));
				return pLeadCard;
			}
//.........这里部分代码省略.........
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:101,代码来源:PlayEngine.cpp

示例5: Perform


//.........这里部分代码省略.........
	{
		case 0:
			// we're leading, player #0
			if (bPlayingInHand) 
			{
				// playing from our own hand (declarer) and cashing in hand
				if (m_nTargetHand == IN_HAND)
				{
					// cashing from hand -- check to be sure the other hand has losers
					// i.e., don't discard a winner on a winner UNLESS both hands 
					// have nothing but winners, OR the other hand has only one card, 
					// a winner that's lower than the top card in this hand, 
					// AND this hand has only winners
					// this is because we don't want to end up stranded in the wrong hand
					// examples: 
					// ---------
					//   from Kx/A   -- don't lead the King!
					//        Kxx/AQ -- again, don't lead the King
					//        KJ/Q   -- we _can_ lead the K (in fact, we should)
					//        KQJ/T9 -- doesn't matter
					//        Qx/AKJ -- doesn't matter
					if ((dummySuit.GetNumCards() == 1) && (combinedSuit.GetNumDummyLosers() == 0) && 
								(combinedSuit.GetNumDeclarerLosers() == 0) && (*dummySuit[0] < *m_pConsumedCard))
					{
						// this is a special case, so it's OK
					}
					else if ((dummySuit.GetNumCards() > 0) && (combinedSuit.GetNumDummyLosers() == 0) && 
								(combinedSuit.GetNumDeclarerLosers() > 0) &&
								(combinedSuit.GetNumDummyWinners() < declarerSuit.GetNumCards()) &&
								(*dummySuit[0] > *declarerSuit[0]) &&
								(declarerEngine.GetNumDeclarerEntries() == 1) )
					{
						// here, nothing but higher winners in dummy, which is shorter than hand
						status << "5PLCSH02! We could cash the " & m_pConsumedCard->GetName() &
								  " from hand, but dummy has no losers to discard in the suit and could get stranded there.\n";
						m_nStatusCode = PLAY_INACTIVE;
						return PLAY_POSTPONE;
					}
					// proceed 
					pPlayCard = m_pConsumedCard;
					status << "PLCSH10! Cash the " & pPlayCard->GetName() &
							  " from hand.\n";
				}
				else
				{
					// playing from hand. but cashing from dummy,
					// lead a low card from hand
					if (declarerSuit.GetNumCards() > 0)
					{
						// we have cards in the suit
//						if (combinedSuit.GetNumDeclarerLosers() > 0)
						if (declarerSuit.GetNumCardsBelow(m_pConsumedCard) > 0)
						{
							// lead a low card, but test first
							pPlayCard = declarerSuit.GetBottomCard();
							if ( combinedSuit .AreEquivalentCards(pPlayCard, m_pConsumedCard) &&
//								 (declarerSuit.GetNumCards() > 1) && (ombinedSuit.GetNumDummyLosers() > 0) )
												 (combinedSuit.GetNumDummyLosers() > 0) )
							{
								// oops, the "low" card is equivalent to the cash card!
								status << "4PLCSH15! Oops, the lowest card we can lead from hand for the cash is the " & 
										  pPlayCard->GetFaceName() & ", which is equivalent to the " &
										  m_pConsumedCard->GetFaceName() & ", so skip the cash play.\n";
								m_nStatusCode = PLAY_INACTIVE;
								return PLAY_POSTPONE;
							}
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:67,代码来源:Cash.cpp

示例6: Perform

//
// Perform()
//
PlayResult CForce::Perform(CPlayEngine& playEngine, CCombinedHoldings& combinedHand, 
				    CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, 
				    CPlayerStatusDialog& status, CCard*& pPlayCard)
{
	// a "force" is a play of the lowest possible card that will force out
	// a key enemy card
	// check which hand this is
	int nOrdinal = pDOC->GetNumCardsPlayedInRound();
	CPlayer* pPlayer = playEngine.GetPlayer();
	BOOL bPlayingInHand = (pDOC->GetCurrentPlayer() == pPlayer);
	CHandHoldings& playerHand = *(combinedHand.GetPlayerHand());
	CHandHoldings& dummyHand = *(combinedHand.GetPartnerHand());
	CCombinedSuitHoldings& combinedSuit = combinedHand.GetSuit(m_nSuit);
	CSuitHoldings& playerSuit = playerHand.GetSuit(m_nSuit);
	CSuitHoldings& dummySuit = dummyHand.GetSuit(m_nSuit);
	CCard* pCardLed = pDOC->GetCurrentTrickCardByOrder(0);
	int nSuitLed = NONE;
	if (pCardLed)
		nSuitLed = pCardLed->GetSuit();
	// see if a trump was played in this round
	BOOL bTrumped = FALSE;
	if ((nSuitLed != pDOC->GetTrumpSuit()) && (pDOC->WasTrumpPlayed()))
		bTrumped = TRUE;
	pPlayCard = NULL;

	// test preconditions
	if (!CPlay::IsPlayUsable(combinedHand, playEngine))
	{
		m_nStatusCode = PLAY_INACTIVE;
		return PLAY_POSTPONE;
	}

	//
	// test to make sure that the required played cards have indeed been played
	//
	if (m_pRequiredPlayedCardsList)
	{
		// check if any of the cards that should have benen played 
		// are still outstanding
		for(int i=0;i<m_pRequiredPlayedCardsList->GetNumCards();i++)
		{
			CCard* pCard = (*m_pRequiredPlayedCardsList)[i];
			if (playEngine.IsCardOutstanding(pCard))
			{
				status << "5PLFRCA! The force play of the " & m_pConsumedCard->GetFaceName() &
						  " to force out the " & m_nTargetCardVal & 
						  " is not yet viable as the card [" & pCard->GetFaceName() & 
						  "] is still outstanding.\n";
				m_nStatusCode = PLAY_INACTIVE;
				return PLAY_POSTPONE;
			}
		}
	}


	//
	// check our position in the play
	//
	switch(nOrdinal)
	{
		case 0:
			// we're leading, player #0
			if (bPlayingInHand) 
			{
				// playing from our own hand (declarer)
				if (m_nTargetHand == IN_HAND)
				{
					// play the card necessary to force the opponent
					pPlayCard = playerSuit.GetHighestCardBelow(m_nTargetCardVal);
					// NCR check that dummy does not have a singleton honor that's same value as our lead
					if(dummySuit.IsSingleton() 
						&& ((dummySuit.GetTopCard()->GetFaceValue() > pPlayCard->GetFaceValue()) // NCR-28
						    || (combinedHand.AreEquivalentCards(pPlayCard, dummySuit.GetTopCard()))))
						pPlayCard = playerSuit.GetBottomCard(); // NCR get lowest card

					if (pPlayCard == NULL)
					{
						status << "4PLFRC02! Error in force play -- no cards in declarer hand usable in a force play.\n";
						m_nStatusCode = PLAY_ERROR;
						return m_nStatusCode;
					}
					status << "PLFRC04! Play the " & pPlayCard->GetName() &
							  " from hand to force out the opponents' " & CardValToString(m_nTargetCardVal) & ".\n";
				}
				else
				{
					// forcing from dummy, so lead a low card 
					if (playerSuit.GetNumCards() > 0)
					{
						pPlayCard = playerSuit.GetBottomCard();
						status << "PLFRC06! Lead a low " & STSS(m_nSuit) & 
								  " (" & pPlayCard->GetFaceName() &
								  ") from hand to trigger a force play in dummy.\n";
					}
					else
					{
						// oops, no card in the suit to lead!
//.........这里部分代码省略.........
开发者ID:azureskydiver,项目名称:EasyBridge,代码行数:101,代码来源:Force.cpp

示例7: WriteFilePBN


//.........这里部分代码省略.........
	{
		// NCR Include ContractToString() here as PBN file does NOT have space before X
		CString strBid;
		strBid.Format("%d%s", 
					  BID_LEVEL(m_nContract), 
					  szSuitNameShort[BID_SUIT(m_nContract)]);
		int nModifier = pDOC->GetContractModifier();
		if (nModifier > 0)
			strBid += FormString("%s", ((nModifier == 1)? "X" : "XX")); // w/o space

		WriteLine(TAG_CONTRACT, strBid);  // NCR replaced ContractToString(m_nContract)
	}
	else
		WriteLine(TAG_CONTRACT, "?");

	// Result tag
	if (m_numTricksPlayed == 13)
		WriteLine(TAG_RESULT, FormString("%d", m_numTricksWon[m_nContractTeam])); // NCR removed extra "s
	else
		WriteLine(TAG_RESULT, "?");

	//
	// write out the hands in comment form
	//
	CString strHands = "{\r\n" + pDOC->FormatOriginalHands() + "}";
	WriteLine(strHands);

	//
	// write out auction
	//
	CString strBids = FormString("[Auction \"%c\"]", PositionToChar(m_nDealer)); // NCR Lowercased
	if (m_numBidsMade > 0)
		strBids += "\r\n";
	nPos = m_nDealer;
	for(i=0;i<m_numBidsMade;i++)
	{
		strBids += FormString("%s ", ::BidToPBNString(m_nBiddingHistory[i]));
		nPos = ::GetNextPlayer(nPos);
		if ( (((i+1) % 4) == 0) && (i < m_numBidsMade-1) )
			strBids += "\r\n";
	}
	// add marker if needed
	if (!ISBID(m_nContract))
		strBids += "\r\n*";
	// and write out
	WriteLine(strBids);


	//
	// write out plays
	//
	CString strPlays = FormString("[Play \"%c\"]", PositionToChar(m_nGameLead));  // NCR Lowercased
	if (m_numTricksPlayed> 0)
		strPlays += "\r\n";
	bool bLastRowFnd = false;  // NCR added - only output single row with -s
	for(i=0;i<m_numTricksPlayed;i++)
	{
		int nPos = m_nGameLead;
		for(int j=0;j<4;j++)
		{
			CCard* pCard = m_pGameTrick[i][nPos];
			if (pCard == NULL) {
				strPlays += "-  ";
				bLastRowFnd = true;  // NCR this row will end the output
			}
			else
				strPlays += FormString("%s ", pCard->GetName());
			nPos = ::GetNextPlayer(nPos);
		} // end for(j) thru poisitions
		if (i < m_numTricksPlayed-1)
			strPlays += "\r\n";
		if(bLastRowFnd)
			break;  // NCR finished output plays on line with -s
	} // end for(i) thru tricks
	// add marker if needed
	if (m_numTricksPlayed < 13)
		strPlays += "\r\n*";
	// and write out
	WriteLine(strPlays);


	// Generator Tag
	WriteLine(TAG_GENERATOR, FormString("Easy Bridge version %s", theApp.GetProgramVersionString()));

	// Description Tag
	WriteLine(TAG_DESCRIPTION, m_strFileDescription);

	// blank line
//	SkipLine();

	//
	// write out the auction
	//

	//	
	// All done
	//
	ar.Flush();
	return TRUE;
}
开发者ID:azureskydiver,项目名称:EasyBridge,代码行数:101,代码来源:WrFilePBN.cpp

示例8: WriteFile

//
//---------------------------------------------------------
//
BOOL CEasyBDoc::WriteFile(CArchive& ar) 
{
	pFile = ar.GetFile();
	ASSERT(pFile != NULL);

	int i,j,numCards;
	CString	strTemp,strHand;
			
	// write the data

	//
	//-----------------------------------------------------
	//
	// first the file ID
	//
	WriteBlockHeader(BLOCK_FILEINFO);
	WriteString(ITEM_PROGRAM_ID,(LPCTSTR)theApp.GetValue(tstrProgramTitle));
	WriteInt(ITEM_MAJOR_VERSIONNO,theApp.GetValue(tnProgramMajorVersion));
	WriteInt(ITEM_MINOR_VERSIONNO,theApp.GetValue(tnProgramMinorVersion));
	WriteInt(ITEM_INCREMENT_VERSIONNO,theApp.GetValue(tnProgramIncrementVersion));
	WriteInt(ITEM_BUILD_NUMBER,theApp.GetValue(tnProgramBuildNumber));
	WriteString(ITEM_BUILD_DATE,(LPCTSTR)theApp.GetValue(tstrProgramBuildDate));
	CTime time = CTime::GetCurrentTime();
	strTemp.Format(" %s",(LPCTSTR)time.Format("%c"));
	WriteString(ITEM_FILE_DATE,strTemp);
	SkipLine();


	// then the file description
	WriteBlockHeader(BLOCK_FILEDESC);
	WriteString(ITEM_NONE,m_strFileDescription);
//	SkipLine();


	//
	//-----------------------------------------------------
	//
	// hand information
	//
	WriteBlockHeader(BLOCK_HANDINFO);
	// first the current hand
	for(i=0;i<4;i++) 
	{
		numCards = PLAYER(i).GetNumCards();
		strHand.Empty();
		for(j=0;j<numCards;j++) 
		{
			strHand += PLAYER(i).GetCardByPosition(j)->GetName();
			strHand += " ";
		}
		switch(i) 
		{
			case NORTH:
				WriteString(ITEM_CURRHAND_NORTH,strHand);
				break;
			case EAST:
				WriteString(ITEM_CURRHAND_EAST,strHand);
				break;
			case SOUTH:
				WriteString(ITEM_CURRHAND_SOUTH,strHand);
				break;
			case WEST:
				WriteString(ITEM_CURRHAND_WEST,strHand);
				break;
		}
	}
	// then the original hand
	for(i=0;i<4;i++) 
	{
		if (pVIEW->GetCurrentMode() == CEasyBView::MODE_CARDLAYOUT) 
		{
			numCards = PLAYER(i).GetNumCards();
			strHand.Empty();
			for(j=0;j<numCards;j++) 
			{
				strHand += PLAYER(i).GetCardByPosition(j)->GetName();
				strHand += " ";
			}
		} 
		else 
		{
			strHand.Empty();
			for(j=0;j<13;j++) 
			{
				strHand += PLAYER(i).GetInitialHandCard(j)->GetName();
				strHand += " ";
			}
		}
		switch(i) 
		{
			case NORTH:
				WriteString(ITEM_ORIGHAND_NORTH,strHand);
				break;
			case EAST:
				WriteString(ITEM_ORIGHAND_EAST,strHand);
				break;
			case SOUTH:
//.........这里部分代码省略.........
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:101,代码来源:Wrfile.cpp

示例9: Perform


//.........这里部分代码省略.........
			// playing second -- may be able to ruff here, intended or not
			if (nSuitLed == nTrumpSuit)
			{
				// but not if a trump was led
					m_nStatusCode = PLAY_POSTPONE;
					return m_nStatusCode;
			}

			// an unintended ruff is OK only if the card led is not a trump card, 
			// _and_ we have zero cards in the suit in the appropriate hand
			if ( ((m_nTargetHand == IN_HAND) && (playerHand.GetNumCardsInSuit(nSuitLed) == 0)) ||
				 ((m_nTargetHand == IN_DUMMY) && (dummyHand.GetNumCardsInSuit(nSuitLed) == 0)) )
			{
				status << "3PLRUF20! We can ruff in the suit led by the opponent.\n";
			}
			else
			{
//				status << "3PLRUF21! A ruff here is not possible.\n";
				m_nStatusCode = PLAY_POSTPONE;
				return m_nStatusCode;
			}

			// see which hand this is
			if (bPlayingInHand) 
			{
				// playing second in hand -- see where the ruff is
				if (m_nTargetHand == IN_HAND)
				{
					// ruff here
					CSuitHoldings& playerTrumps = playerHand.GetSuit(nTrumpSuit);
					if (playerTrumps.GetNumCards() > 0)
					{
						pPlayCard = playerTrumps.GetBottomCard();
						status << "PLRUF30! Ruff in hand with the " & pPlayCard->GetName() & ".\n";
					}
					else
					{
						status << "4PLRUF32! Error - no trumps left in hand to use in a ruff.\n";
						m_nStatusCode = PLAY_ERROR;
						return m_nStatusCode;
					}
				}
				else
				{
					// we'll be ruffing in dummy later, so discard
					pPlayCard = playEngine.GetDiscard();
					status << "PLRUF34! We'll be ruffing in dummy, so discard the " &
							  pPlayCard->GetName() & " from hand.\n";
				}
			}
			else
			{
				// playing second in dummy -- see where the finese card is located
				if (m_nTargetHand == IN_DUMMY)
				{
					// ruff here
					CSuitHoldings& dummyTrumps = dummyHand.GetSuit(nTrumpSuit);
					if (dummyTrumps.GetNumCards() > 0)
					{
						pPlayCard = dummyTrumps.GetBottomCard();
						status << "PLRUF40! Ruff in dummy with the " & pPlayCard->GetName() & ".\n";
					}
					else
					{
						status << "4PLRUF42! Error - no trumps left in dummy to use in a ruff.\n";
						m_nStatusCode = PLAY_ERROR;
开发者ID:derekmcloughlin,项目名称:easybridge,代码行数:67,代码来源:Ruff.cpp


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