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)); }
static void WriteLine(int nLineCode, const CString& strValue) { if ((nLineCode < 0) || (nLineCode > NUM_TAGS)) return; CString strTag = tszTagName[nLineCode]; // strTag.MakeUpper(); // NCR out CString strTemp =FormString("[%s \"%s\"]", strTag, strValue); WriteLine(strTemp); }
CString CTypeAFinesse::GetFullDescription() { CString strText; return FormString("Opportunistically play the %s from %s to finesse against %s.", m_pConsumedCard->GetFaceName(), (m_nTargetHand == IN_HAND)? "hand" : "dummy", PositionToString(m_nTargetPos)); // done return strText; }
CString CType1Finesse::GetFullDescription() { CString strText; int nTrumpSuit = pDOC->GetTrumpSuit(); if (m_pCoverCards->GetNumCards() > 1) return FormString("Lead a low %s from %s to finesse the %s in %s against %s, with the { %s } as possible cover cards.", ((m_nSuit == nTrumpSuit)? "trump" : STSS(m_nSuit)), ((m_nTargetHand == IN_HAND)? "dummy" : "hand"), m_pConsumedCard->GetFaceName(), // STS(m_nSuit), ((m_nTargetHand == 0)? "hand" : "dummy"), PositionToString(m_nTargetPos), m_pCoverCards->GetHoldingsString()); else return FormString("Lead a low %s from %s to finesse the %s in %s against %s, with the %s as cover.", ((m_nSuit == nTrumpSuit)? "trump" : STSS(m_nSuit)), ((m_nTargetHand == IN_HAND)? "dummy" : "hand"), m_pConsumedCard->GetFaceName(), // STS(m_nSuit), ((m_nTargetHand == IN_HAND)? "hand" : "dummy"), PositionToString(m_nTargetPos), m_pCoverCards->GetAt(0)->GetFaceName()); }
//Handler for 'runtime' command. DWORD RunTimeHandler(__CMD_PARA_OBJ* pCmdParaObj) { CHAR Buffer[190] = {0}; DWORD week = 0,day = 0,hour = 0,minute = 0,second = 0; DWORD* Array[5] = {0}; second = System.GetSysTick(NULL); //Get system tick counter. //Convert to second. second *= SYSTEM_TIME_SLICE; second /= 1000; if(second >= 60) //Use minute. { minute = second / 60; second = second % 60; } if(minute >= 60) //use hour. { hour = minute / 60; minute = minute % 60; } if(hour >= 24) //Use day. { day = hour / 24; hour = hour % 24; } if(day >= 7) //Use week. { week = day / 7; day = day % 7; } Array[0] = &week; Array[1] = &day; Array[2] = &hour; Array[3] = &minute; Array[4] = &second; FormString(Buffer,"System has running %d week(s), %d day(s), %d hour(s), %d minute(s), %d second(s).",(LPVOID*)Array); //Show out the result. /*sprintf(Buffer,"System has running %d week(s), %d day(s), %d hour(s), %d minute(s), %d second(s).", week,day,hour,minute,second);*/ //sprintf(Buffer,"System has running %d,%d",(INT)week,(INT)day);//(INT)hour,(INT)minute,(INT)second //PrintLine(Buffer); CD_PrintString(Buffer,TRUE); return SHELL_CMD_PARSER_SUCCESS; }
BOOL CEasyBDoc::ExportGameInfo(CArchive& ar) { // export game info // export hands WriteText(ar, "[Dealt Hands]\r\n"); CString strHands = FormatOriginalHands(); WriteText(ar, strHands); // export bidding history WriteText(ar, "\r\n\r\n"); WriteText(ar, "[Bidding History]\r\n"); const CString strBiddingHistory = pMAINFRAME->GetBiddingHistory(); WriteText(ar, strBiddingHistory); if (ISBID(GetContract())) { int nDeclarer = GetDeclarerPosition(); CString strContract = FormString("Contract: %s by %s; %s leads", pDOC->GetContractString(), PositionToString(nDeclarer), PositionToString(GetNextPlayer(nDeclarer))); // WriteText(pFile, strContract); } // export play history WriteText(ar, "\r\n\r\n\r\n"); WriteText(ar, "[Play History]\r\n"); const CString strPlayHistory = pMAINFRAME->GetPlayHistory(); WriteText(ar, strPlayHistory); // export current hands if (GetNumTricksPlayed() > 0) { WriteText(ar, "\r\n\r\n\r\n"); WriteText(ar, "[Current Hands]\r\n"); CString strHands = pDOC->FormatCurrentHands(); WriteText(ar, strHands); } // done ar.Flush(); return TRUE; }
void CGameReviewDialog::Initialize(BOOL bRefresh) { // first call base class CMyCustomDialog::Initialize(); // then operate m_nGameIndex = 0; CTypedPtrArray<CPtrArray, CGameRecord*>& gamesArray = pDOC->GetGameRecords(); m_numGamesAvailable = gamesArray.GetSize(); BOOL bEnable = (m_numGamesAvailable > 0); // fill the games listbox m_listGameIndex.ResetContent(); int i; // NCR-FFS added here, removed below for(/*int*/ i=0;i<m_numGamesAvailable;i++) m_listGameIndex.AddString(FormString(i+1)); m_nGameIndex = 0; m_strGameInfo.Format("of %d", m_numGamesAvailable); UpdateData(FALSE); // enable/disable all controls for(i=0;i<tnumControls;i++) EnableControl(i, bEnable, TRUE); // disable the back buttons EnableControlByID(IDC_PREV, FALSE); EnableControlByID(IDC_FIRST, FALSE); EnableControlByID(IDC_PREV_GAME, FALSE); EnableControlByID(IDC_FIRST_GAME, FALSE); // expose all cards // theApp.SetValue(tbShowCardsFaceUp, TRUE); // and set current game SetGameIndex(0, bRefresh); }
// // Invoke() // // invoke the GIB program and return the recommended play // int CGIB::Invoke(CPlayer* pPlayer, CHandHoldings* pHand, CHandHoldings* pDummyHand, CPlayerStatusDialog* pStatusDlg) { SECURITY_ATTRIBUTES saAttr; // // create the GIB monitor dialog // CGIBDialog gibDialog(pMAINFRAME); int nProcessingTime = theApp.GetValue(tnGIBAnalysisTime); gibDialog.m_nProcessTime = nProcessingTime; // gibDialog.m_hEventCancel = m_hEventCancel; // Set the bInheritHandle flag so pipe handles are inherited. saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; // // create input and output pipes for the child process // // Create a pipe for the child process's STDOUT. if (!CreatePipe(&m_hChildStdoutRd, // returns the pipe's input handle &m_hChildStdoutWr, // returns the pipe's output handle &saAttr, 0)) { CString strError = "Stdout pipe creation failed\n"; TRACE(strError); pMAINFRAME->SetGIBMonitorText(strError); return ExitGracefully(-5); } // then create a pipe for the child process's STDIN. if (!CreatePipe(&m_hChildStdinRd, &m_hChildStdinWr, &saAttr, 0)) { CString strError = "Stdin pipe creation failed\n"; TRACE(strError); pMAINFRAME->SetGIBMonitorText(strError); return ExitGracefully(-5); } // // Now create the child process (GIB) // PROCESS_INFORMATION piProcInfo; if (!LaunchProgram(piProcInfo)) { TRACE("Create process failed"); return ExitGracefully(-1); } HANDLE hGIBProcess = piProcInfo.hProcess; DWORD nGIBProcessID = piProcInfo.dwProcessId; // now close the readable handle to the child's stdin SafeCloseHandle(m_hChildStdinRd); // and the writable handle to the child's stdout SafeCloseHandle(m_hChildStdoutWr); // //------------------------------------------------------------------ // // create the GIB input file // CFile file; CFileException fileException; CString strTempFile, strTempPath; GetTempPath(1024, strTempPath.GetBuffer(1024)); strTempPath.ReleaseBuffer(); GetTempFileName(strTempPath, "ezb", 0, strTempFile.GetBuffer(2048)); strTempFile.ReleaseBuffer(); // strTempFile.Format("%s\\%s", theApp.GetValueString(tszProgramDirectory), tszGIBTempFilename); /* LPTSTR szBuffer = strTempFile.GetBuffer(MAX_PATH); GetTempFileName(theApp.GetValueString(tszProgramDirectory), "ezb", 0, szBuffer); strTempFile.ReleaseBuffer(); */ // CString strInput; // strInput.Format("-T %d %s\n",theApp.GetValue(tnGIBAnalysisTime),strTempFile); int nCode = file.Open(strTempFile, CFile::modeWrite | CFile::modeCreate | CFile::shareDenyWrite, &fileException); if (nCode == 0) { CString strError = "Error opening temporary input file for GIB"; TRACE(strError); pMAINFRAME->SetGIBMonitorText(strError); return ExitGracefully(-2); } // CString strFileContents; CreateGIBInputFile(file, pPlayer, pHand, pDummyHand, strFileContents); file.Close(); // then send the parameters line CString strParameters, strShortParameters; strParameters.Format("-T %d %s\n",nProcessingTime,strTempFile); strShortParameters.Format("-T %d",nProcessingTime); DWORD dwWritten; int nErrCode; if (!WriteFile(m_hChildStdinWr, (LPCTSTR)strParameters, strParameters.GetLength(), &dwWritten, NULL)) { CString strError = "Error providing parameters to GIB"; TRACE(strError); pMAINFRAME->SetGIBMonitorText(strError); nErrCode = GetLastError(); return ExitGracefully(-3); } // // update the GIB monitor window // CString strGIBText = "========================================\n"; strGIBText += FormString("Launching %s %s\n", theApp.GetValueString(tszGIBPath), strShortParameters); // strGIBText += FormString("Input file contents:\n%s", strFileContents); strGIBText += "Awaiting Responses...\n"; strGIBText += "----------------------------------------\n"; // pMAINFRAME->SetGIBMonitorText(strGIBText); pMAINFRAME->AppendGIBMonitorText(strGIBText); // //------------------------------------------------------------ // // now set up the wait loop and the cancel dialog, // then sit and wait for the process to run or for a cancel message // /* // // create the "Cancel GIB" dialog thread // (this is a user interface thread) // CGIBMonitorThread* pMonitorThread = new CGIBMonitorThread(m_hEventFinished, m_hEventCancel, nProcessingTime); pMonitorThread->CreateThread(CREATE_SUSPENDED); pMonitorThread->SetThreadPriority(THREAD_PRIORITY_ABOVE_NORMAL); pMonitorThread->ResumeThread(); // wait for the monitor thread to initialize DWORD nCode0 = WaitForSingleObject(m_hEventFinished, INFINITE); */ // // create the wait thread // (this is a worker thread) // GIBStruct gibData; gibData.hReadHandle = m_hChildStdoutRd; gibData.pGIBDialog = &gibDialog; CWinThread* pWaitThread = AfxBeginThread(CGIB::ReadGIBOutput, &gibData, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); // copy its handle se that we can check its exit code later HANDLE hWaitThread; BOOL bCode = ::DuplicateHandle(GetCurrentProcess(), pWaitThread->m_hThread, GetCurrentProcess(), &hWaitThread, 0, FALSE, DUPLICATE_SAME_ACCESS); // and launch the threads // MonitorThread->ResumeThread(); pWaitThread->ResumeThread(); // // Show the Wait/Cancel dialog // m_bGIBPending = TRUE; // mark dialog as active bCode = gibDialog.DoModal(); // see if the user cancelled if (!bCode) { /* // lock out the wait thread and cancel operations if (ClearGIBPending()) { */ // pMAINFRAME->SetStatusText("GIB cancelled."); // TerminateProcess(hGIBProcess, 0); TerminateThread(hWaitThread, 0); // wait for the read thread to end WaitForSingleObject(hWaitThread, INFINITE); // close the wait thread handle CloseHandle(hWaitThread); CloseHandle(hGIBProcess); // and delete the thread object delete pWaitThread; // close pipe handles SafeCloseHandle(m_hChildStdinWr); SafeCloseHandle(m_hChildStdoutRd); // and throw an exception throw CGIBException(); // } } /* // set up events HANDLE eventArray[2]; eventArray[0] = m_hEventCancel; eventArray[1] = pWaitThread->m_hThread; // // then sit back and wait for the thread(s) // for(;;) { // wait for the cancelled or finished messages DWORD nCode = WaitForMultipleObjects(2, // 2 events to wait for eventArray, // events array FALSE, // not all at once INFINITE); // wait 4-ever // if (nCode == WAIT_FAILED) { ASSERT(FALSE); break; } else if (nCode == WAIT_OBJECT_0) { // got the cancel message, so kill GIB & the wait thread // the following is very dangersous -- // so kids, don't try this at home TerminateThread(pWaitThread, 0); TerminateProcess(hGIBProcess, 0); return GIB_CANCEL; } else if (nCode == WAIT_OBJECT_0 + 1) { // GIB finished message // signal the GIB monitor that GIB has finished SetEvent(m_hEventFinished); break; } } */ // //------------------------------------------------------------ // // presumably, GIB has finished running // // wait for the GIB thread to exit, then get the card code DWORD nCardPlayed, nErrorCode; bCode = WaitForSingleObject(hWaitThread, INFINITE); bCode = GetExitCodeThread(hWaitThread, &nCardPlayed); if (!bCode) nErrorCode = GetLastError(); // close the wait thread handle CloseHandle(hWaitThread); // delete the temporary file DeleteFile(strTempFile); // and kill the child process // first send a Ctrl-C to the app // (this doesn't seem to do anything) CString strInput = "\03"; // Ctrl-C if (!WriteFile(m_hChildStdinWr, (LPCTSTR)strInput, strInput.GetLength(), &dwWritten, NULL)) { CString strError = "Error stopping GIB"; TRACE(strError); pMAINFRAME->SetGIBMonitorText(strError); nErrCode = GetLastError(); return ExitGracefully(-4); } // close the writable handle to the child's stdin SafeCloseHandle(m_hChildStdinWr); // then call terminateProcess TerminateProcess(hGIBProcess, 0); CloseHandle(hGIBProcess); // then close the readable handle to the child's stdout SafeCloseHandle(m_hChildStdoutRd); // // done // return nCardPlayed; }
// // SetGameIndex() // void CGameReviewDialog::SetGameIndex(int nGame, BOOL bRefresh) { if ((nGame < 0) || (nGame >= m_numGamesAvailable)) return; // init m_nGameIndex = nGame; m_nBidIndex = 0; m_nPlayIndex = 0; m_nPlayRound = 0; // fill tags list // first clear existing items m_listTags.DeleteAllItems(); // then add entries CGameRecord* pGameRecord = pDOC->GetGameRecord(m_nGameIndex); if (!pGameRecord) return; // fill the tags list int nIndex = 0; int nMaxWidth = 0; const int tnColSpacer = 14; CString strTag, strValue; std::map<CString,CString>::const_iterator iter; for(iter=pGameRecord->m_mapTagValues.begin();iter!=pGameRecord->m_mapTagValues.end();iter++) { // get the next tag & value strTag = (*iter).first; strValue = (*iter).second; // skip certain tags if ((strTag.CompareNoCase("Auction") == 0) || (strTag.CompareNoCase("Play") == 0)) continue; // set tag column m_listTags.InsertItem(nIndex, strTag); // set value column m_listTags.SetItem(nIndex, 1, LVIF_TEXT, strValue, 0, 0, 0, 0L); int nWidth = m_listTags.GetStringWidth(strValue) + tnColSpacer; if (nWidth > nMaxWidth) nMaxWidth = nWidth; nIndex++; } // set value column width m_listTags.SetColumnWidth(1, nMaxWidth); // m_nGameIndex = nGame; m_nPlayerPosition = pGameRecord->m_nRoundLead[0]; UpdateData(FALSE); // now update the display iter = pGameRecord->m_mapTagValues.find(_T("DEAL")); if (iter != pGameRecord->m_mapTagValues.end()) strValue = (*iter).second; pDOC->LoadGameRecord(*pGameRecord); if (bRefresh) pDOC->ResetDisplay(); pDOC->UpdateBiddingHistory(); pDOC->UpdatePlayHistory(); pMAINFRAME->SetAllIndicators(); // NCR-759 Check if this hand has data to show if(pDOC->GetDeclarerPosition() == NONE) { return; // No plays to make } // end NCR-759 // set prompt pMAINFRAME->SetMessageText(FormString("Contract is %s. Declarer is %s; %s leads.", pDOC->GetFullContractString(), PositionToString(pDOC->GetDeclarerPosition()), PositionToString(pDOC->GetRoundLead()))); // set game info m_numPlaysAvailable = pGameRecord->m_numCardsPlayed; if (m_numPlaysAvailable > 0) m_numTricksAvailable = ((m_numPlaysAvailable-1) / 4) + 1; else m_numTricksAvailable = 0; // reset suit sequence theApp.InitDummySuitSequence(BID_SUIT(pGameRecord->m_nContract), GetPartner(pGameRecord->m_nDeclarer)); // enable/disable play controls GetDlgItem(IDC_PREV)->EnableWindow(FALSE); GetDlgItem(IDC_FIRST)->EnableWindow(FALSE); if (m_numPlaysAvailable <= 1) { GetDlgItem(IDC_NEXT)->EnableWindow(FALSE); GetDlgItem(IDC_LAST)->EnableWindow(FALSE); } else { GetDlgItem(IDC_NEXT)->EnableWindow(TRUE); GetDlgItem(IDC_LAST)->EnableWindow(TRUE); } // and enable/disable game nav controls if (m_nGameIndex == 0) { GetDlgItem(IDC_PREV_GAME)->EnableWindow(FALSE); GetDlgItem(IDC_FIRST_GAME)->EnableWindow(FALSE); } else { GetDlgItem(IDC_PREV_GAME)->EnableWindow(TRUE); GetDlgItem(IDC_FIRST_GAME)->EnableWindow(TRUE); } // if (m_nGameIndex >= m_numGamesAvailable-1) { GetDlgItem(IDC_NEXT_GAME)->EnableWindow(FALSE); GetDlgItem(IDC_LAST_GAME)->EnableWindow(FALSE); } else { GetDlgItem(IDC_NEXT_GAME)->EnableWindow(TRUE); GetDlgItem(IDC_LAST_GAME)->EnableWindow(TRUE); } }
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; }
void CTestPlayDialog::Update() { // display each row m_listResults.DeleteAllItems(); // get the latest results from the document int nTrumpSuit = pDOC->GetTrumpSuit(); int nContractLevel = pDOC->GetContractLevel(); int nDeclaringTeam = pDOC->GetDeclaringTeam(); int numTricksMade = pDOC->GetNumTricksWonByTeam(nDeclaringTeam); BOOL bDoubled = pDOC->IsContractDoubled(); BOOL bReDoubled = pDOC->IsContractRedoubled(); // update counts m_numContracts[nContractLevel-1][nTrumpSuit]++; m_numContracts[nContractLevel-1][nTotalsColumn]++; m_numContracts[nTotalsRow][nTrumpSuit]++; m_numContracts[nTotalsRow][nTotalsColumn]++; if (bDoubled) { m_numContracts[nContractLevel-1][nDoubledColumn]++; m_numContracts[7][nDoubledColumn]++; } else if (bReDoubled) { m_numContracts[nContractLevel-1][nRedoubledColumn]++; m_numContracts[7][nRedoubledColumn]++; } // NCR-706 WRite out boards that go down using Cash play BOOL bSaveThisBoard = FALSE; if(theApp.GetValue(tnFileProgramBuildNumber) == 1234) { bSaveThisBoard = TRUE; // Ask that this board be written theApp.SetValue(tnFileProgramBuildNumber, 1); // turn off } // NCR-706 end // also update # contracts made if (numTricksMade >= (nContractLevel+6)) { m_numMade[nContractLevel-1][nTrumpSuit]++; m_numMade[nContractLevel-1][nTotalsColumn]++; m_numMade[nTotalsRow][nTrumpSuit]++; m_numMade[nTotalsRow][nTotalsColumn]++; if (bDoubled) { m_numMade[nContractLevel-1][nDoubledColumn]++; m_numMade[7][nDoubledColumn]++; } else if (bReDoubled) { m_numMade[nContractLevel-1][nRedoubledColumn]++; m_numMade[7][nRedoubledColumn]++; } } // NCR-AT Save contracts that went down else if (((nContractLevel >= 1) && m_bSaveDowns) || bSaveThisBoard) //<<<<<<<< NCR changed to 1 vs 4 for NCR-706 testing { int nDownCnt = (nContractLevel+6) - numTricksMade; // show number of tricks down CFile file; CFileException fileException; CString strPath; // CTime time = CTime::GetCurrentTime(); strPath.Format("%s\\LostContract_Down_%d_%s.brd",theApp.GetValue(tszProgramDirectory), nDownCnt, pDOC->GetDealIDString()); // (LPCTSTR)time.Format("%X")); int nCode = file.Open((LPCTSTR)strPath, CFile::modeWrite | CFile::modeCreate | CFile::shareDenyWrite, &fileException); CArchive ar(&file, CArchive::store); pDOC->WriteFile(ar); ar.Close(); file.Close(); } // NCR-AT end saving lost contracts #ifdef _DEBUG // NCR-SCU Save hands that have used conventions // if(m_bSaveConvUsed && (pDOC->GetNumSCU() > 0)) { CFile file; CFileException fileException; CString strPath; // Build filename from conventions used CString fileNm = "CU"; // Filename prefix const int nInitNameLen = fileNm.GetLength(); // save length for test below bool usedConv[] = {false,false,false,false,false,false,false,false,false,false, false,false,false,false,false,false,false,false,false,false, false,false,false,false,false,false,false,false,false,false, false,false,false,false,false,false,false,false,false,false}; for(int k = 0; k < pDOC->GetNumSCU(); k++) { int cix = pDOC->GetSCU(k); // get next convention if(cix == tidOvercalls) continue; // skip saving overcalls if(usedConv[cix]) continue; // skip if seen before usedConv[cix] = true; // remember that we've use this one fileNm += GetConvName(cix); // add on convention } // end for(k) thru used conventions if(fileNm.GetLength() > nInitNameLen) { // Only write if a convention used // build filename from conventions used strPath.Format("%s\\%s_%s.brd",theApp.GetValue(tszProgramDirectory), fileNm, pDOC->GetDealIDString()); int nCode = file.Open((LPCTSTR)strPath, CFile::modeWrite | CFile::modeCreate | CFile::shareDenyWrite, &fileException); CArchive ar(&file, CArchive::store); pDOC->WriteFile(ar); ar.Close(); file.Close(); } } // NCR-SCU end saving hands that used a convention #endif // and display for(int nRow=0;nRow<8;nRow++) { m_listResults.InsertItem(nRow, tszRowTitle[nRow]); for(int nCol=0;nCol<8;nCol++) m_listResults.SetItem(nRow, nCol+1, LVIF_TEXT, FormString("%d / %d", m_numMade[nRow][nCol], m_numContracts[nRow][nCol]), 0, 0, 0, 0L); } // show % made CStatic* pLabel = (CStatic*) GetDlgItem(IDC_GAMES_MADE_LABEL); if (!pLabel->IsWindowVisible()) { pLabel->ShowWindow(SW_SHOW); pLabel->UpdateWindow(); } double fPercent = m_numMade[nTotalsRow][nTotalsColumn] / (double) m_numContracts[nTotalsRow][nTotalsColumn]; m_strPercentMade.Format(_T("%.1f%%"), fPercent * 100); UpdateData(FALSE); // m_listResults.UpdateWindow(); }
CString CCash::GetFullDescription() { return FormString("Cash the %s in %s.", m_pConsumedCard->GetFullName(), ((m_nTargetHand == 0)? "hand" : "dummy")); }
// //--------------------------------------------------------- // // PBN File output routine // BOOL CEasyBDoc::WriteFilePBN(CArchive& ar) { pFile = ar.GetFile(); ASSERT(pFile != NULL); // write header WriteComment(""); WriteComment("EXPORT"); WriteComment("PBN Format 1.0"); WriteComment(FormString("File generated by Easy Bridge version %s", theApp.GetProgramVersionString())); WriteComment(""); // // write the data // // Event tag WriteLine(TAG_EVENT, FormString("%s Game", theApp.GetValue(tstrProgramTitle))); // Site Tag WriteLine(TAG_SITE, "At Home"); // NCR added At Home // Date Tag CTime time = CTime::GetCurrentTime(); WriteLine(TAG_DATE, time.Format("%Y.%m.%d")); /* * skip the round tag -- no longer mandatory in PBN 0.91+ * // Round Tag WriteLine(TAG_ROUND, ""); */ // Board Tag WriteLine(TAG_BOARD, "1"); // NCR added 1 // West/North/East/South Tags WriteLine(TAG_WEST, "Computer"); WriteLine(TAG_NORTH, "Computer"); WriteLine(TAG_EAST, "Computer"); WriteLine(TAG_SOUTH, "Human Player"); // Dealer Tag WriteLine(TAG_DEALER, FormString("%c", PositionToChar(m_nDealer))); // Vulnerable Tag CString strVulnerable; if ((m_bVulnerable[NORTH_SOUTH]) && (m_bVulnerable[EAST_WEST])) strVulnerable = "Both"; else if (m_bVulnerable[NORTH_SOUTH]) strVulnerable = "NS"; else if (m_bVulnerable[EAST_WEST]) strVulnerable = "EW"; else strVulnerable = "None"; WriteLine(TAG_VULNERABLE, strVulnerable); // deal tag CString strDeal = "W:"; int nPos = WEST; int i; // NCR-FFS added here, removed below for(/*int*/ i=0;i<4;i++) { CCardHoldings& cards = m_pPlayer[nPos]->GetHand().GetInitialHand(); strDeal += cards.GetGIBFormatHoldingsString(); nPos = GetNextPlayer(nPos); if (i < 3) strDeal += ' '; } WriteLine(TAG_DEAL, strDeal); // Scoring tag if (theApp.IsRubberInProgress()) WriteLine(TAG_SCORING, _T("Rubber")); else WriteLine(TAG_SCORING, _T("None")); // Declarer Tag if (ISPOSITION(m_nDeclarer)) WriteLine(TAG_DECLARER, FormString("%c", PositionToChar(m_nDeclarer))); else WriteLine(TAG_DECLARER, "?"); // Contract Tag if (ISBID(m_nContract)) { // 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; }
CString CHoldUp::GetFullDescription() { return FormString("Hold up a round of %s.",STS(m_nSuit)); }
void CBidDialog::InitBiddingSequence() { // check for autotrain mode if (m_nCurrMode == BD_MODE_AUTO_TRAIN) return; // get display mode m_bUseSuitSymbols = theApp.GetValue(tbUseSuitSymbols); // get manual bid option m_bManualBidding = theApp.GetValue(tbManualBidding); // get pause option m_bInsertBiddingPause = theApp.GetValue(tbInsertBiddingPause); if (m_bInsertBiddingPause) m_nBiddingPauseLength = theApp.GetValue(tnBiddingPauseLength) * 100; else m_nBiddingPauseLength = 0; // get speech option m_bSpeechEnabled = theApp.GetValue(tbEnableSpokenBids); // get bidding engine info // m_nBiddingEngine = theApp.GetValue(tnBiddingEngine); // m_bTrainingMode = theApp.GetValue(tbNNetTrainingMode); m_nBiddingEngine = 0; m_bTrainingMode = FALSE; // start the bidding process CEasyBDoc* pDoc = CEasyBDoc::GetDoc(); if (!pDoc || !pDoc->IsInitialized()) return; m_nComputerBid = NONE; EnableControls(); DisableControls(); // clear bid displays for(int i=0;i<4;i++) { SetDlgItemText(IDC_BID_SOUTH+i,""); ((CStatic*)GetDlgItem(IDCI_BID_SOUTH+i))->SetIcon(NULL); } // and start bidding, if appropriate // but return if just initializing if (!theApp.IsBiddingInProgress()) return; int nDealer = pDOC->GetDealer(); if ((nDealer != SOUTH) || m_bTrainingMode) { GetComputerBids(nDealer); } else { UpdateBidDisplay(SOUTH,0,TRUE); m_nCurrMode = BD_MODE_WAITFORBID; pDOC->ShowAutoHint(); } // show dealer int nPos = pDOC->GetDealer(); CString strTitle = FormString("Bid (Dealer = %s)", PositionToString(nPos)); // if (m_bTrainingMode) // strTitle += _T(" (Training Mode)"); SetWindowText(strTitle); }
CString CRuff::GetFullDescription() { return FormString("Ruff a %s in %s.", SuitToSingularString(m_nSuit), (m_nTargetHand == 0)? "hand" : "dummy"); }