#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:
	/// ĳֻɫܵע
	int64 ComputerCardColorTotalJetton(uint8 cardcolor);
	/// õָܵע
	int64 ComputerUserTotalJetton(uint32 pUserId);
	/// õָָɫע
	int64 ComputerUserCardColorTotalJetton(uint32 pUserId,uint8 cardcolor);
	/// õǰ׬ǮٵĻɫ
	int ComputerCardColorTotalResult(int64 presult);
	/// õǰĻɫ
	int ComputerCardColorFailTotalResult(int64 *presult);
	/// עõ
	uint8 GetResultCard(void);
	/// Ϸ
	void TradGame(void);
	/// ע¼
	void ClearJettonRecord(void);
	/// Ϸ
	void LoadGameConfig(void);

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

	CGameLogic m_CGameLogic;
	GameState m_GameState;
	uint8 m_resultCard;                                   /**<  */
	int64 m_GamePielement;                                    /**< Ϸ */

	bool m_gamisrunning;

	std::map<uint8,float>     m_jettonTrad;                    /**< ɫ */
	std::map<uint8,int>       m_colorrecordcount;              /**< ɫִ */
	std::map<uint32,tagJettons> m_userjettonresult;              /**< ûѺע */
	std::vector<uint8>        m_cardrecord;                    /**< Ϸ¼ */
	int                      m_gamejvcount;                   /**< Ϸ */

	float m_fangkuai, m_meihua, m_heitao, m_hongtao, m_wang;
	int m_timegamestart, m_timexiazhu, m_timekaipai, m_timejiesuan;
	int m_unitmoney;
	float m_choushui;
};

#endif
