226 lines
7.6 KiB
C++
226 lines
7.6 KiB
C++
#ifndef LOCKTIME_MATCH_HEAD_FILE
|
||
#define LOCKTIME_MATCH_HEAD_FILE
|
||
|
||
#pragma once
|
||
|
||
#include <vector>
|
||
#include <map>
|
||
using std::vector;
|
||
using std::map;
|
||
#include "NDSTLExtend.h"
|
||
|
||
//引入文件
|
||
#include "TableFrameHook.h"
|
||
#include "MatchServiceHead.h"
|
||
#include "DistributeManager.h"
|
||
|
||
#include "..\游戏服务器\DataBasePacket.h"
|
||
|
||
///////////////////////////////////////////////////////////////////////////////////////////
|
||
|
||
//时钟定义
|
||
#define IDI_CHECK_START_MATCH (IDI_MATCH_MODULE_START+1) //开始时钟
|
||
#define IDI_CHECK_END_MATCH (IDI_MATCH_MODULE_START+2) //结束时钟
|
||
#define IDI_SWITCH_STATUS (IDI_MATCH_MODULE_START+3) //切换状态
|
||
#define IDI_LOAD_RANKDATA (IDI_MATCH_MODULE_START+4) //加载排行榜数据
|
||
|
||
//移除理由
|
||
#define REMOVE_BY_ENDMATCH 250 //比赛结束
|
||
|
||
///////////////////////////////////////////////////////////////////////////////////////////
|
||
//结构定义
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////
|
||
|
||
//定时赛
|
||
class CLockTimeMatch : public IGameMatchItem,public IMatchEventSink,IServerUserItemSink
|
||
{
|
||
typedef map<DWORD, tagMatchScore*> tagMatchScorePtrMap;
|
||
typedef vector<tagMatchScore*> tagMatchScorePtrVector;
|
||
//状态变量
|
||
protected:
|
||
BYTE m_MatchStatus; //比赛状态
|
||
CTime m_TimeLastMatch; //比赛时间
|
||
|
||
//变量定义
|
||
protected:
|
||
CDistributeManager m_DistributeManage; //分组管理;
|
||
|
||
tagMatchScorePtrMap m_AllMatchScorePtrMap; //所有参数玩家的玩家分数map;
|
||
tagMatchScorePtrVector m_AllMatchScorePtrVector; //所有参数玩家的分数的有序vector;
|
||
|
||
//比赛配置
|
||
protected:
|
||
tagGameMatchOption * m_pMatchOption; //比赛配置
|
||
tagGameServiceOption * m_pGameServiceOption; //服务配置
|
||
tagGameServiceAttrib * m_pGameServiceAttrib; //服务属性
|
||
|
||
//内核接口
|
||
protected:
|
||
ITableFrame ** m_ppITableFrame; //框架接口
|
||
ITimerEngine * m_pITimerEngine; //时间引擎
|
||
IDBCorrespondManager * m_pIDataBaseEngine; //数据引擎
|
||
ITCPNetworkEngineEvent * m_pITCPNetworkEngineEvent; //网络引擎
|
||
|
||
//服务接口
|
||
protected:
|
||
IMainServiceFrame * m_pIGameServiceFrame; //功能接口
|
||
IServerUserManager * m_pIServerUserManager; //用户管理
|
||
IAndroidUserManager * m_pAndroidUserManager; //机器管理
|
||
IServerUserItemSink * m_pIServerUserItemSink; //用户回调
|
||
|
||
//函数定义
|
||
public:
|
||
//构造函数
|
||
CLockTimeMatch();
|
||
//析构函数
|
||
virtual ~CLockTimeMatch(void);
|
||
|
||
//基础接口
|
||
public:
|
||
//释放对象
|
||
virtual VOID Release(){ delete this; }
|
||
//接口查询
|
||
virtual VOID * QueryInterface(REFGUID Guid, DWORD dwQueryVer);
|
||
|
||
//控制接口
|
||
public:
|
||
//启动通知
|
||
virtual void OnStartService() { return ; }
|
||
|
||
//管理接口
|
||
public:
|
||
//绑定桌子
|
||
virtual bool BindTableFrame(ITableFrame * pTableFrame,WORD wTableID);
|
||
//初始化接口
|
||
virtual bool InitMatchInterface(tagMatchManagerParameter & MatchManagerParameter);
|
||
|
||
//系统事件
|
||
public:
|
||
//时间事件
|
||
virtual bool OnEventTimer(DWORD dwTimerID, WPARAM dwBindParameter);
|
||
//数据库事件
|
||
virtual bool OnEventDataBase(WORD wRequestID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize);
|
||
|
||
//网络事件
|
||
public:
|
||
//比赛事件
|
||
virtual bool OnEventSocketMatch(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem, DWORD dwSocketID);
|
||
|
||
//用户接口
|
||
public:
|
||
//用户积分
|
||
virtual bool OnEventUserItemScore(IServerUserItem * pIServerUserItem, BYTE cbReason);
|
||
//用户状态
|
||
virtual bool OnEventUserItemStatus(IServerUserItem * pIServerUserItem, WORD wOldTableID=INVALID_TABLE, WORD wOldChairID=INVALID_CHAIR);
|
||
//用户权限
|
||
virtual bool OnEventUserItemRight(IServerUserItem *pIServerUserItem, DWORD dwAddRight, DWORD dwRemoveRight,bool bGameRight=true);
|
||
|
||
//事件接口
|
||
public:
|
||
//用户登录
|
||
virtual bool OnEventUserLogon(IServerUserItem * pIServerUserItem);
|
||
//用户登出
|
||
virtual bool OnEventUserLogout(IServerUserItem * pIServerUserItem);
|
||
//进入事件
|
||
virtual bool OnEventEnterMatch(DWORD dwSocketID ,VOID* pData,DWORD dwUserIP, bool bIsMobile);
|
||
//用户参赛
|
||
virtual bool OnEventUserJoinMatch(IServerUserItem * pIServerUserItem, BYTE cbReason,DWORD dwSocketID);
|
||
//用户退赛
|
||
virtual bool OnEventUserQuitMatch(IServerUserItem * pIServerUserItem, BYTE cbReason, WORD *pBestRank=NULL, DWORD dwContextID=INVALID_WORD);
|
||
|
||
//功能函数
|
||
public:
|
||
//游戏开始
|
||
virtual bool OnEventGameStart(ITableFrame *pITableFrame, WORD wChairCount);
|
||
//游戏结束
|
||
virtual bool OnEventGameEnd(ITableFrame *pITableFrame,WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason);
|
||
|
||
//用户事件
|
||
public:
|
||
//用户坐下
|
||
virtual bool OnActionUserSitDown(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser);
|
||
//用户起来
|
||
virtual bool OnActionUserStandUp(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser);
|
||
//用户同意
|
||
virtual bool OnActionUserOnReady(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize);
|
||
//可以准备
|
||
virtual bool OnActionUserOnStart(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize){ return true; }
|
||
virtual bool OnActionUserStartGame(WORD wTableID, WORD wChairID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize){ return true; }
|
||
//辅助函数
|
||
protected:
|
||
//清除玩家
|
||
void ClearSameTableUser(DWORD dwUserID);
|
||
//插入用户
|
||
void InserSameTableUser(DWORD dwUserID,DWORD dwTableUserID);
|
||
//发送分数
|
||
bool SendMatchUserScore(IServerUserItem * pIServerUserItem);
|
||
//移除分组
|
||
bool RemoveDistribute(IServerUserItem * pIServerUserItem);
|
||
//插入用户
|
||
bool InsertDistribute(IServerUserItem * pIServerUserItem);
|
||
//发送分数
|
||
bool SendMatchUserInitScore(IServerUserItem * pIServerUserItem);
|
||
|
||
//校验函数
|
||
private:
|
||
//参赛校验
|
||
bool VerifyUserEnterMatch(IServerUserItem * pIServerUserItem);
|
||
//时间校验
|
||
bool VerifyMatchTime(LPTSTR pszMessage,WORD wMaxCount,WORD & wMessageType);
|
||
//发送数据
|
||
bool SendMatchInfo(IServerUserItem * pIServerUserItem);
|
||
//循环比赛模式;
|
||
bool IsRoundMatchMode();
|
||
//单次模式;
|
||
bool IsNormalMatchMode();
|
||
//报名时间校验;
|
||
bool VerifySignupMatchTime(LPTSTR pszMessage, WORD wMaxCount, WORD & wMessageType);
|
||
|
||
|
||
//辅助函数
|
||
protected:
|
||
//分配用户
|
||
bool PerformDistribute();
|
||
//开始间隔
|
||
DWORD GetMatchStartInterval();
|
||
//获得名次
|
||
WORD GetUserRank(IServerUserItem *pUserItem, ITableFrame *pITableFrame);
|
||
//发送比赛信息
|
||
void SendTableUserMatchInfo(ITableFrame *pITableFrame, WORD wChairID);
|
||
void SendTableUserMatchInfo(IServerUserItem* pIServerUserItem);
|
||
//写入奖励
|
||
bool WriteUserAward(IServerUserItem *pIServerUserItem,tagMatchRankInfo * pMatchRankInfo);
|
||
//更新状态
|
||
void UpdateMatchStatus();
|
||
//执行起立;
|
||
VOID PerformAllUserStandUp(ITableFrame *pITableFrame);
|
||
//计算场次;
|
||
DWORD CalcMatchNo();
|
||
//释放所有tagMatchScore;
|
||
void ReleaseMatchScore();
|
||
//创建一个tagMatchScore;
|
||
void CreateNewMatchScore(IServerUserItem *pIServerUserItem);
|
||
//插入到m_AllMatchScorePtrMap;
|
||
void InsertAllMatchScoreMap(IServerUserItem *pIServerUserItem);
|
||
//find tagMatchScore;
|
||
tagMatchScore* FindMatchScore(IServerUserItem *pIServerUserItem);
|
||
//update tagMatchScore;
|
||
void UpdateMatchScore(IServerUserItem *pIServerUserItem, bool bFinish);
|
||
//sort tagMatchScore;
|
||
void SortMatchScoreVector();
|
||
//获得玩家的RankID;
|
||
DWORD GetUserRank(IServerUserItem *pUserItem);
|
||
//组件CMD_GR_Match_Rank_Info数据;
|
||
void GetCMDGRMatchRankInfo(CMD_GR_Match_Rank_Info* pRankInfo, WORD& refRankSize);
|
||
//send SUB_GR_MATCH_JOIN_RESULT
|
||
void SendMatchJoinResult(IServerUserItem* pIServerUserItem, WORD wSuccess, LPCTSTR lpszMessage);
|
||
//插入到m_AllMatchScorePtrMap;
|
||
void InsertAllMatchScoreMap(tagMatchRankDataInfo * pMatchRankDataInfo);
|
||
//send SUB_GR_MATCH_PLAYERFINISH msg;
|
||
void SendMatchPlayerFinish(IServerUserItem* pIServerUserItem);
|
||
//send SUB_GR_MATCH_WAIT_TIP msg;
|
||
void SendMatchWaitTip(IServerUserItem* pIServerUserItem);
|
||
};
|
||
|
||
#endif |