|
- #ifndef TABLE_FRAME_SINK_50K_HEAD_FILE
- #define TABLE_FRAME_SINK_50K_HEAD_FILE
-
- #pragma once
-
- #include "../Stdafx.h"
- #include "../data.h"
- #include <fstream>
- #include <vector>
- #include <map>
- #include <list>
- #include<algorithm>
- #include "GameLogic_poker.h"
- using namespace std;
- //回放
-
- struct CMD_GR_ReplayRecordResp_Poker
- {
- UINT32 m_UUID; //回放唯一ID
- UINT32 m_tableID; //公开桌子号
- UINT32 m_startTime; //游戏开始时间
- UINT32 m_endTime; //游戏结束时间
- UINT32 m_UserId; //用户ID
-
- CMD_S_GameConfig_Poker m_gameconfig; //游戏基本配置
- ChairRecord m_chairList[GAME_PLAYER]; //游戏椅子玩家信息
- UINT16 m_recordCount; //回放数据记录数
- char pData[0]; //回放记录列表(尾拖数据)
- };
- //游戏桌子类
- class CTableFrameSinkPoker : public ITableFrameSink, public ITableUserAction
- {
- //游戏变量
- private:
- ITableFrame* m_pITableFrame; //框架接口
- const tagGameServiceOption* m_pGameServiceOption; //配置参数
- CMD_S_GameConfig_Poker m_gameConfig; //房间配置
- CGameLogic_Poker m_GameLogic; //扑克逻辑类
-
- BYTE m_cbPlayerNum; //游戏人数
- BYTE m_cbCardNum; //游戏牌数
- // 用户状态
- BYTE m_cbOffline[GAME_PLAYER]; //是否断线 0正常 1断线
- BYTE m_cbTrustee[GAME_PLAYER]; //是否托管 0正常 1托管
- BYTE m_cbTimeOutCount[GAME_PLAYER]; //超时次数 连续两次触发托管
- UINT m_unUserID[GAME_PLAYER]; //顺时针用户顺序
- // 玩家分数
- INT m_lGameTatolScore[GAME_PLAYER]; //16局积分
- //BYTE m_nWins[GAME_PLAYER]; //胜场数
- int m_HuPaiLiuShui[16 * GAME_PLAYER]; //流水详情
- // 游戏回放
- bool m_bReplayRecordStart; //是否开始录像
- std::vector<GameRecordPacket> m_UserReplayRecord; //对四个位置用户的数据的记录,用于回放。
-
-
- /*
-
- ------------------------------------------------------------------------------------
- 单局变量
- */
- int m_GameScore[GAME_PLAYER]; //本局总积分
- short m_lGameGongXianScore[GAME_PLAYER]; //本局贡献分
- short m_lGameAwardScore[GAME_PLAYER]; //本局双扣基础分
-
- WORD m_wWinCount; //胜利人数
- BYTE m_wWinOrder[GAME_PLAYER]; //出完牌顺序
- BYTE m_winLoseCount[GAME_PLAYER]; //玩家胜利失败次数
- WORD m_wTurnWiner; //胜利玩家
- WORD m_wBankerUser; //庄家用户
- WORD m_wCurrentUser; //当前玩家
- WORD m_wCurrentOperate; //当前用户操作类型
- BYTE m_cbTurnCardCount; //出牌数目
- BYTE m_cbTurnCardData[MAX_COUNT_Poker]; //出牌数据 真实牌
- BYTE m_cbMagicCardData[MAX_COUNT_Poker]; //变幻扑克 如果有magic 则是变换后的牌
-
- bool m_bTrustee[GAME_PLAYER]; //是否托管
- bool m_bSwitchChair; //交换位置
- WORD m_wSourceID[2]; //原始ID
- WORD m_wTargetID[2]; //目标ID
- bool m_bResponse[GAME_PLAYER]; //用户反馈
-
- // 要牌状态
- BYTE m_cbResponse[GAME_PLAYER]; //1:要不起|2:要了|0:未操作 出牌判定时需要:如果两家要不起,随意出牌;如果某家要了,需接上次出牌
- BYTE m_cbUserOPerate_mask[GAME_PLAYER]; //记录了 每个玩家的操作类型
- // 发牌信息
- BYTE m_cbLeftCardCount; //剩余数目
- BYTE m_cbRepertoryCard[FULL_COUNT_Poker]; //库存扑克
-
-
-
- BYTE m_cbCardDataCount[GAME_PLAYER]; //扑克数目
- BYTE m_cbCardData[GAME_PLAYER][MAX_COUNT_Poker]; //用户手上扑克
-
- BYTE m_cbStartRandCard;//双扣开始时 随机扑克 的数值
-
- // 出牌提示
- BYTE m_cbHintNum; //提示数目
- BYTE m_cbCurrentHintNum; //当前提示数目
- std::vector<HitStruct> mHistList; //所有的提示牌
- // 出牌信息
- OutCard m_struOutCard; //上家出牌
- list<OutCard> m_listOutCard; //出牌记录
- BYTE m_cbJokerReplacePoker[4][4]; //当前玩家出的牌中王替换的牌
-
- BYTE m_BomoCouut[GAME_PLAYER]; //本局每个人的炸弹个数
- BYTE m_lastLianxianInfo; //上一个出牌玩家的 炸弹 连排信息
- BYTE m_BoomCountInfo[4][9]; //记录每个玩家 单局4 5 6 7 8 9 10 11 12 线 炸弹的累计次数
- /*
- 基础函数定义 ----------------------------------------------------------------------------
- */
- public:
- //构造函数
- CTableFrameSinkPoker();
- //析构函数
- virtual ~CTableFrameSinkPoker();
- //释放对象
- virtual VOID Release() { delete this; }
- //接口查询
- virtual void * QueryInterface(const IID & Guid, DWORD dwQueryVer);
-
- //初始化
- virtual bool Initialization(IUnknownEx * pIUnknownEx);
- //复位桌子
- virtual VOID RepositionSink();
- //删除桌子
- virtual void DeletePrivateTable(bool bSendState = false);
- virtual bool ConcludeGame(BYTE cbGameStatus, bool bSendState = false)
- {
- //结束记录回放数据
- auto dataPair = RepayRecordEnd();
- //结束游戏
- m_pITableFrame->ConcludeGame(cbGameStatus, bSendState);
- return true;
- }
-
- //查询限额
- virtual SCORE QueryConsumeQuota(IServerUserItem * pIServerUserItem){ return 0; };
- //最少积分
- virtual SCORE QueryLessEnterScore(WORD wChairID, IServerUserItem * pIServerUserItem){ return 0; };
- //查询是否扣服务费
- virtual bool QueryBuckleServiceCharge(WORD wChairID){ return true; }
- //查询总得分
- virtual int QueryTatolScore(WORD wChairID){ if (wChairID >= GAME_PLAYER || wChairID<0) ASSERT(false); return m_lGameTatolScore[wChairID]; }
- //查询癞子数
- virtual int QueryTatolLaiGang(WORD wChairID){ if (wChairID >= GAME_PLAYER || wChairID < 0) ASSERT(false); return 0; }
- //查询是否使用临时积分
- virtual bool QueryUseTemporaryScore() {
- return (0 != lstrlen(m_gameConfig.sPrivateTableID)); //私有房间私用临时积分
- }
- //设置基数
- virtual void SetGameBaseScore(LONG lBaseScore){};
-
-
- /*
- 用户事件 ----------------------------------------------------------------------------
- */
- //public:
- //用户断线
- virtual bool OnActionUserOffLine(WORD wChairID, IServerUserItem * pIServerUserItem) { return true; }
- //用户重入 需要处理重新发送指令
- virtual bool OnActionUserConnect(WORD wChairID, IServerUserItem * pIServerUserItem);
- //用户坐下
- 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);
- //游戏中途旁观进入
- virtual bool PerformLookonLogin(IServerUserItem * pIServerUserItem);
-
- //
- ///*
- // 游戏事件 ----------------------------------------------------------------------------
- //*/
- //public:
- // //设置游戏配置
- virtual void SetGameConfig(VOID * pDataBuffer, WORD wDataSize, std::wstring sPrivateRoomId);
- //游戏开始事件
- virtual bool OnEventGameStart();
- // //游戏消息处理
- virtual bool OnGameMessage(WORD wSubCmdID, VOID * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem);
- // //框架消息处理
- virtual bool OnFrameMessage(WORD wSubCmdID, VOID * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem);
- // //发送场景 断线重连
- virtual bool OnEventSendGameScene(WORD wChiarID, IServerUserItem * pIServerUserItem, BYTE cbGameStatus, bool bSendSecret);
- // //游戏结束事件
- virtual bool OnEventGameConclude(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason, bool bSendState = false);
- //
- //
- // //定时器事件
- virtual bool OnTimerMessage(DWORD wTimerID, WPARAM wBindParam);
- // //数据事件
- virtual bool OnDataBaseMessage(WORD wRequestID, VOID * pData, WORD wDataSize);
- // //积分事件
- virtual bool OnUserScroeNotify(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason);
- //
- //protected:
- //
- ///*
- // 辅助函数 ----------------------------------------------------------------------------
- //*/
- //
- //
- ///*
- // 回放纪录 ----------------------------------------------------------------------------
- //*/
- //public:
- //开始纪录回放数据
- bool RepayRecordStart();
- //纪录回放数据
- bool RepayRecord(WORD wChairID, WORD wSubCmdId, void* pData, WORD wSize);
- //上传回放数据到数据库
- bool RepayRecordEnd();
-
- private:
- //用户操作
- bool OnUserOperate(WORD wChairID, CMD_C_OPERATE_CALLBACK_SK* pOperateCallback, BYTE cbType = 0);
-
-
- public:
-
- bool IsTeShuCard(BYTE cbCardData[], BYTE cbCount, BomoType& BomoInfo, WORD&WinScore);
- //具体执行函数
- private:
-
- //用户出牌
- //cbJokerReplacePoker 王 替换的牌
- bool OnUserOutCard(WORD wChairID, BYTE bCardData[], BYTE bCardCount, BYTE cbCardType, BYTE cbJokerReplacePoker[4], BYTE LianxianInfo);
- //判断是否为自由出牌
- bool BeOutCardFree(WORD wChairID);
- //下家操作
- bool NextOperate(WORD wChairID);
- void PrintCards(const BYTE cbCardData[], short cbCount);
- //寻找队友
- void FindCardOwner(BOOL &bSwitchChair);
- //队友换桌
- void SwapSeat();
- //提示
- bool OnUserHint(WORD wChairID);
- void SortCard(BYTE cbCardData[], BYTE cbCardCount);
-
-
-
- BOOL IsWinByChairID(BYTE wChairID);
- //按位分析 特殊牌
- void WithByteAnalyzeCardFlags(BYTE lianxianinfo, BomoType &BomoInfo);
-
- void SetCardFlags(BOOL IsLian, BYTE fuOrLian, BYTE xian);
-
- bool TrusteeOut(WORD wChairID);
-
- bool SendTeamfrindCards(WORD MyWchairID);
-
- //重新设置排名 为游戏结束 以玩家座位号为key 排名为值
- bool RestartRank(const BYTE cbRank[4], BYTE outRandToEnd[4]);
- //删除当前用户的出牌记录
- BOOL DeleteListOutCardRecord(DWORD wChairID);
-
- void ReadGameData();
-
- //计算 某个玩家此次出牌 的炸弹 是否符合累计出到某F某线,并计算特殊分数
- BOOL IsHaveBoomCountScore(BYTE wCharid, BYTE cbCardCount, WORD & WinScore);
- };
-
- //////////////////////////////////////////////////////////////////////////
-
- #endif
|