#ifndef _ROOM_H_INCLUDE_
#define _ROOM_H_INCLUDE_

#include <vector>
#include <string>
#include <map>

#include "Player.h"
#include "ccommon.h"

// 󷿼
#define ROOM_MAX_PLAYERS  500

/**
 * 
 */
enum RoomType
{
	ROOMTYPE_BISAI = 0,                  // 
	ROOMTYPE_JIFEN,                      // ַ
	ROOMTYPE_JINBIN,                     // ҷ
	ROOMTYPE_LIANXI,                     // ϰ
	ROOMTYPE_NULL
};

/**
 * 䵱ǰ״̬
 */
enum RoomState
{
	ROOMSTATE_WAITING = 0,             // ȴ
	ROOMSTATE_GAMING,                  // Ϸ
	ROOMSTATE_NULL
};

//
enum enScoreKind
{
	enScoreKind_Win,					//ʤ
	enScoreKind_Lost,					//
	enScoreKind_Draw,					//
	enScoreKind_Flee,					//
	enScoreKind_Service,				//
	enScoreKind_Present,				//
};

class Player;
class ServerLogicFrame;

class Room
{
public:
	/// ÷ID
	virtual void SetID(int id) = 0;
	/// õID
	virtual int GetID(void) = 0;
	/// ÷Ϸ
	virtual void SetGameType(int type) = 0;
	/// õϷ
	virtual int GetGameType(void) = 0;
	/// ÷Ϸ
	virtual void SetGameId(int gameid) = 0;
	/// õϷ
	virtual int GetGameId(void) = 0;
	/// ÷ʶ
	virtual void SetRoomMarking(int marking) = 0;
	/// õʶ
	virtual int GetRoomMarking(void) = 0;
	/// Ϸ߼ӿ
	virtual void SetServerLogicFrame(ServerLogicFrame *frame) = 0;
	/// Ϸ߼ӿ
	virtual ServerLogicFrame* GetServerLogicFrame(void) = 0;
	/// ÷
	virtual void SetRoomType(RoomType type) = 0;
	/// õ
	virtual RoomType GetRoomType(void) = 0;
	/// ÷
	virtual void SetMaxPlayer(int max) = 0;
	/// õ
	virtual int GetMaxPlayer(void) = 0;
	/// ÷״̬
	virtual void SetRoomState(RoomState state) = 0;
	/// õ״̬
	virtual RoomState GetRoomState(void) = 0;
	/// ÷Ϸ
	virtual void SetRoomGameType(enStartMode type) = 0;
	/// õϷ
	virtual enStartMode GetRoomGameType(void) = 0;
	/// ÷
	virtual void SetName(std::string name) = 0;
	/// õ
	virtual std::string GetName(void) = 0;
	/// Ϸˮֵ
	virtual void SetChouShui(float cs) = 0;
	/// õϷˮֵ
	virtual float GetChouShui(void) = 0;
	/// ϷԪ
	virtual void SetGamePielement(int pielement) = 0;
	/// õϷԪ
	virtual int GetGamePielement(void) = 0;
	/// ϷҪٽ
	virtual void SetLastMoney(unsigned int money) = 0;
	/// õϷҪٽ
	virtual unsigned int GetLastMoney(void) = 0;
	/// ǰǷΪ
	virtual bool IsEmpty(void) = 0;
	/// õָ
	virtual Player* GetPlayer(int index) = 0;
	/// õʾʱָ(ͻʹ)
	virtual int SwitchViewChairID(int chairIndex) = 0;
	/// õǰ
	virtual int GetPlayerCount(void) = 0;
	/// õ׼״̬ҵ
	virtual int GetReadyPlayerCount(void) = 0;
	/// õǰķ
	virtual void SetMaster(int playerId) = 0;
	/// õǰķΪǰһ׼ʼϷ
	virtual int GetMaster(void) = 0;
	/// õеǰ
	virtual int GetCurrentPlayer(void) = 0;
	/// ûIDõûڷеID
	virtual int GetPlayerRoomId(uint32 connId) = 0;
	/// õǰָ״̬Ҹ
	virtual int GetPlayerCount(PlayerState state) = 0;
	/// õǰҵ״̬
	virtual void SetAllPlayerState(PlayerState state) = 0;
	/// ָҵ״̬
	virtual void SetPlayerState(int index,PlayerState state) = 0;
	/// ÷еǰ
	virtual void SetCurrentPlayer(int playerId) = 0;
	/// õǰһ
	virtual int GetCurNextPlayer(void) = 0;
	/// õǰһ
	virtual int GetCurNextWorkPlayer(void) = 0;
	/// ÷
	virtual void SetEnterPassword(std::string pwd) = 0;
	/// õ
	virtual std::string getEnterPassword(void) = 0;
	/// ÷ҷΧ
	virtual void SetEnterMoneyRect(int64 first,int64 second) = 0;
	/// õҷΧ
	virtual void GetEnterMoneyRect(int64 *first,int64 *second) = 0;

	/// ⷿǷѾԱ
	virtual bool IsFull(void) = 0;
	/// ⷿǷȫ׼
	virtual bool IsReadyed(void) = 0;
	/// idõڵǰе
	virtual int GetPlayerIndex(uint32 connId) = 0;
	/// õǰе
	virtual inline int GetLostPlayerCount(void) = 0;

	/// յǰ
	virtual void Clear(void) = 0;
	/// ޳ָңϷʱ޳
	virtual bool EliminatePlayer(Player *pPlayer) = 0;
	/// дû
	virtual bool WriteUserScore(int wChairID, int64 lScore, int64 lRevenue, enScoreKind ScoreKind,int64 pAgentmoney=0,bool isCumulativeResult=true,int64 pcurJetton=0,const char* pgametip="") = 0;
	/// Ϸʱ
	virtual void GameEnd(bool isupdateuserdata=true) = 0;
	/// Ϸʼǵ
	virtual void GameStart(void) = 0;
    /// ָҵ
    virtual void UpdateUserScore(Player *pPlayer) = 0;

	/// ⵱ǰӮ(2:ʾӮˣ1ʾˣ0ʾ䲻Ӯ
	virtual int IsUserWin(int64 *result = NULL, int64 *sysMax = NULL, int64 *sysMin = NULL, bool isUpdate = false) = 0;
	/// ָҵӮ(1:ʾˣ2ʾӮˣ0ʾ䲻Ӯ-1ƣ
	virtual int IsSuperPlayerWin(Player *pPlayer,int64 *curresult=NULL,int64 *decResult=NULL) = 0;

	/// ָҷ
	virtual void SendTableMsg(int index,Json::Value &msg) = 0;
	/// ָҷԹ
	virtual void SendLookOnMes(int index,Json::Value &msg) = 0;

	/// ʼһʱ
	virtual bool StartTimer(int timerId,int space) = 0;
	/// رһʱ
	virtual void StopTimer(int id) = 0;
	/// رеĶʱ
	virtual void StopAllTimer(void) = 0;
	//virtual std::string WideCharConverToUtf8(CString& str)=NULL;

	/// ʼ¼
	virtual void StartVideoTape(Player *pPlayer,Room *pRoom) = 0;
	/// ¼
	virtual void EndVideoTape(void) = 0;
	//¼ϷϢ
	virtual void OnTapeGameMessage(const void * pBuffer, WORD wDataSize) = 0;

	/// ӡ־
	virtual void Room_Log(enLogLevel loglevel,std::string log) = 0;
	/// õò
	virtual std::string GetRoomParameters(void) = 0;
};

#endif
