home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
POKER
/
POKERVW.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-31
|
22KB
|
960 lines
// pokervw.cpp : implementation of the CPokerView class
//
#include "stdafx.h"
#include "poker.h"
#include "pokerdoc.h"
#include "pokervw.h"
#include "betdlg.h"
#include "cardback.h"
#include <time.h>
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
int what1 = 0;
int what2 = 0;
/////////////////////////////////////////////////////////////////////////////
// CPokerView
IMPLEMENT_DYNCREATE(CPokerView, CView)
BEGIN_MESSAGE_MAP(CPokerView, CView)
//{{AFX_MSG_MAP(CPokerView)
ON_WM_TIMER()
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_CHANGECARDBACKS, OnViewChangecardbacks)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_LBUTTONUP()
ON_COMMAND(ID_FILE_NEWGAME, OnFileNewgame)
ON_WM_LBUTTONDOWN()
ON_UPDATE_COMMAND_UI(ID_MOVES_BET, OnUpdateMovesBet)
ON_UPDATE_COMMAND_UI(ID_MOVES_CALL, OnUpdateMovesCall)
ON_UPDATE_COMMAND_UI(ID_MOVES_CHECK, OnUpdateMovesCheck)
ON_UPDATE_COMMAND_UI(ID_MOVES_FOLD, OnUpdateMovesFold)
ON_UPDATE_COMMAND_UI(ID_MOVES_RAISE, OnUpdateMovesRaise)
ON_COMMAND(ID_MOVES_BET, OnMovesBet)
ON_UPDATE_COMMAND_UI(ID_MOVES_DEAL, OnUpdateMovesDeal)
ON_COMMAND(ID_MOVES_DEAL, OnMovesDeal)
ON_COMMAND(ID_MOVES_CALL, OnMovesCall)
ON_COMMAND(ID_MOVES_FOLD, OnMovesFold)
ON_COMMAND(ID_MOVES_RAISE, OnMovesRaise)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPokerView construction/destruction
CPokerView::CPokerView()
{
// TODO: add construction code here
}
CPokerView::~CPokerView()
{
CPokerDoc* pDoc = GetDocument();
KillTimer(pDoc->nTimer);
}
/////////////////////////////////////////////////////////////////////////////
// CPokerView drawing
void CPokerView::OnDraw(CDC* pDC)
{
COLORREF Color = 0x00FFFFFF;
int i;
int j;
CPokerDoc* pDoc = GetDocument();
for (i = 0; i < NUMBER_PLAYERS; i++)
{
for (j = 0; j < 5; j++)
{
CDTDraw(pDC->GetSafeHdc(),
pDoc->CardLocation[i][j].x,
pDoc->CardLocation[i][j].y,
PlayerCard(i, j),
CardDrawMode(i, j),
Color);
}
}
}
void CPokerView::DrawOnePlayer(CClientDC* pDC, int nPlayer)
{
COLORREF Color = 0x00FFFFFF;
int j;
CPokerDoc* pDoc = GetDocument();
for (j = 0; j < 5; j++)
{
CDTDraw(pDC->GetSafeHdc(),
pDoc->CardLocation[nPlayer][j].x,
pDoc->CardLocation[nPlayer][j].y,
PlayerCard(nPlayer, j),
CardDrawMode(nPlayer, j),
Color);
}
}
CPokerView::PlayerCard(int nPlayer, int nCard)
{
CPokerDoc* pDoc = GetDocument();
// For debugging, uncomment the following line (also see CardDrawMode, below):
// return(pDoc->nHand[nPlayer][nCard]);
// For real play, use the following lines:
if (pDoc->bFace[nPlayer] ||
nPlayer == ME ||
pDoc->nGameState == SHOWDOWN ||
pDoc->nGameState == WAIT)
{
return(pDoc->nHand[nPlayer][nCard]);
}
else
{
return(pDoc->nCurrentBack);
}
}
CPokerView::CardDrawMode(int nPlayer, int nCard)
{
// For debugging uncomment the following line (also see PlayerCard, above):
// return(DRAW_FACES);
// For normal operation, use this code:
CPokerDoc* pDoc = GetDocument();
if (nPlayer == ME && pDoc->nCardState[nPlayer][nCard] == CARD_INVERT)
{
return(pDoc->nCardState[nPlayer][nCard]);
}
if (pDoc->nPlayerAction[nPlayer] == FOLD)
{
return(CARD_FOLD);
}
if (pDoc->nCardState[nPlayer][nCard] == CARD_INVERT ||
pDoc->nCardState[nPlayer][nCard] == CARD_DISCARD)
{
return(CARD_DISCARD);
}
if (pDoc->bFace[nPlayer] || nPlayer == ME)
{
return(DRAW_FACES);
}
else
{
return(DRAW_BACKS);
}
}
/////////////////////////////////////////////////////////////////////////////
// CPokerView printing
BOOL CPokerView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CPokerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CPokerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CPokerView diagnostics
#ifdef _DEBUG
void CPokerView::AssertValid() const
{
CView::AssertValid();
}
void CPokerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CPokerDoc* CPokerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPokerDoc)));
return (CPokerDoc*) m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPokerView message handlers
void CPokerView::OnTimer(UINT nIDEvent)
{
CPokerDoc* pDoc = GetDocument();
if (pDoc->nAnimationCounter <= 0 && // We're (over)due for back animation.
pDoc->nGameState != SHOWDOWN && // Don't animate showdown or wait
pDoc->nGameState != WAIT && // because card faces are being shown...
pDoc->nPlayerAction[DEALER] != FOLD)
{// We are in the middle of an animation sequence
OnAnimate();
if (++pDoc->nBackAnimate > 4)
{
pDoc->nBackAnimate = 0;
pDoc->nAnimationCounter = rand() % 25;
if (pDoc->nAnimationCounter < 6)
pDoc->nAnimationCounter += 6;
}
}
else
{
--pDoc->nAnimationCounter;
}
// Next, we perform a player's move, if there are any...
switch(pDoc->nGameState)
{
case DEAL:
pDoc->Deal();
break;
case FIRST_ROUND:
Play(pDoc->nCurrentPlayer);
break;
case DRAW_SELECT:
DrawSelect(pDoc->nCurrentPlayer);
break;
case DRAW_DISCARD:
DrawDiscard(pDoc->nCurrentPlayer);
break;
case DRAW_DEAL:
DrawDeal(pDoc->nCurrentPlayer);
break;
case SECOND_ROUND:
Play(pDoc->nCurrentPlayer);
break;
case SHOWDOWN:
Showdown(pDoc->nCurrentPlayer);
break;
case WAIT:
break;
}
// Finally, update the game's state, if appropriate:
pDoc->UpdateGameState();
// and in the end: call default handler, then return.
CView::OnTimer(nIDEvent);
}
void CPokerView::DrawSelect(int nPlayer)
{// For now, each player (except for me) will keep his cards.
if (nPlayer != ME)
{
TRACE("Player %d being delt his DRAW cards\n", nPlayer);
CPokerDoc* pDoc = GetDocument();
// Discard two cards at random...
// A final version would discard cards based on a strategy...
pDoc->nCardState[nPlayer][0] = CARD_INVERT;
pDoc->nCardState[nPlayer][3] = CARD_INVERT;
// Checking is a gutless move, with a strategy,
// a player would bet, fold or whatever:
pDoc->nPlayerAction[nPlayer] = CHECK;
pDoc->NextPlayer();
}
}
void CPokerView::DrawDiscard(int nPlayer)
{// For now, each player delete cards (from window) that were discarded.
int i;
int bTookCards = FALSE;
CPokerDoc* pDoc = GetDocument();
for (i = 0; i < 5; i++)
{
if (pDoc->nCardState[nPlayer][i] == CARD_INVERT)
{// card selected for replacement by the player
pDoc->nCardState[nPlayer][i] == CARD_DISCARD;
bTookCards = TRUE;
}
}
if (bTookCards)
{
CClientDC dc(this);
DrawOnePlayer(&dc, nPlayer);
}
TRACE("Player %d discarding\n", nPlayer);
pDoc->nPlayerAction[nPlayer] = CHECK;
pDoc->NextPlayer();
}
void CPokerView::DrawDeal(int nPlayer)
{// For now, each player deal & display their new cards.
TRACE("Player %d getting his new cards\n", nPlayer);
CPokerDoc* pDoc = GetDocument();
if (pDoc->DealDraw(nPlayer))
{
CClientDC dc(this);
DrawOnePlayer(&dc, nPlayer);
}
pDoc->nPlayerAction[nPlayer] = CHECK;
pDoc->NextPlayer();
}
void CPokerView::Showdown(int nPlayer)
{// Show each player's cards. Do it in a block?
CPokerDoc* pDoc = GetDocument();
pDoc->bFace[nPlayer] = TRUE;
pDoc->nPlayerAction[nPlayer] = CHECK;
pDoc->NextPlayer();
CClientDC dc(this);
DrawOnePlayer(&dc, nPlayer);
}
void CPokerView::Play(int nPlayer)
{
int i;
int nHandPotential;
int nPlayerBet = 0;
int nFirst = TRUE;
int nBet = FALSE;
int nFold = FALSE;
int nRaise = FALSE;
int nIRaise = FALSE;
int nIBet = FALSE;
int nICall = FALSE;
// Each of the computer's hands (0, 1 and 2) must be played. The valid actions
// must be determined, and then an appropriate action must be taked.
// Pass 1: Always BET $10, don't raise, fold or check...
CPokerDoc* pDoc = GetDocument();
if (pDoc->nPlayerAction[nPlayer] == FOLD)
{// This player is out of the loop!
return;
}
// Determine what action to take.
// First, am I the first to actually play.
if (nPlayer != ME)
{
if (pDoc->nPlayerAction[nPlayer] == BET)
nIBet = TRUE;
if (pDoc->nPlayerAction[nPlayer] == FOLD)
nICall = TRUE;
if (pDoc->nPlayerAction[nPlayer] == RAISE)
nIRaise = TRUE;
for (i = 0; i < NUMBER_PLAYERS; i++)
{
if (i != nPlayer)
{
if (pDoc->nPlayerAction[i] != NOTHING &&
pDoc->nPlayerAction[i] != CHECK)
{// This player is out of the loop!
nFirst = FALSE;
}
if (pDoc->nPlayerAction[i] == BET)
{// This player BET!
nBet = TRUE;
}
if (pDoc->nPlayerAction[i] == FOLD)
{// This player FOLDed!
nFold = TRUE;
}
if (pDoc->nPlayerAction[i] == RAISE)
{// This player FOLDed!
nRaise = TRUE;
}
}
}
if (nFirst || !nBet)
{// Nobody's bet yet. This playereither BET, FOLD, or CHECK (if first)
nHandPotential = pDoc->EvaluateFirst(nPlayer);
switch(nHandPotential)
{
case ROYAL_FLUSH :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 3;
break;
case STRAIGHT_FLUSH :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 3;
break;
case FOUR_OF_KIND :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 3;
break;
case FULL_HOUSE :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 3;
break;
case FLUSH :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 3;
break;
case STRAIGHT :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 3;
break;
case THREE_OF_KIND :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 4;
break;
case TWO_PAIR :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 3;
break;
case ONE_PAIR :
pDoc->nPlayerAction[nPlayer] = BET;
nPlayerBet = 2;
break;
case POSSIBLE_STRAIGHT :
if (!nFirst) // Can't check
pDoc->nPlayerAction[nPlayer] = FOLD;
else
pDoc->nPlayerAction[nPlayer] = CHECK;
break;
case POSSIBLE_FLUSH :
if (!nFirst) // Can't check
pDoc->nPlayerAction[nPlayer] = FOLD;
else
pDoc->nPlayerAction[nPlayer] = CHECK;
break;
case GOT_SQUAT :
pDoc->nPlayerAction[nPlayer] = FOLD;
break;
}
}
else
{// Just playing along, can either FOLD, CALL, or RAISE
nHandPotential = pDoc->EvaluateFirst(nPlayer);
switch(nHandPotential)
{
case ROYAL_FLUSH :
if (nIBet && !nRaise) // Can't raise if I bet and another player didn't raise
{
pDoc->nPlayerAction[nPlayer] = CALL;
}
else
{
pDoc->nPlayerAction[nPlayer] = RAISE;
nPlayerBet = 4;
}
break;
case STRAIGHT_FLUSH :
if (nIBet && !nRaise) // Can't raise if I bet and another player didn't raise
{
pDoc->nPlayerAction[nPlayer] = CALL;
}
else
{
pDoc->nPlayerAction[nPlayer] = RAISE;
nPlayerBet = 5;
}
break;
case FOUR_OF_KIND :
if (nIBet && !nRaise) // Can't raise if I bet and another player didn't raise
{
pDoc->nPlayerAction[nPlayer] = CALL;
}
else
{
pDoc->nPlayerAction[nPlayer] = RAISE;
nPlayerBet = 5;
}
break;
case FULL_HOUSE :
if (nIBet && !nRaise) // Can't raise if I bet and another player didn't raise
{
pDoc->nPlayerAction[nPlayer] = CALL;
}
else
{
pDoc->nPlayerAction[nPlayer] = RAISE;
nPlayerBet = 5;
}
break;
case FLUSH :
if (nIBet && !nRaise) // Can't raise if I bet and another player didn't raise
{
pDoc->nPlayerAction[nPlayer] = CALL;
}
else
{
pDoc->nPlayerAction[nPlayer] = RAISE;
nPlayerBet = 4;
}
break;
case STRAIGHT :
pDoc->nPlayerAction[nPlayer] = CALL;
break;
case THREE_OF_KIND :
pDoc->nPlayerAction[nPlayer] = CALL;
break;
case TWO_PAIR :
pDoc->nPlayerAction[nPlayer] = CALL;
break;
case ONE_PAIR :
pDoc->nPlayerAction[nPlayer] = CALL;
break;
case POSSIBLE_STRAIGHT :
pDoc->nPlayerAction[nPlayer] = CALL;
break;
case POSSIBLE_FLUSH :
pDoc->nPlayerAction[nPlayer] = CALL;
break;
case GOT_SQUAT :
pDoc->nPlayerAction[nPlayer] = FOLD;
break;
}
}
}
if (nPlayer != ME)
{// My plays are by me.
PlayerAction(nPlayer, nPlayerBet);
}
}
void CPokerView::PlayerAction(int nPlayer, int nPlayerBet)
{
TRACE("GETTING THE DOCUMENT>>>>>>>>>>>>\n");
CPokerDoc* pDoc = GetDocument();
switch(pDoc->nPlayerAction[nPlayer])
{
case BET:
pDoc->Bet(nPlayer, nPlayerBet);
break;
case CALL:
pDoc->Call(nPlayer);
break;
case FOLD:
{
pDoc->Fold(nPlayer);
CClientDC dc(this);
DrawOnePlayer(&dc, nPlayer);
}
break;
case RAISE:
pDoc->Raise(nPlayer, nPlayerBet);
break;
case CHECK:
pDoc->Check(nPlayer);
break;
default:
TRACE("INVALID: action by a player\n");
break;
}
pDoc->NextPlayer();
}
void CPokerView::OnAnimate()
{// happens when the backs are to be animated.
int nReturn;
CPokerDoc* pDoc = GetDocument();
if (pDoc->nBackAnimate == 0)
{// Pick a card to animate
pDoc->nAnimateCard = rand() % 4;
}
CClientDC dc(this);
nReturn = CDTAnimate(dc.GetSafeHdc(),
pDoc->nCurrentBack,
pDoc->CardLocation[1][pDoc->nAnimateCard].x,
pDoc->CardLocation[1][pDoc->nAnimateCard].y,
pDoc->nBackAnimate);
}
int CPokerView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CPokerDoc* pDoc = GetDocument();
/* We use the timer to control the following things:
*
* 1. Some of the card backs are capable of animation. These include the hand
* holding cards, sun, robot and castle backs. We install a timer, set it to
* four tenth's of a second and when timer goes off, we decrement the back animation
* counter. When this timer is == 0, we animate a random card belonging to the
* dealer. As well, after we start animating the card,
* we countdown the animation, and then set a new back animation timer value.
*/
pDoc->nTimer = SetTimer(9, 400, NULL);
if (pDoc->nTimer == 0)
{// Couldn't set the timer. Bummer, no game today...
TRACE("Couldn't set the timer. Bummer, no game today...\n");
// END THE PROGRAM HERE!
}
// TODO: Add your specialized creation code here
return 0;
}
void CPokerView::OnViewChangecardbacks()
{
CCardBack Dialog;
CPokerDoc* pDoc = GetDocument();
Dialog.m_nCardBack = pDoc->nCurrentBack;
Dialog.DoModal();
if (Dialog.m_nCardBack != pDoc->nCurrentBack)
{// The user selected a new back!
pDoc->nCurrentBack = Dialog.m_nCardBack;
CClientDC dc(this);
InvalidateRect(NULL, TRUE);
}
}
void CPokerView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
TRACE("Sized with a view width of %d and height of %d\n", cx, cy);
}
void CPokerView::OnDestroy()
{
CView::OnDestroy();
// TODO: Add your message handler code here
// Shutdown the CARDS.DLL code.
CDTTerm();
}
void CPokerView::OnLButtonUp(UINT nFlags, CPoint point)
{
int i;
// Used only when selecting cards to discard...
CPokerDoc* pDoc = GetDocument();
for (i = 0; i < 5; i++)
{// Look at each of my cards...
if (point.x > pDoc->CardLocation[3][i].x &&
point.x < pDoc->CardLocation[3][i].x + pDoc->nWidth &&
point.y > pDoc->CardLocation[3][i].y &&
point.y < pDoc->CardLocation[3][i].y + pDoc->nHeight)
{// This is the card selected!
if (pDoc->nCardState[3][i] == CARD_INVERT)
{// Toggle the card's display state:
pDoc->nCardState[3][i] = CARD_OK;
}
else
{
pDoc->nCardState[3][i] = CARD_INVERT;
}
COLORREF Color = 0x00FFFFFF;
CClientDC dc(this);
CDTDraw(dc.GetSafeHdc(),
pDoc->CardLocation[3][i].x,
pDoc->CardLocation[3][i].y,
PlayerCard(3, i),
CardDrawMode(3, i),
Color);
}
}
CView::OnLButtonUp(nFlags, point);
}
void CPokerView::OnFileNewgame()
{
// TODO: Add your command handler code here
CPokerDoc* pDoc = GetDocument();
pDoc->NewGame();
InvalidateRect(NULL, TRUE);
}
void CPokerView::OnLButtonDown(UINT nFlags, CPoint point)
{// We don't care for button down messages in this version.
// TODO: Add your message handler code here and/or call default
CView::OnLButtonDown(nFlags, point);
}
void CPokerView::OnUpdateMovesBet(CCmdUI* pCmdUI)
{
// Enable the button if we can BET.
int i;
CPokerDoc* pDoc = GetDocument();
pDoc->bCanBet = TRUE;
for (i = 0; i < NUMBER_PLAYERS; i++)
{
if (pDoc->nPlayerAction[i] == BET ||
pDoc->nPlayerAction[i] == CALL ||
pDoc->nPlayerAction[i] == RAISE)
{
pDoc->bCanBet = FALSE;
}
}
if (pDoc->bCanBet &&
pDoc->nPlayerAction[ME] != FOLD &&
pDoc->nCurrentPlayer == ME &&
pDoc->nGameState != WAIT)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
}
void CPokerView::OnUpdateMovesCall(CCmdUI* pCmdUI)
{
// Enable the button if we can CALL.
int i;
CPokerDoc* pDoc = GetDocument();
pDoc->bCanCall = FALSE;
for (i = 0; i < NUMBER_PLAYERS; i++)
{
if (pDoc->nPlayerAction[i] == BET ||
pDoc->nPlayerAction[i] == CALL ||
pDoc->nPlayerAction[i] == RAISE)
{
pDoc->bCanCall = TRUE;
}
}
if (pDoc->bCanCall &&
pDoc->nPlayerAction[ME] != FOLD &&
pDoc->nCurrentPlayer == ME &&
pDoc->nGameState != DRAW_SELECT &&
pDoc->nGameState != DRAW_DISCARD &&
pDoc->nGameState != DRAW_DEAL &&
pDoc->nGameState != WAIT)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
}
void CPokerView::OnUpdateMovesCheck(CCmdUI* pCmdUI)
{
// Enable the button if we can CHECK.
int i;
CPokerDoc* pDoc = GetDocument();
pDoc->bCanCheck = TRUE;
for (i = 0; i < NUMBER_PLAYERS; i++)
{
if (pDoc->nPlayerAction[i] != CHECK && pDoc->nPlayerAction[i] != NOTHING)
{
pDoc->bCanCheck = FALSE;
}
}
if (pDoc->bCanCheck &&
pDoc->nPlayerAction[ME] != FOLD &&
pDoc->nCurrentPlayer == ME &&
pDoc->nGameState != DRAW_SELECT &&
pDoc->nGameState != DRAW_DISCARD &&
pDoc->nGameState != DRAW_DEAL &&
pDoc->nGameState != WAIT)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
}
void CPokerView::OnUpdateMovesFold(CCmdUI* pCmdUI)
{
// Enable the button if we can FOLD.
CPokerDoc* pDoc = GetDocument();
if (pDoc->bCanFold &&
pDoc->nCurrentPlayer == ME &&
pDoc->nGameState != DRAW_SELECT &&
pDoc->nGameState != DRAW_DISCARD &&
pDoc->nGameState != DRAW_DEAL &&
pDoc->nGameState != WAIT)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
}
void CPokerView::OnUpdateMovesRaise(CCmdUI* pCmdUI)
{
// Enable the button if we can RAISE.
int i;
CPokerDoc* pDoc = GetDocument();
pDoc->bCanRaise = FALSE;
for (i = 0; i < NUMBER_PLAYERS; i++)
{
if (i != ME &&
(pDoc->nPlayerAction[i] == BET ||
pDoc->nPlayerAction[i] == RAISE))
{
pDoc->bCanRaise = TRUE;
}
}
if (pDoc->bCanRaise &&
pDoc->nPlayerAction[ME] != FOLD &&
pDoc->nCurrentPlayer == ME &&
pDoc->nGameState != DRAW_DISCARD &&
pDoc->nGameState != WAIT)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
}
void CPokerView::OnMovesBet()
{// I've decided to bet.
int nCurrentBet = 0;
CPokerDoc* pDoc = GetDocument();
CBetDlg Dialog;
Dialog.DoModal();
pDoc->Bet(ME, Dialog.m_nBetAmount);
pDoc->NextPlayer();
}
void CPokerView::OnUpdateMovesDeal(CCmdUI* pCmdUI)
{
// The user can do a new deal with a button.
int bEnable = FALSE;
CPokerDoc* pDoc = GetDocument();
if (pDoc->nGameState > SHOWDOWN ||
(pDoc->nGameState == DRAW_SELECT && pDoc->nCurrentPlayer == ME))
{
bEnable = TRUE;
}
pCmdUI->Enable(bEnable);
}
void CPokerView::OnMovesDeal()
{
// TODO: Add your command handler code here
TRACE("OnMovesDeal called\n");
CPokerDoc* pDoc = GetDocument();
if (pDoc->nGameState >= SHOWDOWN)
{
pDoc->Deal();
}
else
{
TRACE("I've done my draw...\n");
pDoc->nPlayerAction[ME] = CHECK;
pDoc->NextPlayer();
}
}
void CPokerView::OnMovesCall()
{
TRACE("OnMovesCall called\n");
CPokerDoc* pDoc = GetDocument();
pDoc->Call(ME);
pDoc->NextPlayer();
}
void CPokerView::OnMovesFold()
{
TRACE("OnMovesFold called\n");
CPokerDoc* pDoc = GetDocument();
pDoc->Fold(ME);
CClientDC dc(this);
DrawOnePlayer(&dc, ME);
pDoc->NextPlayer();
}
void CPokerView::OnMovesRaise()
{
int nCurrentBet = 0;
TRACE("OnMovesBet called\n");
CPokerDoc* pDoc = GetDocument();
CBetDlg Dialog;
Dialog.DoModal();
pDoc->Raise(ME, Dialog.m_nBetAmount);
pDoc->NextPlayer();
}