192 lines
6.3 KiB
C++
192 lines
6.3 KiB
C++
#ifndef TableFrameSink_h__
|
|
#define TableFrameSink_h__
|
|
#pragma once
|
|
|
|
#include "Stdafx.h"
|
|
#include "GameLogic.h"
|
|
|
|
//游戏桌子类;
|
|
class CTableFrameSink : public ITableFrameSink, public ITableUserAction
|
|
{
|
|
protected:
|
|
WORD m_wBankerUser; //庄家用户;
|
|
LONG m_lTableScore[GAME_PLAYER]; //下注数目;
|
|
bool m_bActiveUser[GAME_PLAYER]; //激活玩家;
|
|
BYTE m_cbUserResponse[GAME_PLAYER]; //回复状态;
|
|
BYTE m_cbHandCardCount[GAME_PLAYER]; //手牌数量;
|
|
BYTE m_cbHandCardData[GAME_PLAYER][MAX_COUNT]; //手牌数据;
|
|
BYTE m_cbRobBankerCount; //抢庄玩家数量;
|
|
WORD m_wRobBankerUser[GAME_PLAYER]; //抢庄玩家位置;
|
|
tagOpenCardRlt m_stOpenCardRlt[GAME_PLAYER]; //开牌结果;
|
|
|
|
protected:
|
|
DWORD m_dwOwnerID; //房主ID;
|
|
tagOpenRuleCfg *m_pOpenRuleCfg; //开房配置;
|
|
|
|
CMD_S_Private_End_Info m_PrivateEndInfo; //私有场信息;
|
|
|
|
protected:
|
|
CGameLogic m_GameLogic; //游戏逻辑;
|
|
ITableFrame *m_pITableFrame; //框架接口;
|
|
const tagGameServiceOption *m_pGameServiceOption; //配置参数;
|
|
|
|
protected:
|
|
static const WORD m_wPlayerCount; //游戏人数;
|
|
static tagGameRuleCfg m_stGameRuleCfg; //规则配置;
|
|
|
|
public:
|
|
//构造函数;
|
|
CTableFrameSink();
|
|
//析构函数;
|
|
virtual ~CTableFrameSink();
|
|
//读取服务器配置;
|
|
static bool ReadServerConfig(const tagGameServiceOption *pGameServiceOption);
|
|
|
|
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:
|
|
//获取有效配置;
|
|
//tagOpenRuleCfg * GetValidConfig()const { return (nullptr!=m_pOpenRuleCfg) ? m_pOpenRuleCfg : &m_stGameRuleCfg; }
|
|
//获取最小自由可下注;
|
|
LONG GetMinFreeChip()const {
|
|
return 0; //GetValidConfig()->cbMinFreeChip;
|
|
}
|
|
//获取最大自由可下注;
|
|
LONG GetMaxFreeChip()const {
|
|
return 0;//GetValidConfig()->cbMaxFreeChip;
|
|
}
|
|
//是否有花牛模式;
|
|
//bool IsHaveHuaNiuMode()const { return (0!=(GetValidConfig()->wGameRule&RULE_HUA_NIU)) ? true : false; }
|
|
//是否是三张模式;
|
|
//bool IsThreeCardMode()const { return (0!=(GetValidConfig()->wGameRule&RULE_SAN_ZHANG)) ? true : false; }
|
|
//是否有牛番模式;
|
|
//bool IsHaveNiuFanMode()const { return (0!=(GetValidConfig()->wGameRule&RULE_NIU_FAN)) ? true : false; }
|
|
//是否是抢庄模式;
|
|
bool IsRobBankerMode()
|
|
{
|
|
//return BANKER_ROB==GetValidConfig()->wBankerRule || BANKER_ROB4==GetValidConfig()->wBankerRule;
|
|
return IsHasGameRule(eNNRuleEnum_BANKER_ROB);
|
|
}
|
|
//是否是固定庄家模式;
|
|
bool IsFixBankerMode() {
|
|
//return BANKER_OWNER==GetValidConfig()->wBankerRule || BANKER_TURNS==GetValidConfig()->wBankerRule;
|
|
return (IsHasGameRule(eNNRuleEnum_BANKER_OWNER) || IsHasGameRule(eNNRuleEnum_BANKER_TURNS));
|
|
}
|
|
//是否是拼刺刀模式;
|
|
bool IsBayonetMode()
|
|
{
|
|
return IsHasGameRule(eNNRuleEnum_BAYONET);
|
|
}
|
|
|
|
// 是否有特殊牛;
|
|
bool IsHasSpecialNiu(eNNRuleEnum eType)
|
|
{
|
|
return !IsHasGameRule(eType);
|
|
}
|
|
|
|
private:
|
|
//移除所有计时器;
|
|
void KillAllTimer();
|
|
//发送开始下注;
|
|
void SendStartChip();
|
|
//是否由玩家没操作;
|
|
bool IsUserNoOperate(bool bIgnoreBanker);
|
|
|
|
protected:
|
|
//发牌完成;
|
|
bool OnUserSendCard(WORD wChairID);
|
|
//叫庄事件;
|
|
bool OnUserRobBanker(WORD wChairID, bool bRob);
|
|
//加注事件;
|
|
bool OnUserChipScore(WORD wChairID, LONG lScore);
|
|
//摊牌事件;
|
|
bool OnUserOpenCard(WORD wChairID);
|
|
|
|
//比赛接口;
|
|
public:
|
|
//设置基数;
|
|
virtual void SetGameBaseScore(LONG lBaseScore){};
|
|
//设置私人场信息;
|
|
virtual void SetPrivateInfo(BYTE bGameTypeIdex, DWORD bGameRuleIdex);
|
|
//重置私人场结束信息;
|
|
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; }
|
|
|
|
//私人场辅助函数;
|
|
public:
|
|
//是否有相应规则;
|
|
bool IsHasGameRule(eNNRuleEnum eType);
|
|
|
|
};
|
|
|
|
#endif // TableFrameSink_h__
|