void CForce::Init() { CPlay::Init(); // m_pTargetCard = deck.GetSortedCard(MAKEDECKVALUE(m_nSuit, m_nTargetCardVal)); m_pConsumedCard = deck.GetSortedCard(MAKEDECKVALUE(m_nSuit, m_nCardVal)); // form name & description m_strName.Format("Force out the %s", m_pTargetCard->GetName()); m_strDescription.Format("Force out the %s with the %s", m_pTargetCard->GetName(), m_pConsumedCard->GetName()); }
// // IsCardOutstanding() // BOOL CPlayEngine::IsCardOutstanding(int nSuit, int nFaceValue) const { int nDeckValue = MAKEDECKVALUE(nSuit, nFaceValue); ASSERT(ISDECKVAL(nDeckValue)); CCard* pCard = deck.GetSortedCard(nDeckValue); return IsCardOutstanding(pCard); }
CString CForce::GetFullDescription() { return FormString("Play the %s from %s to force out the opponents' %s.", CardToString(MAKEDECKVALUE(m_nSuit,m_nCardVal)), (m_nTargetHand == IN_HAND)? "hand" : "dummy", CardValToString(m_nTargetCardVal)); }
// // GetOutstandingCards() // // determine the list of outstanding cards in this suit // outstanding means all the cards that are not in our own hand // (or dummy), _and_ which have not been played // int CPlayEngine::GetOutstandingCards(int nSuit, CCardList& cardList, bool bCountDummy) const { VERIFY(ISSUIT(nSuit)); // first fill the list with all the cards in the suit for(int i=2;i<=ACE;i++) cardList << deck.GetSortedCard(MAKEDECKVALUE(nSuit,i)); cardList.Sort(); // then remove the cards remaining in our own hand CSuitHoldings& suit = m_pHand->GetSuit(nSuit); for(i=0;i<suit.GetNumCards();i++) cardList.Remove(suit[i]); // then remove the cards in dummy from the list // but only if indicated, _and_ dummy's cards are visible if (!bCountDummy) // i.e, don't count dummy's cards as outstanding { CPlayer* pDummy = pDOC->GetDummyPlayer(); if (pDummy->AreCardsExposed() && (GetPlayerPosition() != pDOC->GetDummyPosition())) { CSuitHoldings& dummySuit = pDummy->GetHand().GetSuit(nSuit); for(int i=0;i<dummySuit.GetNumCards();i++) cardList.Remove(dummySuit[i]); } } // then search the list of guessed cards for cards in this suit // that have already been played, and remove them from the list int nOurPos = m_pPlayer->GetPosition(); for(int nPlayer=0;nPlayer<4;nPlayer++) { CGuessedSuitHoldings& suit = m_ppGuessedHands[nPlayer]->GetSuit(nSuit); for(int j=0;j<suit.GetNumDefiniteCards();j++) { if (suit[j]->WasPlayed()) cardList.Remove(deck.GetSortedCard(suit[j]->GetDeckValue())); } } // now we have only the outstanding cards in the suit cardList.Sort(); return cardList.GetNumCards(); }
// // AssignCardsPBN() // void CEasyBDoc::AssignCardsPBN(const CString& str) { CString strHoldings = str; strHoldings.TrimLeft(); // get the starting player int nPlayer = CharToPosition(strHoldings[0]); strHoldings = strHoldings.Mid(2); // go past the "X:" mark strHoldings.TrimLeft(); // read in the holdings string int nIndex; for(int i=0;i<4;i++) { int numCards = 0; // read in each suit for(int nSuit=SPADES;nSuit>=CLUBS;nSuit--) { if (i < 3) { // first 3 players if (nSuit != CLUBS) nIndex = strHoldings.Find('.'); else nIndex = strHoldings.Find(' '); } else { // last player if (nSuit != CLUBS) nIndex = strHoldings.Find('.'); else nIndex = strHoldings.GetLength(); } CString strSuit = strHoldings.Left(nIndex); strSuit.TrimLeft(); // check for end of string if (strSuit == _T(".")) strSuit = _T(""); // for(int j=0;j<strSuit.GetLength();j++) { int nValue = CharToFaceValue(strSuit[j]); int nIndex = MAKEDECKVALUE(nSuit, nValue); CCard* pCard = deck.GetSortedCard(nIndex); ASSERT(pCard); m_pPlayer[nPlayer]->AddCardToHand(pCard,FALSE); m_pPlayer[nPlayer]->AddCardToInitialHand(pCard); numCards++; } // move to the next suit if (strHoldings.GetLength() > nIndex+1) strHoldings = strHoldings.Mid(nIndex+1); else strHoldings = strHoldings.Mid(nIndex); } // verify if (numCards != 13) { ClearAllInfo(); pVIEW->Notify(WM_COMMAND, WMS_REFRESH_DISPLAY); AfxMessageBox("Invalid deal string!"); AfxThrowFileException(CFileException::generic); } // nPlayer = GetNextPlayer(nPlayer); } // m_bHandsDealt = TRUE; }