#ifndef _C_GAME_LOGIC_FRAME_H_INCLUDE_
#define _C_GAME_LOGIC_FRAME_H_INCLUDE_

#include "cdefines.h"
#include "GameLogic.h"
#include <map>
#include <vector>

class CServerLogicFrame : public ServerLogicFrame
{
public:
	/// 캯
	CServerLogicFrame();
	/// 
	~CServerLogicFrame();

	/// õǰӦ÷
	virtual void SetGameRoom(Room* pRoom) { m_g_GameRoom = pRoom; }
	/// ڴûʼϷʼϢ
	virtual void OnProcessPlayerGameStartMes();
	/// ڴûϷϢ
	virtual void OnProcessPlayerRoomMes(int playerId,Json::Value &mes);
	/// û뷿Ϣ
	virtual void OnProcessEnterRoomMsg(int playerId);
	/// û뿪Ϣ
	virtual void OnProcessLeaveRoomMsg(int playerId);
	/// ûϢ
	virtual void OnProcessReEnterRoomMes(int playerId);
	/// ûϢ
	virtual void OnProcessOfflineRoomMes(int playerId);
	/// ûʱϢ
	virtual void OnProcessTimerMsg(int timerId,int curTimer);

private:
	//ҽз
	bool OnUserLandScore(uint16 wChairID, int bLandScore);
	//
	bool OnUserBrightCard(uint16 wChairID);
	//ҳ
	bool OnUserOutCard(uint16 wChairID, uint8 bCardData[], int bCardCount);
	//ҷ
	bool OnUserPassCard(uint16 wChairID);
	//й
	bool OnUserTrustee(uint16 wChairID,int isAutoPlay);
	//jackPot
	bool OnJackPot(int nBoomCount);

private:
	// ϷԴ
	void Clear(void);
	// Ϸ
	void OverGame(uint16 wChairID,Room *pRoom,bool isrunarray=false);
	//
	bool Test(uint8 bAllCard[]);


private:
	Room *m_g_GameRoom;                                  /**< Ϸ */

protected:
	int								 m_bCallScorePhase;			//ƽ׶
	int								 m_curGameState;			//ǰϷ״̬

	//
protected:
	CGameLogic						m_GameLogic;						//Ϸ߼

	//˿Ϣ
protected:
	uint8							m_bBackCard[3];						//Ϸ
	int								m_bCardCount[GAME_PLAYER];			//˿Ŀ
	int								m_bOutCardCount[GAME_PLAYER];		//ƴ
	uint8							m_bHandCardData[GAME_PLAYER][20];	//˿

	uint8							m_cbLastTurnOutCard[GAME_PLAYER][MAX_COUNT];	//ֳ
	uint8							m_cbNowTurnOutCard[GAME_PLAYER][MAX_COUNT];		//ֳ
	int								m_nLastTurnOutCount[GAME_PLAYER];				//ֳĿ
	int								m_nNowTurnOutCount[GAME_PLAYER];				//ֳĿ

	//Ϸ
protected:
	int							m_cbCount;							//ֹط
	int							m_lSnatchLand;						//
	int							m_lBrightCard;						//Ʊ
	int							m_wBombTime;						//ը
	int							m_lThuntian;						//챶
	int							m_bLandScore;						//
	int							m_wShowTimes;						//ʾ
	uint16						m_wFirstUser;						//׽û
	uint16						m_wBankerUser;						//ׯû
	uint16						m_wCurrentUser;						//ǰ
	int							m_bScoreInfo[3];					//зϢ
	uint16						m_wChairID;							//ʱӺ
	int							m_breSendCardTimes;					//·ƴ
	bool						m_GameOver;							//Ϸ
	uint16						m_GameOverChair;					//Ϸ߻ҵӺ
	bool						m_UserStandUp[GAME_PLAYER];			//ûʶ

	//Ϣ
protected:
	uint16							m_wTurnWiner;						//ʤ
	int								m_bTurnCardCount;					//Ŀ
	uint8							m_bTurnCardData[20];				//б
	bool							m_bUserTrustee[GAME_PLAYER];		//й
	bool                            m_bUserOffLine[GAME_PLAYER];        //ҵ״̬
	bool							m_PassTime[GAME_PLAYER];			//ߡʱ
	bool							m_bUserPass[GAME_PLAYER];			//ҡ
	bool							m_bEndFlag;
	bool							m_bYaPaiFlag;
	bool							m_bEndOrReadyFlag;					//Ŷӻ׶
	//bool							m_FirstUserLife;					//׶ǲǵһ뿪
	bool							m_wCloseWarmingFlash;
	int                             m_UserLeaveCount;					//뿪
	bool							m_MatchOver;						//һֱʶ

	//зֽ׶α
protected:
	bool							m_bBrightCard[GAME_PLAYER];			//ģʽ
	bool							m_bGiveUpBanker[GAME_PLAYER];		//ʶ
	int							    m_cbLandScoreCount;					//зִ

protected:
	int								m_BoomCount;					//ѳը(jackPot)
};

#endif
