void CGameReviewDialog::OnPrev() { if (m_nPlayRound == 0) return; // get the game record CGameRecord* pGameRecord = pDOC->GetGameRecord(m_nGameIndex); // undo the last trick CEasyBDoc* pDoc = pDOC; int numCardsPlayed = pDoc->GetNumCardsPlayedInRound(); // return if there's nothing to undo if ((m_nPlayRound == 0) && (numCardsPlayed == 0)) return; // decrement the play round one extra if at the end of play record // play round = # of rounds played so far // undo cards from the current trick, if it has cards if (numCardsPlayed > 0) { pDoc->UndoTrick(); m_nPlayRound--; m_nPlayIndex -= numCardsPlayed; } // see if we're at the start if (m_nPlayRound == 0) { // can't go back any further SetPlayRound(0); // hide dummy pDOC->ExposeDummy(FALSE); // pVIEW->PostMessage(WM_COMMAND, WMS_RESET_DISPLAY, 1L); pMAINFRAME->SetStatusMessage("Start of play record."); pDOC->UpdatePlayHistory(); return; } // if past the first round, clear the previous trick as well pDoc->UndoPreviousTrick(); m_nPlayRound--; m_nPlayIndex -= 4; if (m_nPlayIndex < 0) m_nPlayIndex = 0; // pDoc->ResetDisplay(); pVIEW->DisplayTricks(); // then re-display the trick OnNext(); }
// // AssessPosition() // // fill in some shortcut variables // void CPlayEngine::AssessPosition() { CEasyBDoc* pDoc = pDOC; m_nRound = pDoc->GetNumTricksPlayed(); m_numCardsPlayed = pDoc->GetNumCardsPlayedInRound(); if (m_numCardsPlayed > 0) { m_nRoundLead = pDoc->GetRoundLead(); m_pLeadCard = pDoc->GetCurrentTrickCard(m_nRoundLead); m_nLeadSuit = m_pLeadCard->GetSuit(); m_nLeadFaceValue = m_pLeadCard->GetFaceValue(); } else { m_nRoundLead = -1; m_pLeadCard = NULL; m_nLeadSuit = NONE; m_nLeadFaceValue = -1; } // }
// //----------------------------------------------------------------------- // // InitSwappedHand() // // called when the hand is swapped in midgame // void CPlayEngine::InitSwappedHand() { // set general status info CEasyBDoc* pDoc = pDOC; m_nContract = pDoc->GetContract(); m_nContractModifier = pDoc->GetContractModifier(); m_nTrumpSuit = pDoc->GetContractSuit(); // m_bVulnerable = pDOC->IsTeamVulnerable(m_pPlayer->GetTeam()); m_bOpponentsVulnerable = pDoc->IsTeamVulnerable(m_pLHOpponent->GetTeam()); if (m_pRHOpponent->IsDeclarer()) m_bLHDefender = TRUE; else m_bLHDefender = FALSE; if (m_pLHOpponent->IsDeclarer()) m_bRHDefender = TRUE; else m_bRHDefender = FALSE; // clear analysis variables Clear(); }
void CGameReviewDialog::OnFirst() { // undo the last trick CEasyBDoc* pDoc = pDOC; int numCardsPlayed = pDoc->GetNumCardsPlayedInRound(); // return if there's nothing to undo if ((m_nPlayRound == 0) && (numCardsPlayed == 0)) return; // suppress flashing CWaitCursor wait; pDoc->SuppressPlayHistoryUpdate(TRUE); pMAINFRAME->SetStatusMessage(_T("Backing up to the beginning of play...")); // decrement the play round one extra if at the end of play record if (m_nPlayRound > m_numTricksAvailable) m_nPlayRound--; // undo cards from the current trick if (numCardsPlayed > 0) { pDoc->UndoTrick(); m_nPlayRound--; m_nPlayIndex -= numCardsPlayed; } // and all previous tricks while(m_nPlayRound > 0) { pDoc->UndoPreviousTrick(); m_nPlayRound--; m_nPlayIndex -= 4; } // and reset SetPlayRound(0); // hide dummy pDOC->ExposeDummy(FALSE); // and reset display pDoc->ResetDisplay(); pMAINFRAME->ClearStatusMessage(); pDoc->SuppressPlayHistoryUpdate(FALSE); pDOC->UpdatePlayHistory(); // done return; }
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; }
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); }