#ifndef _C_PLAYER_H_INCLUDE_
#define _C_PLAYER_H_INCLUDE_

#include <string>

#include "../gameserver_common.h"

#include "../../include/molnet/Network.h"
#include "../../include/Common/Player.h"
#include "../../include/Common/Robotlogicframe.h"

#include "../../include/molnet/netallocator/NedAllocatedObject.h"

//class CPlayer;
//class RobotLogicFrame;

class CPlayer : public Player , public NedAllocatedObject
{
public:
	CPlayer(PlayerType type);
	CPlayer(int id,uint32 conid);
	~CPlayer();

	/// ID
	virtual void SetID(int id) { m_Id = id; }
	/// õID
	virtual int GetID(void) { return m_Id; }
	/// ID
	virtual void SetConnectID(uint32 id) { m_ConnectId = id; }
	/// õID
	virtual uint32 GetConnectID(void) { return m_ConnectId; }
	/// ڵķID
	virtual void SetRoomId(int id) { m_roomId = id; }
	/// õڵķID
	virtual int GetRoomId(void) { return m_roomId; }
	/// 
	virtual void SetType(PlayerType type) { m_PlayerType = type; }
	/// õ
	virtual PlayerType GetType(void) { return m_PlayerType; }
	/// 豸
	virtual void SetDeviceType(PlayerDeviceType type) { m_PlayerDeviceType = type; }
	/// õ豸
	virtual PlayerDeviceType GetDeviceType(void) { return m_PlayerDeviceType; }
	/// ڷе
	virtual void SetChairIndex(int index) { m_ChairIndex = index; }
	/// õڷе
	virtual int GetChairIndex(void) { return m_ChairIndex; }
	/// 
	virtual void SetName(std::string name) { m_Name = name; }
	/// õ
	virtual std::string GetName(void) { return m_Name; }
	/// õ״̬
	virtual PlayerState GetState(void) { return m_PlayerState; }
	/// ״̬
	virtual void SetState(PlayerState state)
	{
		m_PlayerState = state;
	}
	/// ǷԹ
	virtual void SetLookOn(bool isLook) { m_isLookOn = isLook; }
	/// õǷԹ
	virtual bool IsLookOn(void) { return m_isLookOn; }

	/// ҽǮ
	virtual void SetMoney(int64 money) { m_Money = money; }
	/// õҽ
	virtual int64 GetMoney(void) { return m_Money; }
	/// нǮ
	virtual void SetBankMoney(int64 money) { m_BankMoney = money; }
	/// õн
	virtual int64 GetBankMoney(void) { return m_BankMoney; }
	/// ˰
	virtual void SetRevenue(int64 revenue) { m_Revenue = revenue; }
	/// õ˰
	virtual int64 GetRevenue(void) { return m_Revenue; }
	/// Ӯֵ
	virtual void SetTotalResult(int64 result) { m_TotalResult = result; }
	/// õӮֵ
	virtual int64 GetTotalResult(void) { return m_TotalResult; }
	/// ҵȼ
	virtual void SetLevel(int level) { m_level = level; }
	/// õҵȼ
	virtual int GetLevel(void) { return m_level; }
	/// Ҿֵ
	virtual void SetExperience(unsigned int exp) { m_experience = exp; }
	/// õҾֵ
	virtual unsigned int GetExperience(void) { return m_experience; }
	/// ܾ
	virtual void SetTotalBureau(int bureau) { m_totalbureau = bureau; }
	/// õܾ
	virtual int GetTotalBureau(void) { return m_totalbureau; }
	/// Ӯ
	virtual void SetSuccessBureau(int bureau) { m_successbureau = bureau; }
	/// õӮ
	virtual int GetSuccessBureau(void) { return m_successbureau; }
	/// 
	virtual void SetFailBureau(int bureau) { m_failbureau = bureau; }
	/// õ
	virtual int GetFailBureau(void) { return m_failbureau; }
	/// ܴ
	virtual void SetRunawayBureau(int bureau) { m_RunawayBureau = bureau; }
	/// õܴ
	virtual int GetRunawayBureau(void) { return m_RunawayBureau; }
	/// ʤ
	virtual void SetSuccessRate(float rate) { m_successrate = rate; }
	/// õʤ
	virtual float GetSuccessRate(void) { return m_successrate; }
	/// 
	virtual void SetRunawayrate(float rate) { m_runawayrate = rate; }
	/// õ
	virtual float GetRunawayrate(void) { return m_runawayrate; }
	/// Ա
	virtual void SetSex(int psex) { sex = psex; }
	/// õԱ
	virtual int GetSex(void) { return sex; }
	/// ʵ
	virtual void SetRealName(std::string rn) { realname = rn; }
	/// õʵ
	virtual std::string GetRealName(void) { return realname; }
	/// ϵͳ
	virtual void SetSysType(int type) { gtype = type; }
	/// õϵͳ
	virtual int GetSysType(void) { return gtype; }
	/// IPַ
	virtual void SetLoginIP(uint32 ip) { ipaddress = ip; }
	/// õIPַ
	virtual uint32 GetLoginIP(void) { return ipaddress; }

