本文整理汇总了C++中CCard::GetFaceName方法的典型用法代码示例。如果您正苦于以下问题:C++ CCard::GetFaceName方法的具体用法?C++ CCard::GetFaceName怎么用?C++ CCard::GetFaceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCard
的用法示例。
在下文中一共展示了CCard::GetFaceName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)
//.........这里部分代码省略.........
示例2: 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";
}
}
//
//.........这里部分代码省略.........
示例3: Perform
//.........这里部分代码省略.........
(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;
}
else
{
status << "PLCSH20! Lead a low " & STSS(m_nSuit) &
" (the " & pPlayCard->GetFaceName() &
") from hand in order to cash the " &
m_pConsumedCard->GetFaceName() & " in dummy.\n";
}
}
else
{
// oops, we have no low cards in hand to lead!
status << "4PLCSH21! Oops, we wanted to cash a " & STSS(m_nSuit) &
" in dummy, but we have no low " & STS(m_nSuit) &
" in hand to lead, so we have to abandon that play.\n";
m_nStatusCode = PLAY_INACTIVE;
return PLAY_POSTPONE;
}
}
else
{
// oops, no card in the suit to lead!
status << "4PLCSH22! Oops, we wanted to cash a " & STSS(m_nSuit) &
" in dummy, but we have no " & STS(m_nSuit) &
" in hand to lead, so we have to abandon that play.\n";
m_nStatusCode = PLAY_NOT_VIABLE;
return m_nStatusCode;
}
}
示例4: 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!
//.........这里部分代码省略.........
示例5: this
//
// Perform()
//
PlayResult CType1Finesse::Perform(CPlayEngine& playEngine, CCombinedHoldings& combinedHand,
CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands,
CPlayerStatusDialog& status, CCard*& pPlayCard)
{
// Type I Finesse
// - lead of a low card towards a higher card in the opposite hand,
// which holds a higher cover card and a commanding top card.
// e.g., AQ3 (dummy) / 4 (hand) -- lead the 4, then finesse the Q
// 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());
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;
CCard* pOppCard = NULL;
// BOOL bLeading = TRUE;
CString strRHO = bPlayingInHand? playEngine.szRHO : playEngine.szLHO;
// test preconditions
if (!CPlay::IsPlayUsable(combinedHand, playEngine))
{
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)
// see where the finese card is located
if (m_nTargetHand == IN_HAND)
{
// can't finesse here
status << "4PL1FNS10! Can't use this (Type I) finesse leading from hand, as the finesse card (" &
m_pConsumedCard->GetName() & ") and its covers are in our own hand.\n";
m_nStatusCode = PLAY_INACTIVE;
return PLAY_POSTPONE;
}
else
{
// finessing from dummy so lead low card of the suit from hand
if (playerHand.GetNumCardsInSuit(m_nSuit) > 0)
{
pPlayCard = playerHand.GetSuit(m_nSuit).GetBottomCard();
status << "PL1FN12! Leading a low " & STSS(m_nSuit) &
" (the " & pPlayCard->GetFaceName() &
") from hand to finesse the " &
m_pConsumedCard->GetFaceName() & " in dummy.\n";
}
else
{
// oops, no card in the suit to lead!
status << "4PL1FN14! Oops, we wanted to finesse a " & STSS(m_nSuit) &
" in dummy, but we have no " & STS(m_nSuit) &
" in hand to lead, so we have to abandon the play.\n";
m_nStatusCode = PLAY_NOT_VIABLE;
return m_nStatusCode;
}
}
}
else
{
// leading from dummy
if (m_nTargetHand == IN_DUMMY)
{
// leading from dummy & finessing in dummy? no can do
status << "4PL1FNS20! Can't use this (Type I) finesse leading from dummy, as the finesse card (" &
m_pConsumedCard->GetName() & ") and its covers are in dummy.\n";
m_nStatusCode = PLAY_INACTIVE;
return PLAY_POSTPONE;
}
else
{
// leading from dummy and finessing in hand, so do it
if (dummyHand.GetNumCardsInSuit(m_nSuit) > 0)
{
pPlayCard = dummyHand.GetSuit(m_nSuit).GetBottomCard();
status << "PL1FN22! Lead a low " & STSS(m_nSuit) &
" (the " & pPlayCard->GetFaceName() &
") from dummy to finesse the " &
m_pConsumedCard->GetFaceName() & " in hand.\n";
//.........这里部分代码省略.........
示例6: Perform
//
// Perform()
//
PlayResult CRuff::Perform(CPlayEngine& playEngine, CCombinedHoldings& combinedHand,
CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands,
CPlayerStatusDialog& status, CCard*& pPlayCard)
{
// 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());
CSuitHoldings& playerSuit = playerHand.GetSuit(m_nSuit);
CSuitHoldings& dummySuit = dummyHand.GetSuit(m_nSuit);
CCombinedSuitHoldings& combinedSuit = combinedHand.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;
int nTrumpSuit = pDOC->GetTrumpSuit();
if ((nSuitLed != nTrumpSuit) && (pDOC->WasTrumpPlayed()))
bTrumped = TRUE;
pPlayCard = NULL;
CCard* pOppCard = NULL;
//
CCard* pRoundTopCard = pDOC->GetCurrentTrickHighCard();
CCard* pDeclarerCard = pDOC->GetCurrentTrickCard(playEngine.GetPlayerPosition());
CCard* pDummysCard = pDOC->GetCurrentTrickCard(playEngine.GetPartnerPosition());
CCard* pPartnersCard = bPlayingInHand? pDummysCard : pDeclarerCard;
BOOL bPartnerHigh = (pRoundTopCard == pPartnersCard);
//
BOOL bValid = FALSE;
// test preconditions
if (!CPlay::IsPlayUsable(combinedHand, playEngine))
{
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)? can't do so!
if (m_nTargetHand == IN_HAND)
{
// can't ruff here
// status << "4PLRUF02! Can't ruff a card when leading.\n";
m_nStatusCode = PLAY_POSTPONE;
return m_nStatusCode;
}
else
{
// ruffing in dummy -- first check eligibility
if (dummyHand.GetNumCardsInSuit(m_nSuit) > 0)
{
// can't use this now
m_nStatusCode = PLAY_POSTPONE;
return m_nStatusCode;
}
// now lead a low card of the suit from hand
if (combinedSuit.GetNumDeclarerLosers() > 0)
{
pPlayCard = playerHand.GetSuit(m_nSuit).GetBottomCard();
status << "PLRUF04! Lead a low " & STSS(m_nSuit) &
" (the " & pPlayCard->GetFaceName() & ") from hand to ruff in dummy.\n";
}
else
{
// oops, no card in the suit to lead!
status << "4PLRUF08! Oops, we wanted to ruff a " & STSS(m_nSuit) &
" in dummy, but we have no " & STSS(m_nSuit) &
" losers in hand to lead, so we have to abandon the play.\n";
m_nStatusCode = PLAY_NOT_VIABLE;
return m_nStatusCode;
}
}
}
else
{
// leading from dummy
if (m_nTargetHand == IN_DUMMY)
{
// leading from dummy & ruffing in dummy? no can do
// status << "4PLRUF12! Can't lead from dummy and ruff in dummy at the same time.\n";
m_nStatusCode = PLAY_POSTPONE;
return m_nStatusCode;
}
else
{
// ruffing in hand -- first check eligibility
if (playerHand.GetNumCardsInSuit(m_nSuit) > 0)
//.........这里部分代码省略.........