Пример #1
0
void CReader::Disconnect(tDisconnectMode disconnectMode)
{
	m_oPKCS15.Clear(NULL);

	if (m_poCard != NULL)
	{
		// Strange behaviour with Ctrl-C:
		// It's possible that this function is called multiple times. Normally,
		// this doesn't hurt except that after a Ctrl-C, m_poCard->Disconnect()
		// throws us out of this function WITHOUT an exception! So the m_poCard
		// is not deleted() and set to NULL allthough the next call to this function
		// it contains rubbisch => CRASH.
		// So we set m_poCard = NULL in advance, and only if an exception is thrown
		// we assign it the old value.
		CCard *poTemp = m_poCard;
		m_poCard = NULL;
		try {
			poTemp->Disconnect(disconnectMode);
			MWLOG(LEV_INFO, MOD_CAL, L" Disconnected from card in reader %ls",
				m_wsReader.c_str());
			delete poTemp;
		}
		catch(...) {
			m_poCard = poTemp;
		}
	}
}
Пример #2
0
void CTable::distributeBoard()
{
    if (!board_) return;

    CPlayer *player;
    CRingIterator it(ring_);
    CCard *pCard;

    // all-in players must be evaluated too
    int state = PLAYER_STATE_PLAYING|PLAYER_STATE_ALLIN;

    if (it.start(state))
    {
        do {
            player = it.current()->getPlayer();
            // if player has been all-in for longer
            // than a complete hand, he doesn't have cards
            if (player->hasHand())
            {
                pCard = board_->getCard();
                while (pCard != NULL)
                {
                    player->getHand()->addCard(pCard);
                    pCard = pCard->getNext();
                }
            }
        } while (it.next(state));
    }
}
Пример #3
0
bool	CPart::SetTextContents( const std::string& inString )
{
	CPartContents*	contents = GetContentsOnCurrentCard();
	if( contents )
		contents->SetText( inString );
	else
	{
		CCard	*	currCard = GetStack()->GetCurrentCard();
		bool		isBgPart = dynamic_cast<CBackground*>(mOwner) != NULL;
		bool 		bgPartWithNonSharedText = (isBgPart && !GetSharedText());
		contents = new CPartContents( bgPartWithNonSharedText ? currCard : mOwner );
		contents->SetID( mID );
		contents->SetText( inString );
		contents->SetIsOnBackground( isBgPart );
		if( bgPartWithNonSharedText )	// We're on the background layer, not on the card? But we don't have shared text? Add the contents to the current *card*!
		{
			currCard->AddPartContents( contents );
		}
		else	// Otherwise, we're on the card, or on the background with shared text, add the contents to that.
		{
			mOwner->AddPartContents( contents );
		}
	}
	return true;
}
Пример #4
0
ObjectID	CDocument::GetUniqueIDForCard()
{
	bool	notUnique = true;
	
	while( notUnique )
	{
		notUnique = false;
		
		for( auto currStack = mStacks.begin(); currStack != mStacks.end(); currStack ++ )
		{
			size_t	numCards = (*currStack)->GetNumCards();
			for( size_t x = 0; x < numCards; x++ )
			{
				CCard	*	currCard = (*currStack)->GetCard(x);
				if( currCard->GetID() == mCardIDSeed )
				{
					notUnique = true;
					mCardIDSeed++;
					break;
				}
			}
		}
	}
	
	return mCardIDSeed;
}
Пример #5
0
CPartContents*	CPart::GetContentsOnCurrentCard()
{
	CPartContents*	contents = NULL;
	CStack		*	currStack = GetStack();
	if( !currStack )
		return NULL;
	CCard		*	currCard = currStack->GetCurrentCard();
	if( !currCard )
		return NULL;
	bool	isBgPart = dynamic_cast<CBackground*>(mOwner) != NULL;
	bool 	bgPartWithNonSharedText = (isBgPart && !GetSharedText());
	if( isBgPart && !GetSharedText() )	// We're on the background layer, not on the card, and don't have shared text?
	{
		contents = currCard->GetPartContentsByID( GetID(), isBgPart );
	}
	else
	{
		contents = mOwner->GetPartContentsByID( GetID(), isBgPart );
	}
	
	if( !contents )
	{
		contents = new CPartContents( currCard );
		contents->SetID( mID );
		contents->SetIsOnBackground( isBgPart );
		if( bgPartWithNonSharedText )
			currCard->AddPartContents( contents );
		else
			mOwner->AddPartContents( contents );
	}

	return contents;
}
Пример #6
0
void CBot::CardPlayed(const CCard &c)
{
   int n = c.GetNum() - 1;
   if (c.IsJoker()) {
      n += 13;
   }
   m_rgiRemainingCard[n]--;
}
Пример #7
0
bool CDeck::CanChow(int const pIdx)
{
    if(DumpPile->Empty())
        return false;

    CCard thrown = DumpPile->Pop();
    DumpPile->Push(thrown); //just checking so push again

    int Rank = thrown.Rank();
    int Suit = thrown.Suit();

    int a = PlayerHand[pIdx]->FindCard(Rank + 1, Suit);
    int b = PlayerHand[pIdx]->FindCard(Rank + 2, Suit);
    int c = PlayerHand[pIdx]->FindCard(Rank - 1, Suit);
    int d = PlayerHand[pIdx]->FindCard(Rank - 2, Suit);

    int e[3] = {-1, -1, -1};	//cards with same rank
    e[0] = PlayerHand[pIdx]->FindMoreSameRank(0, Rank, Suit);
    if(e[0] != -1) {

        e[1] = PlayerHand[pIdx]->FindMoreSameRank(e[0] + 1, Rank, Suit);
        if(e[1] != -1)
            e[2] = PlayerHand[pIdx]->FindMoreSameRank(e[1] + 1, Rank, Suit);
    }

    if(a != -1 && b != -1) {

        PlayerHand[pIdx]->SelectCard(a);
        PlayerHand[pIdx]->SelectCard(b);
        return true;
    }

    if(a != -1 && c != -1) {

        PlayerHand[pIdx]->SelectCard(a);
        PlayerHand[pIdx]->SelectCard(c);
        return true;
    }

    if(c != -1 && d != -1) {

        PlayerHand[pIdx]->SelectCard(c);
        PlayerHand[pIdx]->SelectCard(d);
        return true;
    }

    if(e[0] != -1 && e[1] != -1) {

        PlayerHand[pIdx]->SelectCard(e[0]);
        PlayerHand[pIdx]->SelectCard(e[1]);
        if(e[2] != -1)
            PlayerHand[pIdx]->SelectCard(e[2]);
        return true;
    }

    return false;
}
Пример #8
0
int CRandomEvent::REventCardDrop(
		CRole *pCRole,
		int32_t &para1,
		int32_t &para2,
		int32_t &para3,
		int32_t &para4
		)
{
//	IME_DEBUG("card drop event %u", CARD_GET);
	std::vector<int> vecrate;
	std::vector<STC_CONF_CARD_COLLECTION *> *p;
	p = CConfCardCollection::Find(para1);
	if (p->size() == 0)
	{
		IME_ERROR("can not find cardcollection index %u", para1);
		para1 = 0;
		para2 = 0;
		para3 = 0;
		return 0;
	}
	for (int i = 0; i < p->size(); i++)
	{
		vecrate.push_back((*p)[i]->byWeight);
	}	
	int rel;
	if ((rel = CUtil::RandFactor(vecrate)) == -1)
	{
		para1 = 0;
		para2 = 0;
		para3 = 0;
		return 0;
	}
	if ((*p)[rel]->dwCardindex == 0)
	{
		para1 = 0;
		para2 = 0;
		para3 = 0;
		return 0;
	}
	para1 = CARD_GET; 
	para2 = 0;
	para3 = (*p)[rel]->dwCardindex;
	uint32_t objid, opt;
	pCRole->GetclsCardPacket()->CardAddByPara(para3, objid, opt, SOURCE_OTHER); 
	if (opt)
	pCRole->GetclsCardPacket()->SingleCardAddUpdate(objid);
	CCard *pCard = pCRole->GetclsCardPacket()->Find(objid);
	if (pCard == NULL)
	{
		IME_ERROR("add this card fail %u", para3);
		return -1;
	}
	para2 = pCard->GetbyStarLevel();
	para3 = objid;
	return 0;
}
void CCardLabelNexus::showCardLabelToolTip(const CCard &card, int x, int y)
{
    if (!mCardLabelToolTip->isVisible() && card.isValid())
    {
        const CGlobalConfig &cfg = CGlobalConfig::getCfg();
        const CCardTable &cardTable = CCardTable::getCardTable();

        mCardLabelToolTipSummonLabel->setVisible(false);
        const QList<CCardSkill> &skills = card.getSkills();
        QStringList skillDescr;
        skillDescr.append(QString("<b>%1</b><br>").arg(card.getName()));
        QString subTitleStr = card.isUnique() ? "Unique " : "";
        switch(card.getFaction())
        {
        case EImperialFaction: subTitleStr += "Imperial"; break;
        case EBloodthirstyFaction: subTitleStr += "Bloodthirsty"; break;
        case EXenoFaction: subTitleStr += "Xeno"; break;
        case ERighteousFaction: subTitleStr += "Righteous"; break;
        case ERaiderFaction: subTitleStr += "Raider"; break;
        default: break;
        }
        skillDescr.append(QString("<i>%1</i><table valign='middle'>").arg(subTitleStr));
        for (int i = 0; i < skills.size(); ++i)
        {
            const CSkill& curSkill = cardTable.getSkillForId(skills.at(i).getId());
            if (curSkill.isValid())
            {
                skillDescr.append(QString("<tr><td><img src='%1.png'/></td><td> %2</td></tr>")
                    .arg(cfg.getResourcePicturePath() + curSkill.getPicture())
                    .arg(curSkill.makeSignature(skills.at(i), true)));
                if (curSkill.isSummon())
                {
                    const CCard &summonCard = cardTable.getCardForId(skills.at(i).getX());
                    mCardLabelToolTipSummonLabel->setCard(summonCard);
                    mCardLabelToolTipSummonLabel->setVisible(true);
                }
            }
        }
        skillDescr.append(QString("</table>"));
        mCardLabelToolTipText->setText(skillDescr.join(""));
        mCardLabelToolTipLayout->activate();
        mCardLabelToolTip->adjustSize();

        int reqW = mCardLabelToolTip->width() + 5;
        int reqH = mCardLabelToolTip->height() + 20;
        int xRel = (QApplication::desktop()->width() - x < reqW)
            ? -reqW
            : 5;
        int yRel = (QApplication::desktop()->height() - y < reqH)
            ? -reqH
            : 20;
        mCardLabelToolTip->setGeometry(x + xRel, y + yRel, 80, 40);
        mCardLabelToolTip->setVisible(true);
    }
}
Пример #10
0
//
// 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;
}
Пример #11
0
void CTable::Init()
{


	unsigned char i = 0;

	win_counter = 0;

	BBSetBackground( BACK_C );

	this->act_slot = BLOCK;
	memset( changed, 0xFF, sizeof( changed ) );


	block.RemoveAll();
	block.Fill();

	for( i = 0; i < 7; i++ )
		block.Shuffle();

	for( i = 0; i < 7; i++ )
		tableau[i].RemoveAll();

	for( i = 0; i < 4; i++ )
		foundation[i].RemoveAll();

	hand.RemoveAll();

	wastepile.RemoveAll();

	unsigned char	filled;

	for( filled = 1; filled < 7; filled++ )
	{
		for( i = filled; i < 7 ; i++ )
		{
			CCard tmp = block.PopCard();
			tableau[i].PushCard( tmp, true );
		}
	}

	for( i = 0; i < 7 ; i++ )
	{
		CCard tmp = block.PopCard();
		tmp.Flip();
		tableau[i].PushCard( tmp, true );
	}

	act_slot = BLOCK;

	ChangeSelection( true );

}
Пример #12
0
/* 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;
			}
		}
	}
}
void CCardFilterParameters::setCardWhiteListStatus(const CCard &card, bool isWhite)
{
    QSet<QString>::iterator iWhite = mWhiteList.find(card.getName());
    if (iWhite == mWhiteList.end() && isWhite)
    {
        setCardBlackListStatus(card, false);
        mWhiteList.insert(card.getName());
    }
    else if (iWhite != mWhiteList.end() && !isWhite)
    {
        mWhiteList.erase(iWhite);
    }
}
Пример #14
0
void CDlgAddCards::OnClickedBtnOK()
{
	// TODO: 在此添加控件通知处理程序代码	
	//
	int nCnt = m_proCard.GetPropertyCount();
	for( int i = 0; i < nCnt; i++)
	{
		CMFCPropertyGridProperty* pProp = m_proCard.GetProperty(i);
		if(!pProp || FALSE == pProp->IsEnabled())
			continue;
		CCardField* pField = (CCardField*)(pProp->GetData());
		if(!pField)
			continue;
		CString sv = CXxwMfcPub::OleVar2Str(pProp->GetValue());
		string sValue = sv.GetBuffer(0);
		pField->sInstantValue = pField->FormatValue(sValue);//修改值
	}

	for(int r = 0; r < m_lstDevicesSelected.GetItemCount(); ++r)
	{
		CCardLine* pLine = (CCardLine*)(m_lstDevicesSelected.GetItemData(r));
		CCard newCard = m_swiCard;
		for (int i = 0 ; i < m_vecKeynames.size(); i++)
		{
			CCardField* pFld = pLine->m_card.FindFieldByKeyname(m_vecKeynames[i]);
			CCardField* pFldNew = newCard.FindFieldByKeyname(m_vecKeynames[i]);
			if (pFld && pFldNew)
			{
				pFldNew->sInstantValue = pFld->sInstantValue;//替换为选择的值
			}
		}
		CCardLine* pLineNew = theApp.m_parserSwi.AddNewCard(newCard);//添加新卡
		m_AllCardsNew.insert(make_pair(newCard.m_sName, pLineNew));
	}

	// 获得父窗口的句柄
	HWND hWnd = m_pParentWnd->GetSafeHwnd();
	// 向父窗口发送消息
	if (hWnd == NULL) 
		return (void)MessageBox(_T("获得父窗口句柄失败!"));
	::SendNotifyMessage(hWnd,WM_MY_ADDCARDS_OK,(WPARAM)0, (LPARAM)0);

	//从“待选”中删除所有的行
	m_lstDevicesSelected.DeleteAllItems();//删除所有的行
	UpdateBtnOK();

	SetFocus();//获得焦点并显示,以免被隐藏
}
void CCardLabel::updateCardLabelPicture(const CCard& card)
{
    if (mCard.getId() == card.getId())
    {
        setCard(card);
    }
}
Пример #16
0
int CpduShowdown::sendShowdown(CPlayer* player,
                               int numCards,
                               const char* message)
{
    // Sending dummy cards for now!
    
    CCard *pCard = player->getHand()->getCard();
    int msglen = (message != NULL ? strlen(message) : 0);

    length_ += numCards * sizeof(pdu_card) + msglen;
    stuffHeader();

    if (length_ < MAXBUFFERSIZE)
    {
        char* buf = value_ + PDU_HEADER_SIZE;
        pdu_showdown data;

        data.slot = htons(player->getSlot());
        data.numCards = htons(numCards);
        data.msglen = htons(msglen);
        memcpy(buf, &data, sizeof(data));
        buf += sizeof(data);
    
        // copy cards to buffer
        for (int i = 0; i < numCards; i++)
        {
            pdu_card card;
            card.suit = htons(pCard->getSuit());
            card.value = htons(pCard->getValue());
            memcpy(buf, &card, sizeof(card));
            buf += sizeof(card);
            pCard = pCard->getNext();
        }

        // copy showdown message to buffer
        if (msglen > 0)
            memcpy(buf, message, msglen);

        return broadcastTo(table_->getRing());
    }
    else
    {
        Sys_LogError("CpduShowdown: buffer size too small.\n");
        return 0;
    }
}
Пример #17
0
void HandleMouseDownEvent(SDL_Event &event)
{
	CCardRegion *srcReg;
	if(event.button.button == SDL_BUTTON_LEFT){
		srcReg = Scorpion.OnMouseDown(event.button.x, event.button.y);
		if(srcReg == NULL) return;
				//clicked on the top of the foundations
		if((srcReg->Id == CRD_TABLEAU) && srcReg->PtOnTop(event.button.x, event.button.y)){
			srcReg->SetCardFaceUp(true, srcReg->Size() - 1);
		}
		//clicked on the tableau or piles for dragging
		if(((srcReg->Id == CRD_TABLEAU) || (srcReg->Id == CRD_FOUNDATION)) && Scorpion.InitDrag(event.button.x, event.button.y)){
			startdrag = true;
			SDL_WM_GrabInput(SDL_GRAB_ON);
		}
		//clicked on the stock pile
		if(srcReg->Id == CRD_STOCK){
			//printf("clicked on stock pile\n");
			CCardStack *cs = new CCardStack;
			for(int i = 0; i < 4; i++){
				*cs = Scorpion[0].Pop(1);
				cs->SetCardsFaceUp(true);
				Scorpion.InitDrag(cs, -1, -1);
				Scorpion.DoDrop(&Scorpion[i]);
			}
		}
	}

	//substitute right-click for double-click event
	if(event.button.button == SDL_BUTTON_RIGHT){
		srcReg = Scorpion.OnMouseDown(event.button.x, event.button.y);
		if(srcReg == NULL) return;
		CCardRegion *cr;
		CCard card =  srcReg->GetCard(srcReg->Size()-1);

		//clicked on the top of the foundations
		if(((srcReg->Id == CRD_FOUNDATION) || (srcReg->Id == CRD_STOCK)) && card.FaceUp() && srcReg->PtOnTop(event.button.x, event.button.y)){
			if((cr = Scorpion.FindDropRegion(CRD_FOUNDATION, card))){
				CCardStack *cs = new CCardStack;
				*cs = srcReg->Pop(1);
				Scorpion.InitDrag(cs, -1 , -1);
				Scorpion.DoDrop(cr);
			}
		}
	}
}
Пример #18
0
// finds a num card and sets its value to thiscard
void CDeck::SetCard(CCard thiscard, int num)
{
	int i = 0;
	const_deckIterator deckitr;

	deckitr = getDeckIterator();

	while ((deckitr != NULL) && (i != num)) {
		deckitr = deckitr->next;
		i++;
	}

	if (deckitr != NULL) {
		deckitr->data->setCard(thiscard.getRank(), thiscard.getSuit());
	}

	return;
}
Пример #19
0
void CCardGame::deal( void ) {
	CCard c;
	CCardDeck cd( mCardsNo );
	uint32_t turn = 0;
	cd.shuffle( 6546 );

	// TODO tricky stuff!!!
	while( (c = cd.getCard(), c.isCardValid() ) ) {
		if( turn ) {
			mPlayer1Cards.putCard( c );
		} else {
			mPlayer2Cards.putCard( c );
		}
		turn ^= 1;
	}
	
	gameLogFile<<"INIT "<<"("<<mPlayer1Cards.getDeckSize()<<","<<mPlayer2Cards.getDeckSize()<<") "<<endl<<*this;

}
Пример #20
0
void CTaxasRobotBrain::recivedCard( CCard& card )
{
	if ( m_tPeerCard.getAllCardCnt() < 7 )
	{
		m_tPeerCard.AddCardByCompsiteNum(card.GetCardCompositeNum()) ;
	}
	else
	{
		assert( 0 && "you forget reset state or add too more cards, logic error");
	}
}
Пример #21
0
// In 7-stud, the odd chip goes to player with
// highest card of suit in this order:
// Spades, Hearts, Diamonds, Clubs.
CPlayer* Cplm_7Stud::getOddChipWinner(Winners& winners)
{
    CPlayer* player = NULL;

    u_int16_t highestCard = 0;

    for (Winners::iterator it = winners.begin(),
            end = winners.end();
            it != end;
            ++it)
    {
        CWinner& winnerEntry = const_cast<CWinner&>(*it);
        CPlayer* winner = winnerEntry.player_;

        if (winner && winner->hasHand())
        {
            Chand* hand = winner->getHand();
            if (hand)
            {
                CCard* card = hand->getCard();
                while (card != NULL)
                {
                    u_int16_t thisCard = card->getSuit() * 13 + card->getValue();
                    if (thisCard > highestCard)
                    {
                        highestCard = thisCard;
                        player = winner;
                    }
                    card = card->getNext();
                }
            }
        }
    }

    if (!player)
        player = getPlayerClosestToLeftOfDealer(winners);

    return player;
}
Пример #22
0
//
// 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;
}
QString CDeckSaveWidget::buildCardName(const CCard &card)
{
    QString name = "unknown";
    QStringList nameTokens = card.getName().split(QRegExp("\\s|\\,|\\*"), QString::SkipEmptyParts);
    if (!nameTokens.empty())
    {
        name = nameTokens.at(0);
        if (nameTokens.size() > 1)
        {
            name = "";
            for (int i = 0; i < nameTokens.size(); ++i)
            {
                name += nameTokens.at(i).left(1);
            }
        }
    }
    return name.toLower();
}
Пример #24
0
// resets deck
void CDeck::resetDeck(bool bFull)
{
	CCard* pCard;
	POINT pt;

	pt.x = 100;
	pt.y = 100;
	EmptyHand();

	if (bFull) {
		// initialize the 52 card deck
		for(CCard::Suit suit = CCard::Hearts; suit <= CCard::Spades; suit++)
		{
			for(CCard::Rank rank = CCard::Ace; rank <= CCard::King; rank++)
			{
				pCard = new CCard();
				pCard->setCard(rank, suit);
				pCard->setFaceUp(false);
				pCard->setFileName(L"");
				pCard->setLocation(pt);
				pCard->setSpriteLength(0);
				pCard->setSpriteWidth(0);
				pCard->setFrontTexture(NULL);
				pCard->setBackTexture(NULL);

				AddCard(pCard);
			}
		}
	}

	if (m_pD3D10Device != NULL) {
		InitSprite(m_pD3D10Device, bFull);
	}

	return;
}
Пример #25
0
void CTable::dealCards(CPlayer *player, int numcards)
{
    CCard *tmpCard;
    CpduDealCardsFlex pdu;
    char message[100] = { '\0' };
    char vChar[3] = { '\0' };
    char sChar;

    if (numcards)
        sprintf(message, "%s was dealt ", player->getUsername());

    pdu.setDeal(0xffff, Hole);
    
    for (; numcards > 0; numcards--)
    {
        tmpCard = deck_.popCard();

        player->getHand()->addCard(tmpCard);

        memset(vChar, 0x0, sizeof(vChar));
        
        switch (tmpCard->getValue())
        {
        case (10):  strcpy(vChar, "10"); break;
        case (11):  vChar[0] = 'J'; break;
        case (12):  vChar[0] = 'Q'; break;
        case (13):  vChar[0] = 'K'; break;
        case (14):  vChar[0] = 'A'; break;
        default: itoa(tmpCard->getValue(), vChar, 10); break;
        }

        switch (tmpCard->getSuit())
        {
        case (1):   sChar = 'C'; break;         // Clubs
        case (2):   sChar = 'D'; break;         // Diamonds
        case (3):   sChar = 'H'; break;         // Hearts
        case (4):   sChar = 'S'; break;         // Spades
        }
        
        sprintf(message, "%s [%s%c]", message, vChar, sChar);

        pdu.addCard(tmpCard->getValue(), tmpCard->getSuit());

        delete tmpCard;
    }

    pdu.sendDealCards(player);

    setLog(message);
  
}
Пример #26
0
void COldMaidGame::RemoveSameNumber( CPlayer* pPlayer )
{
    CCardDeck* pDeck = pPlayer->GetDeck();
    for( int ii=0; ii < pDeck->GetCount(); ii++ ){
        CCard* pSrcCard = pDeck->GetAt(ii);
        int nIndex = pDeck->GetSameNumberIndex( pSrcCard );
        if( 0 <= nIndex ){
            CCard* pDirCard = pDeck->GetAt(nIndex);
            cout<< pPlayer->GetName() << ": " << pSrcCard->GetMarkStr() << pSrcCard->GetNumberStr() <<"と"
            << pDirCard->GetMarkStr() << pDirCard->GetNumberStr() << "を捨てます。" <<endl;
            pDeck->RemoveAt(nIndex);
            pDeck->RemoveAt(ii);
            ii--;
        }
    }
}
Пример #27
0
SpriteFrame* CClientApp::getCardSpriteByCompsiteNum(uint16_t nNum )
{
	CCard tc ;
	tc.RsetCardByCompositeNum(nNum);
	std::string spriteValue  ;
	uint8_t nType = 0 ;
	switch ( tc.GetType() )
	{
	case CCard::eCard_Diamond:
		nType = 4 ;
		break;
	case CCard::eCard_Heart:
		nType = 2 ;
		break;
	case CCard::eCard_Sword:
		nType = 1 ;
		break;
	case CCard::eCard_Club:
		nType = 3 ;
		break;
	default:
		break;
	}

	if ( nType == 0 || tc.GetCardCompositeNum() == 0 )
	{
		return nullptr ;
	}

	if ( tc.GetCardFaceNum(true) <= 9 )
	{
		spriteValue = String::createWithFormat("card-%d0%d.png",nType,tc.GetCardFaceNum(true))->getCString();
	}
	else
	{
		spriteValue = String::createWithFormat("card-%d0%c.png",nType,'a'+ tc.GetCardFaceNum(true)%10)->getCString();
	}

	return SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteValue.c_str());
}
Пример #28
0
void CTable::dealCards(Cring *ring, int numcards)
{
    CCard *tmpCard;
    CpduDealCommunity pdu;
    char message[100] = "Community Cards dealt ";
    char vChar[3] = { '\0' };
    char sChar;

    

    for (; numcards > 0; numcards--)
    {
        tmpCard = deck_.popCard();

        memset(vChar, 0x0, sizeof(vChar));

        switch (tmpCard->getValue())
        {
        case (10):  strcpy(vChar, "10"); break;
        case (11):  vChar[0] = 'J'; break;
        case (12):  vChar[0] = 'Q'; break;
        case (13):  vChar[0] = 'K'; break;
        case (14):  vChar[0] = 'A'; break;
        default: itoa(tmpCard->getValue(), vChar, 10); break;
        }

        switch (tmpCard->getSuit())
        {
        case (1):   sChar = 'C'; break;         // Clubs
        case (2):   sChar = 'D'; break;         // Diamonds
        case (3):   sChar = 'H'; break;         // Hearts
        case (4):   sChar = 'S'; break;         // Spades
        }

        getBoard()->addCard(tmpCard);

        sprintf(message, "%s [%s%c]", message, vChar, sChar);
        pdu.sendDealCommunity(ring, tmpCard->getValue(), tmpCard->getSuit(), 500);
        delete tmpCard;
    }

    setLog(message);
}
bool CCardFilterParameters::checkCard(const CCard &card, int &num) const
{
    if (mIsCompletionEnabled)
    {
        switch (card.getSet())
        {
        case EEnclaveSet: num = qMax(num, mComplement[1]); break;
        case ENexusSet: num = qMax(num, mComplement[2]); break;
        case EBlightSet: num = qMax(num, mComplement[3]); break;
        case EPuritySet: num = qMax(num, mComplement[4]); break;
        case EHomeWorldSet: num = qMax(num, mComplement[5]); break;
        case EPhobosSet: num = qMax(num, mComplement[6]); break;
        case EPhobosAftermathSet: num = qMax(num, mComplement[7]); break;
        case EAwakeningSet: num = qMax(num, mComplement[8]); break;
        case ETerminusSet: num = qMax(num, mComplement[9]); break;
        case EOccupationSet: num = qMax(num, mComplement[10]); break;
        case EWorldshipSet: num = qMax(num, mComplement[11]); break;
        case EFlashpointSet: num = qMax(num, mComplement[12]); break;
        case EStandardSet: num = qMax(num, mComplement[0]); break;
        case ERewardSet: num = qMax(num, mComplement[13]); break;
        case EPromotionalSet: num = qMax(num, mComplement[14]); break;
        case EUpgradedSet: num = qMax(num, mComplement[15]); break;
        default: break;
        }
    }

    if (mIsBlackListEnabled)
    {
        if (mBlackList.contains(card.getName()))
        {
            return false;
        }
    }

    if (mIsBlockListEnabled)
    {
        QHash<QString, int>::const_iterator iBlock = mBlockList.find(card.getName());
        if (iBlock != mBlockList.end())
        {
            num = qMax(0, num - iBlock.value());
        }
        if (num < 1)
        {
            return false;
        }
    }

    if (mIsWhiteListEnabled)
    {
        if (mWhiteList.contains(card.getName()))
        {
            return true;
        }
    }

    if (mIsFilterOptionEnabled)
    {
        bool passRarity(true);
        switch (card.getType())
        {
        case EAssaultType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsAssaultAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsAssaultAllowed[2]; break;
            case ERareRarity: passRarity = mIsAssaultAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsAssaultAllowed[0]; break;
            default: break;
            }
            break;
        case ECommanderType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsCommanderAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsCommanderAllowed[2]; break;
            case ERareRarity: passRarity = mIsCommanderAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsCommanderAllowed[0]; break;
            default: break;
            }
            break;
        case EStructureType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsStructureAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsStructureAllowed[2]; break;
            case ERareRarity: passRarity = mIsStructureAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsStructureAllowed[0]; break;
            default: break;
            }
            break;
        case EActionType:
            switch (card.getRarity())
            {
            case ECommonRarity: passRarity = mIsActionAllowed[3]; break;
            case EUncommonRarity: passRarity = mIsActionAllowed[2]; break;
            case ERareRarity: passRarity = mIsActionAllowed[1]; break;
            case ELegendaryRarity: passRarity = mIsActionAllowed[0]; break;
            default: break;
            }
            break;
        default:
            break;
        }

        bool passFaction(true);
        bool passHealth(true);
        bool passAttack(true);
        bool passDelay(true);
        if (mIsAssaultOptionEnabled && card.getType() == EAssaultType)
        {
            switch(card.getFaction())
            {
            case EBloodthirstyFaction: passFaction = mIsFactionAllowed[0]; break;
            case EImperialFaction: passFaction = mIsFactionAllowed[1]; break;
            case ERaiderFaction: passFaction = mIsFactionAllowed[2]; break;
            case ERighteousFaction: passFaction = mIsFactionAllowed[3]; break;
            case EXenoFaction: passFaction = mIsFactionAllowed[4]; break;
            default: break;
            }
            switch (card.getHealth())
            {
            case 1: passHealth = mIsHealthAllowed[0]; break;
            case 2: passHealth = mIsHealthAllowed[1]; break;
            case 3: passHealth = mIsHealthAllowed[2]; break;
            case 4: passHealth = mIsHealthAllowed[3]; break;
            case 5:
            default: passHealth = mIsHealthAllowed[4]; break;
            }
            switch (card.getAttack())
            {
            case 0: passAttack = mIsAttackAllowed[0]; break;
            case 1: passAttack = mIsAttackAllowed[1]; break;
            case 2: passAttack = mIsAttackAllowed[2]; break;
            case 3: passAttack = mIsAttackAllowed[3]; break;
            case 4:
            default: passAttack = mIsAttackAllowed[4]; break;
            }
            switch (card.getDelay())
            {
                case 0: passDelay = mIsDelayAllowed[0]; break;
                case 1: passDelay = mIsDelayAllowed[1]; break;
                case 2: passDelay = mIsDelayAllowed[2]; break;
                case 3: passDelay = mIsDelayAllowed[3]; break;
                case 4: passDelay = mIsDelayAllowed[4]; break;
                default: break;
            }
        }
        return passRarity && passFaction && passHealth && passAttack && passDelay;
    }
    return true;
}
Пример #30
0
//
//---------------------------------------------------------
//
BOOL CEasyBDoc::ReadFile(CArchive& ar) 
{
	int i,nRtnCode,nLineCode,nSectionCode;
	int	nIndex,nValue,nOffset,nLen;
	int nPlayOffset, nPos;
	int nBidIndex = 0;
	CString strMessage,string,partString;
	CCard* pCard;
	double fValue;
	BOOL bValue;
	BOOL bFileInfoFound = FALSE;

	
	// read
	m_nLineNumber = 0;
	try
	{
		for(;;) 
		{

			nRtnCode = ReadLine(ar, strBuf);
next:		if (nRtnCode == EOF)
				break;
			if (nRtnCode == 0)
				continue;
			if ((strBuf[0] == '#') || (strBuf[0] == '*'))
				continue;
			nLineLen = nRtnCode;
			nLineCode = ParseLine(strBuf,nLineLen);
			
			if (nLineCode < 0) 
			{

				// section signifier
				nSectionCode = -nLineCode;
				if (nSectionCode == BLOCK_FILEINFO)
				{
					//
					bFileInfoFound = TRUE;
					// file info; skip this section
					do {
						nRtnCode = ReadLine(ar, strBuf);
					} while ((nRtnCode != EOF) && (strBuf.Left(2) != "[["));
					//
					goto next;
				} 
				//
				if (nSectionCode == BLOCK_FILEDESC) 
				{
					// file description; read until next block
					m_strFileDescription.Empty();
					do {
						nRtnCode = ReadLine(ar, strBuf);
						if (strBuf.Left(2) != "[[")
						{
							strBuf += "\r\n";
							m_strFileDescription += strBuf;
						}
					} while ((nRtnCode != EOF) && (strBuf.Left(2) != "[["));

					// trim ending CR/LF
					int nLen = m_strFileDescription.GetLength();
					if ((nLen >= 2) && (m_strFileDescription[nLen-1] == _T('\n')))
						m_strFileDescription = m_strFileDescription.Left(nLen-2);
					//
					goto next;
				} 
				else if (nSectionCode == BLOCK_COMMENTS) 
				{
					// file comments
					for (;;) 
					{
						nRtnCode = ReadLine(ar, strBuf);
						if ((nRtnCode == EOF) || (strBuf.Left(2) == "[[")) 
						{
							// update file comments dialog if it's open
							CWnd* pWnd = pMAINFRAME->GetDialog(twFileCommentsDialog);
							if (pWnd)
								pWnd->SendMessage(WM_COMMAND, WMS_UPDATE_TEXT, FALSE);
							goto next;
						}
						strBuf += "\r\n";
						m_strFileComments += strBuf;
					}
				}
				else if ((nSectionCode == BLOCK_SOUTH_ANALYSIS) ||
						 (nSectionCode == BLOCK_WEST_ANALYSIS) ||
						 (nSectionCode == BLOCK_NORTH_ANALYSIS) ||
						 (nSectionCode == BLOCK_EAST_ANALYSIS))
				{
					// don't bother to save the analysis
					int nPlayer = nSectionCode - BLOCK_SOUTH_ANALYSIS;
					CString strAnalysisBiffer;
					do {
						nRtnCode = ReadLine(ar, strBuf);
	//					strBuf += "\r\n";
	//					strAnalysisBiffer += strBuf;
					} while ((nRtnCode != EOF) && (strBuf.Left(2) != "[["));
	//				m_player[nPlayer].SetValueString(tszAnalysis,  strAnalysisBiffer);
					goto next;
				}

			} 
			else if (nLineCode > 0) 
			{

				// first skip spaces
				nLen = strBuf.GetLength();
				while ((nDataPosition < nLen) && 
						(strBuf[nDataPosition] == ' '))
					nDataPosition++;
				if (nDataPosition >= nLen)
					continue;
				// then get data item
				string = strBuf.Mid(nDataPosition);
				nValue = atoi(string);
				fValue = atof(string);
				if ((string == "Yes") || (string == "1"))
					bValue = TRUE;
				else
					bValue = FALSE;

				switch(nLineCode) 
				{

					case ITEM_PROGRAM_ID:
						m_strFileProgTitle = string;
						break;

					case ITEM_MAJOR_VERSIONNO:
						m_nFileProgMajorVersion = nValue;
						break;

					case ITEM_MINOR_VERSIONNO:
						m_nFileProgMinorVersion = nValue;
						break;

					case ITEM_INCREMENT_VERSIONNO:
						m_nFileProgIncrementVersion = nValue;
						break;

					case ITEM_BUILD_NUMBER:
						m_nFileProgBuildNumber = nValue;
						break;

					case ITEM_BUILD_DATE:
						m_strFileProgBuildDate = string;
						break;

					case ITEM_FILE_DATE:
						m_strFileDate = string;
						break;

					// hand info, 10..19
					case ITEM_CURRHAND_NORTH:
						AssignCards(string,NORTH);
						break;

					case ITEM_CURRHAND_EAST:
						AssignCards(string,EAST);
						break;

					case ITEM_CURRHAND_SOUTH:
						AssignCards(string,SOUTH);
						break;

					case ITEM_CURRHAND_WEST:
						AssignCards(string,WEST);
						break;

					case ITEM_ORIGHAND_NORTH:
						AssignCards(string,NORTH,TRUE);
						break;

					case ITEM_ORIGHAND_EAST:
						AssignCards(string,EAST,TRUE);
						break;

					case ITEM_ORIGHAND_SOUTH:
						AssignCards(string,SOUTH,TRUE);
						break;

					case ITEM_ORIGHAND_WEST:
						AssignCards(string,WEST,TRUE);
						break;

					// current round info
					case ITEM_CURR_ROUND_LEAD:
						m_nRoundLead = StringToPosition(string);
						break;

					case ITEM_NUM_CARDS_PLAYED_IN_ROUND:
						m_numCardsPlayedInRound = nValue;
						break;

					case ITEM_TRICK_CARD_1:
						m_pCurrTrick[0] = deck.GetCard(string);
						break;

					case ITEM_TRICK_CARD_2:
						m_pCurrTrick[1] = deck.GetCard(string);
						break;

					case ITEM_TRICK_CARD_3:
						m_pCurrTrick[2] = deck.GetCard(string);
						break;

					case ITEM_TRICK_CARD_4:
						m_pCurrTrick[3] = deck.GetCard(string);
						break;

					// game status info
					case ITEM_VIEW_STATUS_CODE:
						pVIEW->SetCurrentMode((CEasyBView::ScreenMode)nValue);
						break;

					case ITEM_RUBBER_IN_PROGRESS:
						theApp.SetValue(tbRubberInProgress, bValue);
						break;

					case ITEM_GAME_IN_PROGRESS:
						// TEMP
//						theApp.SetValue(tbGameInProgress, FALSE);
						theApp.SetValue(tbGameInProgress, bValue);
						break;

					case ITEM_BIDDING_IN_PROGRESS:
						theApp.SetValue(tbBiddingInProgress, bValue);
						break;

					case ITEM_HANDS_DEALT:
						m_bHandsDealt = bValue;
						break;
					
					case ITEM_CONTRACT_SUIT:
						nLen = string.GetLength();
						m_nContractSuit = CharToSuit(string.GetAt(0));
						break;

					case ITEM_CONTRACT_LEVEL:
						m_nContractLevel = nValue;
						break;

					case ITEM_CONTRACT_MODIFIER:
						switch(nValue) 
						{
							case 0:
								m_bDoubled = FALSE;
								m_bRedoubled = FALSE;
								m_nContractModifier = 0;
								break;
							case 1:
								m_bDoubled = TRUE;
								m_bRedoubled = FALSE;
								m_nContractModifier = 1;
								break;
							case 2:
								m_bDoubled = FALSE;
								m_bRedoubled = TRUE;
								m_nContractModifier = 2;
								break;
						}
						break;

					case ITEM_DEALER:
						m_nDealer = StringToPosition(string);
						break;

					case ITEM_NUM_BIDS:
//						m_numBidsMade = nValue;
						break;

					case ITEM_BIDDING_HISTORY:
						strBiddingHistory = string;
						break;

					case ITEM_DECLARER:
						m_nDeclarer = StringToPosition(string);
						m_nContractTeam = GetPlayerTeam(m_nDeclarer);
						m_nDefendingTeam = (m_nContractTeam == NORTH_SOUTH)? EAST_WEST : NORTH_SOUTH;
						break;

					// game record
					case ITEM_NUM_TRICKS_PLAYED:
						m_numTricksPlayed = nValue;
						break;

					case ITEM_NUM_TRICKS_WON_NS:
						m_numTricksWon[0] = nValue;
						break;

					case ITEM_NUM_TRICKS_WON_EW:
						m_numTricksWon[1] = nValue;
						break;

					case ITEM_GAME_LEAD:
						m_nGameLead = StringToPosition(string);
						break;

					case ITEM_GAME_TRICK_1: case ITEM_GAME_TRICK_2: 
					case ITEM_GAME_TRICK_3: case ITEM_GAME_TRICK_4: 
					case ITEM_GAME_TRICK_5: case ITEM_GAME_TRICK_6: 
					case ITEM_GAME_TRICK_7: case ITEM_GAME_TRICK_8: 
					case ITEM_GAME_TRICK_9: case ITEM_GAME_TRICK_10: 
					case ITEM_GAME_TRICK_11: case ITEM_GAME_TRICK_12: 
					case ITEM_GAME_TRICK_13:
						try
						{
							nIndex = nLineCode - ITEM_GAME_TRICK_1;
							nOffset = 0;
							nLen = string.GetLength();
							// first read the lead player for the trick
							partString = string.Mid(nOffset);
							m_nTrickLead[nIndex] = StringToPosition(partString);
							nOffset = string.Find(' ');
							//
							for(i=0;i<4;i++) 
							{
								while((nOffset < nLen) && (string[nOffset] == ' '))
									nOffset++;
								partString = string.Mid(nOffset);
								nOffset += 2;
								if (partString.IsEmpty()) 
								{
									strMessage.Format("Incomplete Trick record at line %d;\n%s",
													  m_nLineNumber, string);
									AfxMessageBox(strMessage);
									break;
								}
								//
								if (partString.Left(2) == "--")
								{
									m_pGameTrick[nIndex][i] = NULL;
								}
								else
								{
									pCard = deck.GetCard(partString);
									m_pGameTrick[nIndex][i] = pCard;
								}
							}
							// insert the trick record into the game record
							// in the proper order
							nPlayOffset = nIndex * 4;
							nPos = m_nTrickLead[nIndex];
							for(i=0;i<4;i++)
							{
								CCard* pCard = m_pGameTrick[nIndex][nPos];
								if (pCard)
									m_nPlayRecord[nPlayOffset+i] = pCard->GetDeckValue();
								nPos = GetNextPlayer(nPos);
							}
							// and finally read the trick's winner 
							while((nOffset < nLen) && (string[nOffset] == ' '))
								nOffset++;
							partString = string.Mid(nOffset);
							m_nTrickWinner[nIndex] = StringToPosition(partString);
						}
						catch(...)
						{
							// error
						}
						break;

					// match info
					case ITEM_SCORE_NS_BONUS:
						m_nBonusScore[NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAME0:
						m_nGameScore[0][NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAME1:
						m_nGameScore[1][NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAME2:
						m_nGameScore[2][NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAMES_WON:
						m_numGamesWon[NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_EW_BONUS:
						m_nBonusScore[EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAME0:
						m_nGameScore[0][EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAME1:
						m_nGameScore[1][EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAME2:
						m_nGameScore[2][EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAMES_WON:
						m_numGamesWon[EAST_WEST] = nValue;
						break;

					case ITEM_CURRENT_GAME_INDEX:
						m_nCurrGame = nValue-1;
						break;

					case ITEM_BONUS_SCORE_RECORD:
						m_strArrayBonusPointsRecord.Add(StripQuotes(string));
						break;

					case ITEM_GAME_SCORE_RECORD:
						m_strArrayTrickPointsRecord.Add(StripQuotes(string));
						break;

					// misc info
					case ITEM_AUTOSHOW_COMMENTS:
						m_bShowCommentsUponOpen = bValue;
						break;
					case ITEM_AUTOSHOW_BID_HISTORY:
						m_bShowBidHistoryUponOpen = bValue;
						break;
					case ITEM_AUTOSHOW_PLAY_HISTORY:
						m_bShowPlayHistoryUponOpen = bValue;
						break;
					case ITEM_AUTOSHOW_ANALYSES:
						m_bShowAnalysesUponOpen = bValue;
						break;

				}

			} 
			else 
			{

	/*
				// unknown line
				strMessage.Format("Found Unknown line\n%s.\nContinue?",strBuf);
				if (AfxMessageBox(strMessage, MB_ICONEXCLAMATION | MB_OKCANCEL) == IDCANCEL)
					break;
	*/
			}

		}
	}
	catch(...)
	{
		// handle any improper file error here
		ClearAllInfo();
//		AfxMessageBox("An error ocurred while reading the game file.");
		return FALSE;
	}

	// see if this was a valid file
	if (!bFileInfoFound)
	{
		AfxMessageBox("This is not a proper Easy Bridge game file.");
		AfxThrowFileException(CFileException::generic);
	}

	//
	// do some sanity checks
	//
	m_nContract = MAKEBID(m_nContractSuit, m_nContractLevel);
	if (!ISPLAYER(m_nDeclarer) || !ISBID(m_nContract))
		theApp.SetValue(tbGameInProgress, FALSE);

	//
	// parse the bidding history
	//
	if (!ISPLAYER(m_nDeclarer))
		m_nDeclarer = SOUTH;
	nPos = m_nDeclarer;
	m_nCurrPlayer = nPos;
	int nTeam = GetPlayerTeam(nPos);
	nOffset = 0;
	// 
	nLen = strBiddingHistory.GetLength();
	for(i=0;;i++) 
	{
		// skip leading spaces
		while((nOffset < nLen) && (strBiddingHistory[nOffset] == ' '))
			nOffset++;
		if (nOffset >= nLen)
			break;
		// grab the next bid
		partString = strBiddingHistory.Mid(nOffset);
		int nBid = ContractStringToBid(partString);
		// and record it
		m_nBiddingHistory[m_numBidsMade] = nBid;
		m_numBidsMade++;
		m_nCurrPlayer = GetNextPlayer(m_nCurrPlayer);
		int nBiddingRound = i % 4;
		m_nBidsByPlayer[nPos][nBiddingRound] = nBid;
		// see if this is an actual numeric bid
		if (ISBID(nBid))
		{
			m_nValidBidHistory[m_numValidBidsMade] = nBid;
			m_numValidBidsMade++;
			m_nLastValidBid = nBid;
			m_nLastValidBidTeam = nTeam;
		}
		// skip over remainder of current bid string
		while((nOffset < nLen) && (strBiddingHistory[nOffset] != ' '))
			nOffset++;
		// and move to the next player
		nPos = GetNextPlayer(nPos);
		nTeam = GetOpposingTeam(nTeam);
	}
	if (ISBID(m_nContract))
		UpdateBiddingHistory();


	// tally some figures
	m_nTotalScore[0] = m_nGameScore[0][0] + m_nGameScore[1][0] +
					   m_nGameScore[2][0] + m_nBonusScore[0];
	m_nTotalScore[1] = m_nGameScore[0][1] + m_nGameScore[1][1] +
					   m_nGameScore[2][1] + m_nBonusScore[1];

	// vulnerability
	if ((m_numGamesWon[0] > 0) && (m_numGamesWon[1] > 0)) 
	{
		m_nVulnerableTeam = BOTH;
		m_bVulnerable[0] = m_bVulnerable[1] = TRUE;
	} 
	else if (m_numGamesWon[0] > 0) 
	{
		m_nVulnerableTeam = NORTH_SOUTH;
		m_bVulnerable[0] = TRUE;
	} 
	else if (m_numGamesWon[1] > 0)
	{
		m_nVulnerableTeam = EAST_WEST;
		m_bVulnerable[1] = TRUE;
	} 
	else 
	{
		m_nVulnerableTeam = NEITHER;
	}

	//
	// set contract info
	//
	m_nContract = ContractParamsToBid(m_nContractSuit,m_nContractLevel);
	m_nTrumpSuit = m_nContractSuit;
	m_nBiddingRound = nBidIndex;
	// set play info 
	if (ISBID(m_nContract) && ISPLAYER(m_nDeclarer))
	{
		// contract has been reached
		m_nDummy = GetPartner((int) m_nDeclarer);
		m_nGameLead = GetNextPlayer(m_nDeclarer);
		m_nRoundLead = m_nGameLead;
		m_nCurrPlayer = m_nRoundLead;
		m_nTrickLead[0] = m_nRoundLead;
//		m_pPlayer[m_nDummy]->SetDummyFlag(TRUE);
//		m_pPlayer[m_nDeclarer]->SetDeclarerFlag(TRUE);
	}
	else
	{
		// contract has NOT been reached, so restart
		m_nCurrPlayer = m_nDealer;
		m_numBidsMade = 0;
	}

	// restore initial hands (temp?)
	for(i=0;i<4;i++)
		m_pPlayer[i]->RestoreInitialHand();

	// not reviewing game
	m_bReviewingGame = FALSE;

	// all done
	return TRUE;
}