Skip to content

Commit

Permalink
新增基础库api
Browse files Browse the repository at this point in the history
新增基础库api
  • Loading branch information
limingfan2016 committed Jun 30, 2018
1 parent 624c4af commit 77609d4
Show file tree
Hide file tree
Showing 26 changed files with 904 additions and 55 deletions.
12 changes: 11 additions & 1 deletion service_common_lib/CServiceOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ const NCattlesBaseConfig::CattlesBaseConfig& CServiceOperation::getCattlesBaseCf
return NCattlesBaseConfig::CattlesBaseConfig::getConfigValue(NCommonConfig::CommonCfg::getConfigValue().config_file.cattles_base_cfg.c_str(), isReset);
}

const NGoldenFraudBaseConfig::GoldenFraudBaseConfig& CServiceOperation::getGoldenFraudBaseCfg(bool isReset)
{
return NGoldenFraudBaseConfig::GoldenFraudBaseConfig::getConfigValue(NCommonConfig::CommonCfg::getConfigValue().config_file.golden_fraud_base_cfg.c_str(), isReset);
}

const NFightLandlordBaseConfig::FightLandlordBaseConfig& CServiceOperation::getFightLandlordBaseCfg(bool isReset)
{
return NFightLandlordBaseConfig::FightLandlordBaseConfig::getConfigValue(NCommonConfig::CommonCfg::getConfigValue().config_file.fight_landlord_base_cfg.c_str(), isReset);
}

bool CServiceOperation::createDataLogger(const char* cfgName, const char* fileItem, const char* sizeItem, const char* backupCountItem)
{
if (m_dataLogger == NULL)
Expand Down Expand Up @@ -167,7 +177,7 @@ void CServiceOperation::stopTimer(unsigned int& timerId)
unsigned int CServiceOperation::getRecordId(RecordIDType recordId)
{
static unsigned int SRecordIndex = 0;
const unsigned int MaxRecordIndex = 100000;
const unsigned int MaxRecordIndex = 1000000;

return snprintf(recordId, sizeof(RecordIDType) - 1, "%uS%uI%u", (unsigned int)time(NULL), m_msgHandler->getSrvId(), ++SRecordIndex % MaxRecordIndex);
}
Expand Down
10 changes: 9 additions & 1 deletion service_common_lib/CServiceOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#include "_NCommonConfig_.h"
#include "_DBConfig_.h"
#include "_MallConfigData_.h"
#include "_NCattlesBaseConfig_.h"
#include "_ServiceCommonConfig_.h"
#include "_NCattlesBaseConfig_.h"
#include "_NGoldenFraudBaseConfig_.h"
#include "_NFightLandlordBaseConfig_.h"


namespace NProject
Expand Down Expand Up @@ -54,6 +56,12 @@ class CServiceOperation : public NFrame::CHandler

// 牛牛游戏基础配置信息
const NCattlesBaseConfig::CattlesBaseConfig& getCattlesBaseCfg(bool isReset = false);

// 炸金花游戏基础配置信息
const NGoldenFraudBaseConfig::GoldenFraudBaseConfig& getGoldenFraudBaseCfg(bool isReset = false);

// 斗地主游戏基础配置信息
const NFightLandlordBaseConfig::FightLandlordBaseConfig& getFightLandlordBaseCfg(bool isReset = false);

public:
// 检查服务数据日志配置信息并创建对应的日志对象
Expand Down
9 changes: 9 additions & 0 deletions service_common_lib/CattlesErrorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ enum ECattlesErrorCode
CattlesOnPlayCanNotChangeRoom = 11023, // 玩家游戏中,不可以更换房间
CattlesOnPlayCanNotLeaveRoom = 11024, // 玩家游戏中,不可以离开房间
CattlesInvalidChessHallId = 11025, // 无效的棋牌室ID

CattlesRoomCardInsufficient = 11026, // 房卡数量不足
CattlesNotRoomCreator = 11027, // 不是房间的创建者
CattlesNotAutoStartRoom = 11028, // 不是自动开桌的房间
CattlesNotManualStartRoom = 11029, // 不是手动开桌的房间
CattlesHasSitDownPlayer = 11030, // 存在在座未准备的玩家
CattlesStartPlayerInsufficient = 11031, // 开桌玩家人数不足

CattlesAskDismissRoomFrequently = 11032, // 玩家频繁请求解散房间
};


Expand Down
3 changes: 3 additions & 0 deletions service_common_lib/CattlesProtocolId.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ enum EClientCattlesProtocolId
CATTLES_PLAYER_CHOICE_BANKER_REQ = 1015,
CATTLES_PLAYER_CHOICE_BANKER_RSP = 1016,
CATTLES_PLAYER_CHOICE_BANKER_NOTIFY = 1017,

