Пример #1
0
BOOL CGIB::CreateGIBInputFile(CFile& file, CPlayer* pPlayer, CHandHoldings* pHand, CHandHoldings* pDummyHand, CString& strContents) const
{
	// format the input
	CString strInput;
	CEasyBDoc* pDoc = pDOC;

	// indicate player
	strInput.Format("%c\n",PositionToChar(pPlayer->GetPosition()));
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());

	// indicate hand
	strInput = pHand->GetInitialHand().GetGIBFormatHoldingsString();
	strInput += '\n';
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());

	// indicate dealer
	strInput.Format("%c\n",PositionToChar(pDoc->GetDealer()));
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());

	// indicate vulnerability
	strInput = "n\n";	// TEMP
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());

	// indicate auction
	strInput.Empty();
	int numBids = pDoc->GetNumBidsMade();
	int i; // NCR-FFS added here, removed below
	for(/*int*/ i=0;i<numBids;i++)
	{
		strInput += BidToBriefString(pDoc->GetBidByIndex(i));
		if (i < numBids)
			strInput += ' ';
	}
	strInput += '\n';
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());

	// indicate opening lead
	int nLeadCard = pDoc->GetPlayRecord(0);
	strInput.Format("%s\n",CardToShortString(nLeadCard));
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());
	
	// indicate dummy's (ORIGINAL) hand
	strInput = pDummyHand->GetInitialHand().GetGIBFormatHoldingsString();
	strInput += '\n';
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());

	// and enter any plays so far
	strInput.Empty();
	int numCardsPlayed = pDoc->GetNumCardsPlayedInGame();
	for(i=1;i<numCardsPlayed;i++)
	{
		strInput += CardToShortString(pDoc->GetPlayRecord(i));
		strInput += ' ';
		if (((i % 3) == 0) || (i == numCardsPlayed-1))
		{
			// flush the line
			strInput += '\n';
			file.Write((LPCTSTR)strInput, strInput.GetLength());
			strInput.Empty();
		}
	}

	// end the file with a # sign
	strInput = "#\n";
	strContents += strInput;
	file.Write((LPCTSTR)strInput, strInput.GetLength());

	// done
	return TRUE;
}