/* * playhand: * Do up one hand of the game */ int playhand(bool mycrib) { int deckpos; werase(Compwin); wrefresh(Compwin); werase(Tablewin); wrefresh(Tablewin); knownum = 0; deckpos = deal(mycrib); sorthand(chand, FULLHAND); sorthand(phand, FULLHAND); makeknown(chand, FULLHAND); prhand(phand, FULLHAND, Playwin, FALSE); discard(mycrib); if (cut(mycrib, deckpos)) return TRUE; if (peg(mycrib)) return TRUE; werase(Tablewin); wrefresh(Tablewin); if (score(mycrib)) return TRUE; return FALSE; }
/* verify the guessed code made by code breaker */ bool GameBoard :: verify_guess(int attempt_number) { /* Get the code pegs at particular attempt */ vector<Peg> code_row = get_code_peg_row(attempt_number); vector<Peg> shield_row = shield_pegs_row.get_pegs_row(); for(unsigned int idx = 0; idx < code_row.size(); idx++) { Peg code_peg = code_row[idx]; Peg shield_peg = shield_row[idx]; /* If colors are same at particular position then set feedback as white */ if( code_peg.get_color() == shield_peg.get_color()) { Peg peg(PegType::FEEDBACK,PegColor::WHITE); set_feedback_peg(attempt_number,idx,peg); } /* If color is present in shield code but not in correct position, set feedback as black */ else if (check_color_exist_in_shield(code_peg.get_color())) { Peg peg(PegType::FEEDBACK,PegColor::BLACK); set_feedback_peg(attempt_number,idx,peg); } /* Else set feedback code as Empty */ else { Peg peg(PegType::FEEDBACK,PegColor::EMPTY); set_feedback_peg(attempt_number,idx,peg); } } unsigned int idx = 0; vector<Peg> feedback_row = get_feedback_peg_row(attempt_number); /* if all colors are white in feedback code. It means user had guessed all codes correctly */ for(idx = 0; idx < feedback_row.size(); idx++) { if (feedback_row[idx].get_color() != PegColor :: WHITE) break; } return idx == shield_row.size(); }
/* To be used by code maker */ void GameBoard :: create_shield_code() { srand(time(nullptr)); for (unsigned int idx=0; idx < pegs_in_row; idx++) { PegColor clr = get_random_color(); Peg peg(PegType::CODE, clr); shield_pegs_row.set_peg(idx, peg); } }
void CCopyDlg::OnLvnGetdispinfoExternalslist(NMHDR *pNMHDR, LRESULT *pResult) { NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR); *pResult = 0; if (m_ExtList.HasText()) return; if (pDispInfo) { if (pDispInfo->item.iItem < (int)m_externals.size()) { SVNExternal ext = m_externals[pDispInfo->item.iItem]; if (pDispInfo->item.mask & LVIF_INDENT) { pDispInfo->item.iIndent = 0; } if (pDispInfo->item.mask & LVIF_IMAGE) { pDispInfo->item.mask |= LVIF_STATE; pDispInfo->item.stateMask = LVIS_STATEIMAGEMASK; if (ext.adjust) { //Turn check box on pDispInfo->item.state = INDEXTOSTATEIMAGEMASK(2); } else { //Turn check box off pDispInfo->item.state = INDEXTOSTATEIMAGEMASK(1); } } if (pDispInfo->item.mask & LVIF_TEXT) { switch (pDispInfo->item.iSubItem) { case 0: // folder { CTSVNPath p = ext.path; p.AppendPathString(ext.targetDir); lstrcpyn(m_columnbuf, p.GetWinPath(), min(MAX_PATH-2, pDispInfo->item.cchTextMax)); int cWidth = m_ExtList.GetColumnWidth(0); cWidth = max(28, cWidth-28); CDC * pDC = m_ExtList.GetDC(); if (pDC != NULL) { CFont * pFont = pDC->SelectObject(m_ExtList.GetFont()); PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth); pDC->SelectObject(pFont); ReleaseDC(pDC); } } break; case 1: // url { lstrcpyn(m_columnbuf, ext.url, min(MAX_PATH-2, pDispInfo->item.cchTextMax)); SVNRev peg(ext.pegrevision); if (peg.IsValid() && !peg.IsHead()) { wcscat_s(m_columnbuf, L"@"); wcscat_s(m_columnbuf, peg.ToString()); } int cWidth = m_ExtList.GetColumnWidth(1); cWidth = max(14, cWidth-14); CDC * pDC = m_ExtList.GetDC(); if (pDC != NULL) { CFont * pFont = pDC->SelectObject(m_ExtList.GetFont()); PathCompactPath(pDC->GetSafeHdc(), m_columnbuf, cWidth); pDC->SelectObject(pFont); ReleaseDC(pDC); } } break; case 2: // tagged m_columnbuf[0] = 0; if (ext.origrevision.kind == svn_opt_revision_number) swprintf_s(m_columnbuf, L"%ld", ext.origrevision.value.number); else if (ext.origrevision.kind == svn_opt_revision_date) { SVNRev r(ext.origrevision); wcscpy_s(m_columnbuf, (LPCTSTR)r.ToString()); } break; default: m_columnbuf[0] = 0; } pDispInfo->item.pszText = m_columnbuf; } } } }