	/// ҵǰϷID
	virtual void setCurGameID(uint32 gameid) { m_CurGameType = gameid; }
	/// õҵǰϷID
	virtual uint32 getCurGameID(void) { return m_CurGameType; }
	/// ҵǰID
	virtual void setCurTableIndex(int32 tableindex) { m_CurTableIndex = tableindex; }
	/// õҵǰID
	virtual int32 getCurTableIndex(void) { return m_CurTableIndex; }
	/// õҵǰID
	virtual void setCurChairIndex(int32 chairindex) { m_CurChairIndex = chairindex; }
	/// õҵǰID
	virtual int32 getCurChairIndex(void) { return m_CurChairIndex; }
	/// ҵǰڷID
	virtual void setCurServerId(uint32 serverid) { m_CurServerPort = serverid; }
	/// õҵǰڷID
	virtual uint32 getCurServerId(void) { return m_CurServerPort; }
	/// ҵǰǷϷ
	virtual void setCurGamingState(bool state) { m_CurGamingState = state; }
	/// õҵǰǷϷ
	virtual bool getCurGamingState(void) { return m_CurGamingState; }
	/// ǷԳ齱
	virtual void setIsChouJiang(bool iscj) { m_isChoujiang = iscj; }
	/// õǷԳ齱
	virtual bool IsChouJiang(void) { return m_isChoujiang; }

	/// ÷
	inline void SetEnterPassword(std::string pwd) { m_roomenterpwd = pwd; }
	/// õ
	inline std::string getEnterPassword(void) { return m_roomenterpwd; }
	/// ÷ҷΧ
	inline void SetEnterMoneyRect(int64 first,int64 second) { m_roomentermoneyfirst = first; m_roomentermoneysecond = second; }
	/// õҷΧ
	inline void GetEnterMoneyRect(int64 *first,int64 *second) { *first = m_roomentermoneyfirst; *second = m_roomentermoneysecond; }


	/// ׼ʱ
	inline void SetReadyTime(DWORD time) { m_RealyTime = time; }
	/// õ׼ʱ
	inline DWORD GetReadyTime(void) { return m_RealyTime; }

	/// ʼһʱ
	virtual bool StartTimer(int timerId,int space);
	/// رһʱ
	virtual void StopTimer(int id);
	/// رеĶʱ
	virtual void StopAllTimer(void);

	/// Ϸ
	virtual void SendGameMsg(Json::Value &msg);
	/// ׼Ϣ
	virtual void SendReadyMsg(void);

	/// ûϷ߼ӿ
	void SetRobotLogicFrame(RobotLogicFrame *frame);
	/// õϷ߼ӿ
	RobotLogicFrame* GetRobotLogicFrame(void) { return m_RobotLogicFrame; }
	///ʱ¼
	bool OnEventTimer(DWORD dwTimerID, DWORD wBindParam);

	/// õǰϷ
	void SetCurGameRoom(Room* pRoom);
	/// õߺID
	inline void SetOffLineConnectId(uint32 connid) { m_offlineConnectId = connid; }
	/// õߺID
	inline uint32 GetOffLineConnectId(void) { return m_offlineConnectId; }

	/// õǰϷӮֵ
	inline void setCurrentGamingResult(int64 presult) { m_curGamingResult = presult; }
	/// õǰϷӮֵ
	inline int64 getCurrentGamingResult(void) { return m_curGamingResult; }

