www.pudn.com > goodchessGame.zip > GameController.h


#if !defined(AFX_GAMECONTROLLER_H__8D543E6F_81F7_422F_96B2_330ABDB8DC0F__INCLUDED_) 
#define AFX_GAMECONTROLLER_H__8D543E6F_81F7_422F_96B2_330ABDB8DC0F__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
// GameController.h : header file 
// 
 
#include "Player.h" 
#include "Deck.h" 
#include "Floor.h" 
#include "FloorDialog.h" 
#include "OptionsDialog.h" 
#include "WinDialog.h" 
#include "ListeningSocket.h" 
#include "FiveInOneSocket.h" 
#include "Pakage.h" 
#include "FiveInOneWaitDialog.h" 
#include  
class CFiveInOneDoc; 
 
///////////////////////////////////////////////////////////////////////////// 
// CGameController view 
 
//  This is the main class of the game and is responsible for all the coordination 
 
class CGameController : public CView  
{ 
protected: 
	HCURSOR m_PrevCursor; 
	HCURSOR m_HDrag;		//cursor displayed while a card is being dragged 
	HCURSOR m_HSelection;	//cursor displayed when selection is in progress 
	CBrush m_BackgroundBrush; 
	CBitmap m_BackgroundBitmap; 
 
	CMenu m_Menu; 
	CMenu m_MainMenu; 
 
	int *m_pTotalCards; 
	int m_nNumOfDecks; 
	int m_nTotalNumberOfPlayers; 
 
	int m_DraggedCardIndex; 
	BOOL m_bDragging; 
 
	BOOL m_bSelection; 
	CSize m_Size; 
	CPoint m_OriginalPoint; 
 
	CPoint *m_pStartingPoints; 
	BOOL *m_pXConstants; 
	int m_nProgressCounter; 
	static int itimer; 
	BOOL m_bAnimating; 
protected: 
	void GenerationOfRandomNumbers(); 
	void DeckInitialization(); 
	void FloorInitialization(); 
	BOOL Timer(CTypedPtrList *pPlayerList); 
     
	CGameController();           // protected constructor used by dynamic creation 
	//DECLARE_DYNCREATE(CGameController) 
 
// Attributes 
public: 
	CFiveInOneDoc* GetDocument(); 
 
// Operations 
public: 
 
// Overrides 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CGameController) 
	public: 
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view 
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 
	//}}AFX_VIRTUAL 
 
// Implementation 
public: 
	virtual ~CGameController(); 
	virtual void CleanUp(); 
protected: 
#ifdef _DEBUG 
	virtual void AssertValid() const; 
	virtual void Dump(CDumpContext& dc) const; 
#endif 
 
	// Generated message map functions 
protected: 
	//{{AFX_MSG(CGameController) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
 
public: 
	virtual void Begin() = 0; 
	virtual void CreationOfPlayers() 
	{} 
	void SetPlayerID(int id); 
	int GetPlayerID(); 
	COptionsDialog &m_Dlg;	//this dialog presents the options of the game 
protected: 
	int m_PlayerID; 
	CDeck m_Deck;			//the deck of the game 
	CFloor m_Floor;			//the floor is the place wheere the cards are thrown 
	CFloorDialog* m_pFloorDlg; 
	CFiveInOneWaitDialog m_WaitDialog; 
	CWinDialog m_WinDlg; 
	short m_nGameType; 
public: 
	afx_msg void OnFileDeal(); 
	afx_msg void OnUpdateFileDeal(CCmdUI *pCmdUI); 
	afx_msg void OnFileDeck(); 
	afx_msg void OnUpdateFileDeck(CCmdUI *pCmdUI); 
	virtual void OnInitialUpdate(); 
public: 
	BOOL m_bPlay; 
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); 
	afx_msg BOOL OnEraseBkgnd(CDC* pDC); 
 
	DECLARE_DYNAMIC(CGameController); 
}; 
 
#ifndef _DEBUG  // debug version in FiveInOneView.cpp 
inline CFiveInOneDoc* CGameController::GetDocument() 
   { return (CFiveInOneDoc*)m_pDocument; } 
#endif 
 
class CSingleCompGameController : public CGameController 
{ 
public: 
	CSingleCompGameController() 
	{ 
	} 
protected: 
	virtual ~CSingleCompGameController(){} 
	virtual void CleanUp() { CGameController::CleanUp(); } 
	virtual void OnDraw(CDC* pDC);    // overridden to draw this view 
	//DECLARE_DYNCREATE(CSingleCompGameController) 
public: 
	virtual void Begin() = 0; 
 
	DECLARE_MESSAGE_MAP() 
	DECLARE_DYNAMIC(CSingleCompGameController); 
}; 
 
class CNetworkGameController : public CGameController 
{ 
public: 
	CNetworkGameController(){ 
		m_pListeningSocket = NULL; 
		m_pFiveInOneSocket = NULL; 
		m_bIsHost = FALSE; 
		m_bItsMyTurn = FALSE; 
		m_bReadyToDeal = TRUE; 
	} 
protected: 
	virtual ~CNetworkGameController() 
	{ 
		delete m_pListeningSocket; 
		delete m_pFiveInOneSocket; 
	} 
	virtual void CleanUp() 
	{ 
		CGameController::CleanUp(); 
		m_bItsMyTurn = FALSE; 
	} 
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view 
	//DECLARE_DYNCREATE(CNetworkGameController) 
public: 
	virtual void Begin() = 0; 
	virtual void ProcessMessage(DataPacket &dp); 
	void Send(DataPacket & dp, int nLen); 
	BOOL CheckNames(CStringList &rList); 
	HRESULT OnSocketMessage(WPARAM wParam, LPARAM lParam); 
 
	BOOL IsHost();			//indicates whether the player is the host or the client 
	void SetHost(BOOL bIsHost);		//sets the player as a host or client 
 
    DECLARE_MESSAGE_MAP() 
protected: 
	BOOL m_bIsHost;			//this indicates whether the player is the host or the client 
	CListeningSocket *m_pListeningSocket; 
	CFiveInOneSocket *m_pFiveInOneSocket; 
	CStringList m_NameList; 
public: 
	BOOL m_bItsMyTurn; 
	BOOL m_bReadyToDeal; 
	DECLARE_DYNAMIC(CNetworkGameController); 
}; 
 
///////////////////////////////////////////////////////////////////////////// 
 
//{{AFX_INSERT_LOCATION}} 
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. 
 
#endif // !defined(AFX_GAMECONTROLLER_H__8D543E6F_81F7_422F_96B2_330ABDB8DC0F__INCLUDED_)