void PartnerInformation::Draw(int animationOffsetPartner, int yOffset) { if (GetPartner() == NULL) { return; } Vector2 offsetVector = Vector2(animationOffsetPartner, yOffset); Vector2 partnerNamePosition = Vector2( partnerNameRectangle.GetX() + partnerNameRectangle.GetWidth() / 2 - pHeadingFont->GetWidth(GetPartner()->GetName()) / 2, partnerNameRectangle.GetY() + partnerNameRectangle.GetHeight() / 2 - pHeadingFont->GetHeight(GetPartner()->GetName()) / 2 - 1); partnerNamePosition = Vector2(floor(0.5 + partnerNamePosition.GetX()), floor(0.5 + partnerNamePosition.GetY())); pBackgroundImage->Draw(backgroundImagePosition + offsetVector); pHeadingFont->Draw(GetPartner()->GetName(), partnerNamePosition + offsetVector); GetPartner()->GetProfileImageSprite()->Draw(profileImagePosition + offsetVector); double currentYOffset = (AbilityDescriptionHeight - (double)passiveAbilityDescriptionLines.size() * pBodyFont->GetLineHeight() - ((double)passiveAbilityDescriptionLines.size() - 1) * AbilityDescriptionExtraLineHeight) / 2; for (unsigned int i = 0; i < passiveAbilityDescriptionLines.size(); i++) { pBodyFont->Draw(passiveAbilityDescriptionLines[i], passiveAbilityDescriptionPosition + offsetVector + Vector2(0, currentYOffset)); currentYOffset += pBodyFont->GetLineHeight() + AbilityDescriptionExtraLineHeight; } currentYOffset = (AbilityDescriptionHeight - activeAbilityDescriptionLines.size() * pBodyFont->GetLineHeight() - ((double)activeAbilityDescriptionLines.size() - 1) * AbilityDescriptionExtraLineHeight) / 2; for (unsigned int i = 0; i < activeAbilityDescriptionLines.size(); i++) { pBodyFont->Draw(activeAbilityDescriptionLines[i], activeAbilityDescriptionPosition + offsetVector + Vector2(0, currentYOffset)); currentYOffset += pBodyFont->GetLineHeight() + AbilityDescriptionExtraLineHeight; } pHeadingFont->Draw("Passive ability", passiveAbilityHeadingPosition + offsetVector); pHeadingFont->Draw("Active ability", activeAbilityHeadingPosition + offsetVector); }
// //--------------------------------------------------------- // 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; }
// // 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 Gate::SetWorldPosition(Coordinate c) { this->_SetWorldPosition(c); GetPartner()->_SetWorldPosition(c); }
void Gate::SetAngle(float angle) { this->_SetAngle(angle); GetPartner()->_SetAngle(angle); }