// 通知玩家可以手动开始游戏(房卡手动开桌)
CATTLES_MANUAL_START_GAME_NOTIFY = 1018,
};


Expand Down
92 changes: 70 additions & 22 deletions service_common_lib/CommonDataDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,6 @@ using namespace std;
namespace NProject
{

// 服务内部公共的消息协议ID,范围[0 --- 1000]
enum EServiceCommonProtocolId
{
// 关闭重复的连接,用户重复登录了
// 所有服务包括大厅和游戏服务收到该消息则对应的用户必须退出服务
SERVICE_CLOSE_REPEATE_CONNECT_NOTIFY = 1,

// 管理员给玩家赠送物品通知大厅&游戏服务
SERVICE_MANAGER_GIVE_GOODS_NOTIFY = 2,

// 游戏服务系统公告消息通知
SERVICE_GAME_MSG_NOTICE_NOTIFY = 3,

// 玩家收到其他游戏玩家邀请一起游戏通知
SERVICE_PLAYER_INVITATION_NOTIFY = 4,

// 玩家收到拒绝邀请通知
SERVICE_REFUSE_INVITATION_NOTIFY = 5,
};


// 所有游戏与客户端间的固定消息协议ID,范围[0 --- 1000]
enum EClientGameCommonProtocolId
{
Expand Down Expand Up @@ -113,6 +92,71 @@ enum EClientGameCommonProtocolId
COMM_PLAYER_CHANGE_ROOM_REQ = 27,
COMM_PLAYER_CHANGE_ROOM_RSP = 28,
COMM_PLAYER_CHANGE_ROOM_NOTIFY = 29,

// 通知客户端开始游戏
COMM_START_GAME_NOTIFY = 30,

// 玩家手动开始游戏
COMM_PLAYER_START_GAME_REQ = 31,
COMM_PLAYER_START_GAME_RSP = 32,

// 玩家解散房间
COMM_PLAYER_DISMISS_ROOM_REQ = 33,
COMM_PLAYER_DISMISS_ROOM_RSP = 34,
COMM_PLAYER_DISMISS_ROOM_ASK_NOTIFY = 35,
COMM_PLAYER_DISMISS_ROOM_ANSWER_NOTIFY = 36,
COMM_PLAYER_CONFIRM_DISMISS_ROOM_NOTIFY = 37,
COMM_PLAYER_CANCEL_DISMISS_ROOM_NOTIFY = 38,

// 准备下一局游戏通知(房卡场)
COMM_PREPARE_GAME_NOTIFY = 39,

// 通知客户端结束游戏
COMM_FINISH_GAME_NOTIFY = 40,

// 倒计时通知
COMM_TIME_OUT_SECONDS_NOTIFY = 41,

// 游戏准备按钮状态通知
COMM_PREPARE_STATUS_NOTIFY = 42,

// 通知玩家可以手动开始游戏(房卡手动开桌)
COMM_MANUAL_START_GAME_NOTIFY = 43,

// 房卡大结算通知
COMM_ROOM_TOTAL_SETTLEMENT_NOTIFY = 44,
};


// 服务内部公共的消息协议ID,范围[0 --- 1000]
enum EServiceCommonProtocolId
{
// 关闭重复的连接,用户重复登录了
// 所有服务包括大厅和游戏服务收到该消息则对应的用户必须退出服务
SERVICE_CLOSE_REPEATE_CONNECT_NOTIFY = 1,

// 管理员给玩家赠送物品通知大厅&游戏服务
SERVICE_MANAGER_GIVE_GOODS_NOTIFY = 2,

// 游戏服务系统公告消息通知
SERVICE_GAME_MSG_NOTICE_NOTIFY = 3,

// 玩家收到其他游戏玩家邀请一起游戏通知
SERVICE_PLAYER_INVITATION_NOTIFY = 4,

// 玩家收到拒绝邀请通知
SERVICE_REFUSE_INVITATION_NOTIFY = 5,
};


// 服务内部公共的自定义应答协议ID值
// 其值必须大于 MaxProtocolIDCount = 8192
enum EServiceCommonReplyProtocolId
{
SERVICE_COMMON_MIN_PROTOCOL_ID = 10000, // 服务自定义应答协议最小ID值

SERVICE_COMMON_GET_USER_INFO_FOR_ENTER_ROOM = 10001, // 用户进入房间获取个人信息
SERVICE_COMMON_GET_ROOM_INFO_FOR_ENTER_ROOM = 10002, // 用户进入房间获取房间信息
};


Expand Down Expand Up @@ -159,6 +203,9 @@ enum EGameGoodsType
EMallFlower = 104, // 鲜花
EMallSoap = 105, // 肥皂
EMaxMallGoodsType, // 最大商城物品类型

// 其他类型
EWinLoseResult = 1001, // 输赢结果
};

// 服务操作类型
Expand Down Expand Up @@ -195,12 +242,13 @@ enum ServiceType

