181 lines
6.3 KiB
C++
181 lines
6.3 KiB
C++
#ifndef TableFrameSink_h__
|
||
#define TableFrameSink_h__
|
||
#pragma once
|
||
|
||
#include "Stdafx.h"
|
||
#include "GameLogic.h"
|
||
#include "ServerControl.h"
|
||
#include "DlgCustomRule.h"
|
||
|
||
//游戏桌子类;
|
||
class CTableFrameSink : public ITableFrameSink ,public ITableUserAction
|
||
{
|
||
enum tagServerTimerEnum
|
||
{
|
||
IDI_SEND_CARD = 1, //发牌计时器;
|
||
IDI_WAIT_OPERATE = 2, //操作计时器;
|
||
|
||
IDT_SEND_CARD = 3000, //发牌时间;
|
||
IDT_WAIT_OPERATE = 45000, //操作时间;
|
||
};
|
||
|
||
protected:
|
||
WORD m_wFirstChairID; //第一个进房间椅子号;
|
||
WORD m_wBankerUser; //本局庄家;
|
||
WORD m_wCurrentUser; //当前玩家;
|
||
WORD m_wFirstOperateUser; //每轮开始玩家;
|
||
LONG m_lCurChipScore; //当前下注;
|
||
DWORD m_dwOperateCode; //操作码;
|
||
BYTE m_cbCurPlayRound; //当前轮数;
|
||
BYTE m_cbGamingUserCount; //参与玩的人数;
|
||
BYTE m_cbUserResponse[GAME_PLAYER]; //玩家回复状态;
|
||
BYTE m_cbHandCardData[GAME_PLAYER][MAX_COUNT]; //玩家手牌;
|
||
LONG m_lUserChipScore[GAME_PLAYER]; //玩家下注数目;
|
||
BYTE m_cbGamingStatus[GAME_PLAYER]; //玩家游戏状态;
|
||
BYTE m_cbHideCardRound[GAME_PLAYER]; //焖牌轮数;
|
||
|
||
LONG m_lCfgMinChipScore; //最小可下注;
|
||
LONG m_lCfgMaxChipScore; //最大可下注;
|
||
|
||
BYTE m_cbCfgMaxPlayRound; //最大轮数;
|
||
BYTE m_cbCfgMinCompareUser; //最小比牌人数;
|
||
BYTE m_cbCfgMinLookRound; //最小看牌轮数;
|
||
BYTE m_cbCfgMinCompareRound; //最小比牌轮数;
|
||
|
||
BYTE m_cbPlayTimes; //局数;
|
||
BYTE m_cbMasterCtrlType; //控制类型;
|
||
WORD m_wMasterChairID; //控制玩家椅子号;
|
||
|
||
protected:
|
||
CMD_S_Private_End_Info m_PrivateEndInfo; //私有场信息;
|
||
|
||
protected:
|
||
ITableFrame *m_pITableFrame; //框架接口;
|
||
tagCustomRule *m_pGameCustomRule; //自定规则;
|
||
|
||
const tagGameServiceOption *m_pGameServiceOption; //配置参数;
|
||
CGameLogic m_GameLogic; //游戏逻辑;
|
||
|
||
protected:
|
||
static const WORD m_wPlayerCount; //游戏人数;
|
||
|
||
public:
|
||
//构造函数;
|
||
CTableFrameSink();
|
||
//析构函数;
|
||
virtual ~CTableFrameSink();
|
||
|
||
public:
|
||
//释放对象;
|
||
virtual VOID Release() { if (IsValid()) delete this; }
|
||
//是否有效;
|
||
virtual bool IsValid() { return AfxIsValidAddress(this,sizeof(CTableFrameSink))?true:false; }
|
||
//接口查询;
|
||
virtual void * QueryInterface(const IID & Guid, DWORD dwQueryVer);
|
||
|
||
public:
|
||
//初始化;
|
||
virtual bool Initialization(IUnknownEx * pIUnknownEx);
|
||
//复位桌子;
|
||
virtual void RepositionSink();
|
||
|
||
public:
|
||
//游戏状态;
|
||
virtual bool IsUserPlaying(WORD wChairID);
|
||
|
||
public:
|
||
//用户断线;
|
||
virtual bool OnActionUserOffLine(WORD wChairID,IServerUserItem * pIServerUserItem) { return true; }
|
||
//用户重入;
|
||
virtual bool OnActionUserConnect(WORD wChairID,IServerUserItem * pIServerUserItem) { return true; }
|
||
//用户坐下;
|
||
virtual bool OnActionUserSitDown(WORD wChairID,IServerUserItem * pIServerUserItem, bool bLookonUser);
|
||
//用户起立;
|
||
virtual bool OnActionUserStandUp(WORD wChairID,IServerUserItem * pIServerUserItem, bool bLookonUser);
|
||
//用户同意;
|
||
virtual bool OnActionUserOnReady(WORD wChairID,IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize) { return true; }
|
||
//用户开始游戏
|
||
virtual bool OnActionUserOnStart(WORD wChairID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize) { return true; }
|
||
//用户开始游戏
|
||
virtual bool OnActionUserStartGame(WORD wChairID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize) { return true; }
|
||
//游戏事件;
|
||
public:
|
||
//游戏开始;
|
||
virtual bool OnEventGameStart();
|
||
//游戏结束;
|
||
virtual bool OnEventGameConclude(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason);
|
||
//发送场景;
|
||
virtual bool OnEventSendGameScene(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbGameStatus, bool bSendSecret);
|
||
|
||
//事件接口;
|
||
public:
|
||
//定时器事件;
|
||
virtual bool OnTimerMessage(DWORD wTimerID, WPARAM wBindParam);
|
||
//游戏消息处理;
|
||
virtual bool OnGameMessage(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem);
|
||
//框架消息处理;
|
||
virtual bool OnFrameMessage(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem);
|
||
|
||
//查询接口;
|
||
public:
|
||
//查询限额;
|
||
virtual SCORE QueryConsumeQuota(IServerUserItem * pIServerUserItem){ return 0; }
|
||
//最少积分;
|
||
virtual SCORE QueryLessEnterScore(WORD wChairID, IServerUserItem * pIServerUserItem){ return 0; }
|
||
//数据事件;
|
||
virtual bool OnDataBaseMessage(WORD wRequestID, VOID * pData, WORD wDataSize){ return false; }
|
||
//积分事件;
|
||
virtual bool OnUserScroeNotify(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason){ return false; }
|
||
//查询是否扣服务费;
|
||
virtual bool QueryBuckleServiceCharge(WORD wChairID){ return true; }
|
||
|
||
private:
|
||
//获取操作掩码;
|
||
DWORD MakeOperateCode(WORD wChairID);
|
||
//参与游戏玩家;
|
||
WORD FindNextGamingUser(WORD wChairID);
|
||
//切换参与玩家(下注轮数结束 true,否则false);
|
||
void SwitchNextGamingUser(WORD wChairID);
|
||
//统计胜利玩家;
|
||
WORD CountLastWinUser();
|
||
//统计游戏分数;
|
||
WORD CountGameScore(WORD wWinner, LONG lGameScore[GAME_PLAYER]);
|
||
//是否是闷牌;
|
||
bool IsCardHidden(WORD wChairID)const { ASSERT(wChairID>=0 && wChairID<GAME_PLAYER); return ST_GAMING_HIDDEN==m_cbGamingStatus[wChairID]; }
|
||
//是否是正在游戏玩家;
|
||
bool IsGamingUser(WORD wChairID)const { ASSERT(wChairID>=0 && wChairID<GAME_PLAYER); return (ST_GAMING_HIDDEN==m_cbGamingStatus[wChairID] || ST_GAMING_LOOK==m_cbGamingStatus[wChairID]); }
|
||
|
||
protected:
|
||
//发牌动画结束;
|
||
bool OnSendCardOver(WORD wChairID);
|
||
//用户操作消息;
|
||
bool OnUserOperate(WORD wChairID, DWORD dwOperateCode, LONG lOperateData);
|
||
//放弃消息处理;
|
||
bool OnUserGiveUp(WORD wChairID);
|
||
//看牌消息处理;
|
||
bool OnUserLookCard(WORD wChairID);
|
||
//下注消息处理;
|
||
bool OnUserChipScore(WORD wChairID, DWORD dwOperateCode, LONG lUserChip);
|
||
//比牌消息处理;
|
||
bool OnUserCompareCard(WORD wChairID, DWORD dwOperateCode, WORD wCompareUser);
|
||
|
||
//比赛接口;
|
||
public:
|
||
//设置基数;
|
||
virtual void SetGameBaseScore(LONG lBaseScore){};
|
||
//设置私人场信息;
|
||
virtual void SetPrivateInfo(BYTE cbGameTypeIndex, DWORD dwGameRule);
|
||
//重置私人场结束信息;
|
||
virtual void ResetPrivateEndInfo();
|
||
//获得私人场结束信息流;
|
||
virtual void GetPrivateEndInfo(DataStream &kDataStream, bool bSend);
|
||
//判断私人场是否结束;
|
||
virtual bool IsPrivateEnd();
|
||
//真实椅子数量
|
||
virtual WORD GetRealChairCount() { return GAME_PLAYER; }
|
||
|
||
virtual bool OnActionUserFangKaCheck(WORD wChairID, IServerUserItem * pIServerUserItem, SCORE lUserInsure){ return true; }
|
||
};
|
||
|
||
#endif // TableFrameSink_h__
|