	/// Ƿڱ
	virtual bool IsMatching(void) { return m_IsMatching; }
	/// Ƿ
	virtual void SetMatching(bool im) { m_IsMatching = im; }
	/// Ƿ
	virtual bool IsMatchSignUp(void) { return m_IsMatchSignUp; }
	/// Ƿ
	virtual void SetMatchSignUp(bool ms) { m_IsMatchSignUp = ms; }
	/// 
	virtual void SetMatchCount(int count) { m_MatchCount = count; }
	/// õ
	virtual int GetMatchCount(void) { return m_MatchCount; }
	/// ܾ
	virtual void SetTotalMatchCount(int count) { m_TotalMatchCount = count; }
	/// õܾ
	virtual int GetTotalMatchCount(void) { return m_TotalMatchCount; }
	/// 
	virtual void SetMatchResult(int64 result) { m_MatchResult = result; }
	/// õ
	virtual int64 GetMatchResult(void) { return m_MatchResult; }
	/// ȡָұ
	virtual void GetPlayerRanking(void);
	/// ñ
	virtual void SetMatchRoomIndex(int index) { m_MatchRoomIndex = index; }
	/// õ
	virtual int GetMatchRoomIndex(void) { return m_MatchRoomIndex; }
	/// Ƿе
	virtual bool IsMatchingLostLine(void) { return m_IsMatchingLostOnline; }
	/// Ƿе
	virtual void SetMatchingLostLine(bool mlo) { m_IsMatchingLostOnline = mlo; }

private:
	/// ɾеĶʱ
	void DeleteAllTimer(void);

	//ʱ
protected:
	CTimerItemArray					m_TimerItemActive;					//
	Mutex                           m_TimerLock;                        /**< ڱеĶʱ */

private:
	int m_Id;         /**< ID */
	uint32 m_ConnectId;  /**< ҵID */
	uint32 ipaddress;    /**< IP */
	uint32 m_offlineConnectId;  /**< ߺID */
	int m_roomId;     /**< ڵķID */
	int m_ChairIndex;   /**< ûڷе */
	PlayerState m_PlayerState;       /**< ҵǰ״̬ */
	PlayerType m_PlayerType;           /**<  */
	PlayerDeviceType m_PlayerDeviceType; /**< 豸 */
	bool m_isLookOn;                   /**< ǷΪԹ */

	std::string m_Name;  /**< ҵ */

	std::string m_roomenterpwd; /**<  */
	int64 m_roomentermoneyfirst,m_roomentermoneysecond;  /**< ҷΧ */

	int64 m_Money;              /**< ҽǮ */
	int64 m_BankMoney;                /**< нǮ */
	int64 m_TotalResult;              /**< ܵӮֵ */
	int64 m_Revenue;                  /**< ˰ */
	int m_level;                       /**< ҵȼ */
	unsigned int m_experience;         /**< Ҿֵ */
	std::string m_useravatar;         /**< ûͷ */
	int m_totalbureau;                 /**< ܾ */
	int m_successbureau;               /**< Ӯ */
	int m_RunawayBureau;			   /**< ܴ */
	int m_failbureau;                  /**<  */
	float m_successrate;               /**< ʤ */
	float m_runawayrate;               /**<  */
	int sex;                      //Ա
	std::string realname;           //ʵ
	int gtype;                    //

	int64 m_curGamingResult;                         /**< ǰϷӮֵ */

	uint32 m_CurGameType;                            /**< ǰϷ */
	uint32 m_CurServerPort;                          /**< ǰϷ˿ */
	int32 m_CurTableIndex;                          /**< ǰϷID */
	int32 m_CurChairIndex;                          /**< ǰϷID */
	bool m_CurGamingState;                          /**< ǰϷ״̬ */
	bool m_isChoujiang;                                 /**< ǷϷ齱 */

	DWORD           m_RealyTime;                  /**< ׼ʱ */

	RobotLogicFrame *m_RobotLogicFrame;             /**< ˴ */

	int             m_MatchCount;                   /**<  */
	int             m_TotalMatchCount;              /**< ܾ */
	int64           m_MatchResult;                  /**<  */
	bool            m_IsMatching;                   /**< Ƿڱ */
	int             m_MatchRoomIndex;               /**< ڱ */
	bool            m_IsMatchingLostOnline;         /**< Ƿڱе */
	bool            m_IsMatchSignUp;                           /**< Ƿǰ */
};

#endif