// 游戏服务类型
CattlesGame = 11, // 牛牛游戏
GoldenFraudGame = 12, // 炸金花游戏
FightLandlordGame = 13, // 斗地主游戏
};

// 服务ID的倍数基值,即服务 ServiceType = ServiceID / ServiceIdBaseValue
static const unsigned int ServiceIdBaseValue = 1000;


/*
// 逻辑数据类型
enum ELogicDataType
Expand Down
24 changes: 0 additions & 24 deletions service_common_lib/CommonType.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,6 @@ struct GameServiceData // 此数据内容对应的二级key为 用户ID
#pragma pack()


/*
// 道具变更记录信息
struct RecordItem
{
unsigned int type;
int count;
RecordItem() {};
RecordItem(unsigned int _type, int _count) : type(_type), count(_count) {};
};
typedef vector<RecordItem> RecordItemVector;
// 道具变更记录信息(多人)
struct MoreUserRecordItem
{
string src_username; // 源用户
string dst_username; // 目标用户
string remark; // 游戏记录信息
RecordItemVector items; // 变更的道具
};
typedef vector<MoreUserRecordItem> MoreUserRecordItemVector;
*/


// 从redis获取到的大厅逻辑数据,一级key为"HallLogicData",二级key为用户ID
static const char* HallLogicDataKey = "HallLogicData";
static const int HallLogicDataKeyLen = strlen(HallLogicDataKey);
Expand Down
20 changes: 20 additions & 0 deletions service_common_lib/DBProxyErrorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ enum EDBProxyErrorCode

DBProxyQueryManagerPlatformInfoError = 2093, // 获取管理员所在的平台信息错误
DBProxyQueryManagerIdError = 2094, // 查询棋牌室管理员ID错误

DBProxyCreateRoomCardInsufficient = 2095, // 创建棋牌室游戏房间房卡数量不足

DBProxyGenerateRoomGameRecordSqlError = 2096, // 生成房间游戏记录sql语句错误
DBProxyAddRoomGameRecordError = 2097, // 添加房间游戏记录错误

DBProxyQueryGameRoomError = 2098, // 查询游戏房间失败
DBProxyNoFoundGameRoomError = 2099, // 找不到棋牌室游戏房间
DBProxyGameRoomStatusError = 2100, // 游戏房间状态错误

DBProxyQueryRoomGameRecordError = 2101, // 查询房间游戏记录信息错误
DBProxyQueryRoomRecordPlayerError = 2102, // 查询房间游戏记录玩家信息错误
DBProxyGetRoomRecordPlayerError = 2103, // 获取房间游戏记录玩家信息错误
DBProxyQueryDetailedRoomRecordError = 2104, // 查询房间游戏详细记录错误

DBProxyUpdateUserStaticInfoFailed = 2105, // 刷新用户静态信息失败
DBProxyUpdateUserDynamicInfoFailed = 2106, // 刷新用户动态信息失败

DBProxyBuyGoldRoomCardInsufficient = 2107, // 购买金币房卡数量不足
DBProxyAddGoodsExchangeRecordError = 2108, // 添加物品兑换记录错误
};


Expand Down
20 changes: 20 additions & 0 deletions service_common_lib/DBProxyProtocolId.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ enum EDBProxyProtocolId
// 获取棋牌室玩家信息列表
DBPROXY_GET_HALL_PLAYER_LIST_REQ = 77,
DBPROXY_GET_HALL_PLAYER_LIST_RSP = 78,

// 设置房间游戏记录
DBPROXY_SET_ROOM_GAME_RECORD_REQ = 79,
DBPROXY_SET_ROOM_GAME_RECORD_RSP = 80,

// 查询游戏房间
DBPROXY_QUERY_GAME_ROOM_REQ = 81,
DBPROXY_QUERY_GAME_ROOM_RSP = 82,

// 获取房间游戏战绩信息
DBPROXY_GET_ROOM_GAME_RECORD_REQ = 83,
DBPROXY_GET_ROOM_GAME_RECORD_RSP = 84,

// 获取详细房间游戏战绩信息
DBPROXY_GET_DETAILED_ROOM_GAME_RECORD_REQ = 85,
DBPROXY_GET_DETAILED_ROOM_GAME_RECORD_RSP = 86,

// 房卡购买金币
DBPROXY_ROOM_CARD_BUY_GOLD_REQ = 87,
DBPROXY_ROOM_CARD_BUY_GOLD_RSP = 88,
};


Expand Down
30 changes: 30 additions & 0 deletions service_common_lib/FightLandlordErrorCode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

/* author : limingfan
* date : 2018.04.19
* description : 斗地主游戏服务错误码定义
*/

#ifndef __FIGHT_LANDLORD_GAME_ERROR_CODE_H__
#define __FIGHT_LANDLORD_GAME_ERROR_CODE_H__


// 斗地主游戏服务错误码 13301 - 13999
enum EFightLandlordErrorCode
{
FightLandlordNotFoundPlayer = 13301, // 找不到游戏玩家
FightLandlordGameStatusInvalidOpt = 13302, // 游戏状态错误,操作不允许
FightLandlordPlayerStatusInvalid = 13303, // 玩家状态无效
FightLandlordPlayerOptInvalid = 13304, // 无效的玩家操作
FightLandlordNotCurrentOptPlayer = 13305, // 非当前操作玩家
FightLandlordGoldInsufficient = 13306, // 金币不足
FightLandlordPlayCardParamInvalid = 13307, // 出牌参数错误
FightLandlordPlayCardNotExist = 13308, // 出了不存在的牌
FightLandlordPlayCardTypeInvalid = 13309, // 打出的牌型无效
FightLandlordPlayCardValueSmall = 13310, // 打出的牌值小,不能压制对方
FightLandlordPlayCardCountInvalid = 13311, // 打出的牌数目不对
FightLandlordPlayCardTypeMismatch = 13312, // 打出的牌型不匹配
};


#endif // __FIGHT_LANDLORD_GAME_ERROR_CODE_H__

38 changes: 38 additions & 0 deletions service_common_lib/FightLandlordProtocolId.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

/* author : limingfan
* date : 2018.04.19
* description : 斗地主游戏服务协议码ID定义
*/

#ifndef __FIGHT_LANDLORD_GAME_PROTOCOL_ID_H__
#define __FIGHT_LANDLORD_GAME_PROTOCOL_ID_H__


// 斗地主游戏与客户端间的消息协议ID
enum EClientFightLandlordProtocolId
{
// 所有游戏与客户端间的自定义消息协议ID值从 2001 开始
// 前 2000 位值由公共协议 EClientGameCommonProtocolId 占用

// 游戏开始发牌给玩家
FIGHTLANDLORD_PUSH_CARD_NOTIFY = 2001,

// 玩家操作(叫地主、抢地主、出牌、托管)
FIGHTLANDLORD_PLAYER_OPT_REQ = 2002,
FIGHTLANDLORD_PLAYER_OPT_RSP = 2003,
FIGHTLANDLORD_PLAYER_OPT_NOTIFY = 2004,

// 结算通知
FIGHTLANDLORD_SETTLEMENT_NOTIFY = 2015,
};


// 服务内部消息协议ID,值从 1001 开始
// 前 1000 位值由公共协议 EServiceCommonProtocolId 占用
enum EServiceFightLandlordProtocolId
{
};


#endif // __FIGHT_LANDLORD_GAME_PROTOCOL_ID_H__

5 changes: 5 additions & 0 deletions service_common_lib/GameHallErrorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ enum EGameHallErrorCode
GameHallInvalidPhoneVerificationCode = 1014, // 无效的手机验证码

GameHallCreateGameRoomParamInvalid = 1015, // 创建棋牌室游戏房间参数无效
GameHallCreateRoomPlayerCountInvalid = 1016, // 创建棋牌室游戏房间玩家人数无效
GameHallCreateRoomGameTimesInvalid = 1017, // 创建棋牌室游戏房间游戏局数无效
GameHallCreateRoomPayModeInvalid = 1018, // 创建棋牌室游戏房间付费模式无效
GameHallCreateRoomStartModeInvalid = 1019, // 创建棋牌室游戏房间开桌方式无效
GameHallCreateRoomBaseRateInvalid = 1020, // 创建棋牌室游戏房间底注(基础倍率)无效
};


Expand Down
19 changes: 19 additions & 0 deletions service_common_lib/GameHallProtocolId.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@ enum EClientGameHallProtocolId
// 用户离开当前棋牌室
CGH_USER_LEAVE_HALL_REQ = 61,
CGH_USER_LEAVE_HALL_RSP = 62,

// 查询游戏房间
CGH_QUERY_GAME_ROOM_REQ = 63,
CGH_QUERY_GAME_ROOM_RSP = 64,

// 获取房间游戏战绩信息
CGH_GET_ROOM_GAME_RECORD_REQ = 65,
CGH_GET_ROOM_GAME_RECORD_RSP = 66,

// 获取详细房间游戏战绩信息
CGH_GET_DETAILED_ROOM_GAME_RECORD_REQ = 67,
CGH_GET_DETAILED_ROOM_GAME_RECORD_RSP = 68,

// 房卡购买金币
CGH_ROOM_CARD_BUY_GOLD_REQ = 69,
CGH_ROOM_CARD_BUY_GOLD_RSP = 70,

// 系统消息通知
CGH_SYSTEM_MESSAGE_NOTIFY = 71,
};


Expand Down
Loading

0 comments on commit 77609d4

Please sign in to comment.