玩家下注及每秒更新投注区域的业务逻辑

This commit is contained in:
liuxiaobo 2025-06-10 23:33:37 +08:00
parent 31c9af105d
commit 4c8e9de082
11 changed files with 320 additions and 253 deletions

View File

@ -6,6 +6,7 @@ enum ErrCode
{
OK = 0;
SystemErr = 1; //
ParamErr = 2; //
LoginDiffLoc = 100; //
LoginUserOrPwdErr = 102; //
AccountFrozen = 103; //
@ -14,6 +15,9 @@ enum ErrCode
VersionTooLow = 115; //
Maintain = 120; //
GoldNotEnough = 125; //
TotalBetExceedsLimit = 130; //
AreaBetExceedsLimit = 135; //
}

View File

@ -152,22 +152,21 @@ message ReqColorBetting
message RspColorBetting
{
ErrCode code = 1;
ColorBetArea area = 2;
int64 bet = 3;
int64 gold = 4; //
ColorBetAreaInfo areaInfo = 2;
}
message ColorBetAreaInfo
{
ColorBetArea area = 1; //
int64 totalBet = 2; //
int32 playerNum = 3; //
int64 myBet = 4; //
}
//
message NtfColorBetAreaInfo
{
message BetAreaInfo
{
ColorBetArea area = 1; //
int64 totalGold = 2; //
int32 playerNum = 3; //
int64 myBet = 4; //
}
repeated BetAreaInfo areaInfos = 1;
repeated ColorBetAreaInfo areaInfos = 1;
}
//

View File

@ -32,19 +32,18 @@ enum MsgId
NtfUserEnterRoomId = 2202; //
// color game 2300-2399
NtfColorRoomInfoId = 2300;
NtfColorGameStartId = 2305;
NtfColorBettingId = 2310;
ReqColorBettingId = 2315;
NtfColorRoomInfoId = 2300; //
NtfColorGameStartId = 2305; //
NtfColorBettingId = 2310; //
ReqColorBettingId = 2315; //
RspColorBettingId = 2320;
NtfColorBetAreaInfoId = 2325;
NtfColorEndBettingId = 2330;
NtfColorOpenThreeDiceId = 2335;
NtfColorSettleId = 2340;
NtfColorBigUserId = 2345;
NtfColorTrendId = 2350;
NtfColorKickOutUserId = 2355;
NtfColorMaintainId = 2360;
NtfColorBetAreaInfoId = 2325; //
NtfColorEndBettingId = 2330; //
NtfColorOpenThreeDiceId = 2335; //
NtfColorSettleId = 2340; //
NtfColorBigUserId = 2345; //
NtfColorTrendId = 2350; //
NtfColorKickOutUserId = 2355; //
}

View File

@ -26,6 +26,7 @@ type ErrCode int32
const (
ErrCode_OK ErrCode = 0
ErrCode_SystemErr ErrCode = 1 // 系统错误
ErrCode_ParamErr ErrCode = 2 // 参数错误
ErrCode_LoginDiffLoc ErrCode = 100 // 帐号在其它地方登陆
ErrCode_LoginUserOrPwdErr ErrCode = 102 // 帐号或密码错误
ErrCode_AccountFrozen ErrCode = 103 // 帐号已冻结
@ -33,6 +34,9 @@ const (
ErrCode_RegisterUserExist ErrCode = 110 // 已有该帐号,无法注册
ErrCode_VersionTooLow ErrCode = 115 // 版本太低,无法登陆
ErrCode_Maintain ErrCode = 120 // 系统维护
ErrCode_GoldNotEnough ErrCode = 125 // 金币不足
ErrCode_TotalBetExceedsLimit ErrCode = 130 // 总投注超过极限
ErrCode_AreaBetExceedsLimit ErrCode = 135 // 区域投注超过极限
)
// Enum value maps for ErrCode.
@ -40,6 +44,7 @@ var (
ErrCode_name = map[int32]string{
0: "OK",
1: "SystemErr",
2: "ParamErr",
100: "LoginDiffLoc",
102: "LoginUserOrPwdErr",
103: "AccountFrozen",
@ -47,10 +52,14 @@ var (
110: "RegisterUserExist",
115: "VersionTooLow",
120: "Maintain",
125: "GoldNotEnough",
130: "TotalBetExceedsLimit",
135: "AreaBetExceedsLimit",
}
ErrCode_value = map[string]int32{
"OK": 0,
"SystemErr": 1,
"ParamErr": 2,
"LoginDiffLoc": 100,
"LoginUserOrPwdErr": 102,
"AccountFrozen": 103,
@ -58,6 +67,9 @@ var (
"RegisterUserExist": 110,
"VersionTooLow": 115,
"Maintain": 120,
"GoldNotEnough": 125,
"TotalBetExceedsLimit": 130,
"AreaBetExceedsLimit": 135,
}
)
@ -93,17 +105,21 @@ var File_code_proto protoreflect.FileDescriptor
const file_code_proto_rawDesc = "" +
"\n" +
"\n" +
"code.proto\x12\x02pb*\xa7\x01\n" +
"code.proto\x12\x02pb*\xfd\x01\n" +
"\aErrCode\x12\x06\n" +
"\x02OK\x10\x00\x12\r\n" +
"\tSystemErr\x10\x01\x12\x10\n" +
"\tSystemErr\x10\x01\x12\f\n" +
"\bParamErr\x10\x02\x12\x10\n" +
"\fLoginDiffLoc\x10d\x12\x15\n" +
"\x11LoginUserOrPwdErr\x10f\x12\x11\n" +
"\rAccountFrozen\x10g\x12\x11\n" +
"\rAccountBanned\x10h\x12\x15\n" +
"\x11RegisterUserExist\x10n\x12\x11\n" +
"\rVersionTooLow\x10s\x12\f\n" +
"\bMaintain\x10xB\x11Z\x0fcommon/proto/pbb\x06proto3"
"\bMaintain\x10x\x12\x11\n" +
"\rGoldNotEnough\x10}\x12\x19\n" +
"\x14TotalBetExceedsLimit\x10\x82\x01\x12\x18\n" +
"\x13AreaBetExceedsLimit\x10\x87\x01B\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_code_proto_rawDescOnce sync.Once

View File

@ -1016,9 +1016,7 @@ func (x *ReqColorBetting) GetBet() int64 {
type RspColorBetting struct {
state protoimpl.MessageState `protogen:"open.v1"`
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"`
Area ColorBetArea `protobuf:"varint,2,opt,name=area,proto3,enum=pb.ColorBetArea" json:"area,omitempty"`
Bet int64 `protobuf:"varint,3,opt,name=bet,proto3" json:"bet,omitempty"`
Gold int64 `protobuf:"varint,4,opt,name=gold,proto3" json:"gold,omitempty"` // 玩家一共有多少金币
AreaInfo *ColorBetAreaInfo `protobuf:"bytes,2,opt,name=areaInfo,proto3" json:"areaInfo,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -1060,23 +1058,77 @@ func (x *RspColorBetting) GetCode() ErrCode {
return ErrCode_OK
}
func (x *RspColorBetting) GetArea() ColorBetArea {
func (x *RspColorBetting) GetAreaInfo() *ColorBetAreaInfo {
if x != nil {
return x.AreaInfo
}
return nil
}
type ColorBetAreaInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
Area ColorBetArea `protobuf:"varint,1,opt,name=area,proto3,enum=pb.ColorBetArea" json:"area,omitempty"` // 投注区域
TotalBet int64 `protobuf:"varint,2,opt,name=totalBet,proto3" json:"totalBet,omitempty"` // 所有玩家总投注金额
PlayerNum int32 `protobuf:"varint,3,opt,name=playerNum,proto3" json:"playerNum,omitempty"` // 投注该区域人数
MyBet int64 `protobuf:"varint,4,opt,name=myBet,proto3" json:"myBet,omitempty"` // 我的投注金额
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ColorBetAreaInfo) Reset() {
*x = ColorBetAreaInfo{}
mi := &file_colorgame_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ColorBetAreaInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ColorBetAreaInfo) ProtoMessage() {}
func (x *ColorBetAreaInfo) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[13]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ColorBetAreaInfo.ProtoReflect.Descriptor instead.
func (*ColorBetAreaInfo) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{13}
}
func (x *ColorBetAreaInfo) GetArea() ColorBetArea {
if x != nil {
return x.Area
}
return ColorBetArea_CBA_Yellow
}
func (x *RspColorBetting) GetBet() int64 {
func (x *ColorBetAreaInfo) GetTotalBet() int64 {
if x != nil {
return x.Bet
return x.TotalBet
}
return 0
}
func (x *RspColorBetting) GetGold() int64 {
func (x *ColorBetAreaInfo) GetPlayerNum() int32 {
if x != nil {
return x.Gold
return x.PlayerNum
}
return 0
}
func (x *ColorBetAreaInfo) GetMyBet() int64 {
if x != nil {
return x.MyBet
}
return 0
}
@ -1084,14 +1136,14 @@ func (x *RspColorBetting) GetGold() int64 {
// 更新投注区域信息
type NtfColorBetAreaInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
AreaInfos []*NtfColorBetAreaInfo_BetAreaInfo `protobuf:"bytes,1,rep,name=areaInfos,proto3" json:"areaInfos,omitempty"`
AreaInfos []*ColorBetAreaInfo `protobuf:"bytes,1,rep,name=areaInfos,proto3" json:"areaInfos,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *NtfColorBetAreaInfo) Reset() {
*x = NtfColorBetAreaInfo{}
mi := &file_colorgame_proto_msgTypes[13]
mi := &file_colorgame_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1103,7 +1155,7 @@ func (x *NtfColorBetAreaInfo) String() string {
func (*NtfColorBetAreaInfo) ProtoMessage() {}
func (x *NtfColorBetAreaInfo) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[13]
mi := &file_colorgame_proto_msgTypes[14]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1116,10 +1168,10 @@ func (x *NtfColorBetAreaInfo) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorBetAreaInfo.ProtoReflect.Descriptor instead.
func (*NtfColorBetAreaInfo) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{13}
return file_colorgame_proto_rawDescGZIP(), []int{14}
}
func (x *NtfColorBetAreaInfo) GetAreaInfos() []*NtfColorBetAreaInfo_BetAreaInfo {
func (x *NtfColorBetAreaInfo) GetAreaInfos() []*ColorBetAreaInfo {
if x != nil {
return x.AreaInfos
}
@ -1139,7 +1191,7 @@ type ColorBetAreaMul struct {
func (x *ColorBetAreaMul) Reset() {
*x = ColorBetAreaMul{}
mi := &file_colorgame_proto_msgTypes[14]
mi := &file_colorgame_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1151,7 +1203,7 @@ func (x *ColorBetAreaMul) String() string {
func (*ColorBetAreaMul) ProtoMessage() {}
func (x *ColorBetAreaMul) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[14]
mi := &file_colorgame_proto_msgTypes[15]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1164,7 +1216,7 @@ func (x *ColorBetAreaMul) ProtoReflect() protoreflect.Message {
// Deprecated: Use ColorBetAreaMul.ProtoReflect.Descriptor instead.
func (*ColorBetAreaMul) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{14}
return file_colorgame_proto_rawDescGZIP(), []int{15}
}
func (x *ColorBetAreaMul) GetArea() ColorBetArea {
@ -1207,7 +1259,7 @@ type NtfColorEndBetting struct {
func (x *NtfColorEndBetting) Reset() {
*x = NtfColorEndBetting{}
mi := &file_colorgame_proto_msgTypes[15]
mi := &file_colorgame_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1219,7 +1271,7 @@ func (x *NtfColorEndBetting) String() string {
func (*NtfColorEndBetting) ProtoMessage() {}
func (x *NtfColorEndBetting) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[15]
mi := &file_colorgame_proto_msgTypes[16]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1232,7 +1284,7 @@ func (x *NtfColorEndBetting) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorEndBetting.ProtoReflect.Descriptor instead.
func (*NtfColorEndBetting) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{15}
return file_colorgame_proto_rawDescGZIP(), []int{16}
}
func (x *NtfColorEndBetting) GetEndTime() int64 {
@ -1267,7 +1319,7 @@ type NtfColorOpenThreeDice struct {
func (x *NtfColorOpenThreeDice) Reset() {
*x = NtfColorOpenThreeDice{}
mi := &file_colorgame_proto_msgTypes[16]
mi := &file_colorgame_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1279,7 +1331,7 @@ func (x *NtfColorOpenThreeDice) String() string {
func (*NtfColorOpenThreeDice) ProtoMessage() {}
func (x *NtfColorOpenThreeDice) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[16]
mi := &file_colorgame_proto_msgTypes[17]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1292,7 +1344,7 @@ func (x *NtfColorOpenThreeDice) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorOpenThreeDice.ProtoReflect.Descriptor instead.
func (*NtfColorOpenThreeDice) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{16}
return file_colorgame_proto_rawDescGZIP(), []int{17}
}
func (x *NtfColorOpenThreeDice) GetColor() []ColorType {
@ -1331,7 +1383,7 @@ type NtfColorSettle struct {
func (x *NtfColorSettle) Reset() {
*x = NtfColorSettle{}
mi := &file_colorgame_proto_msgTypes[17]
mi := &file_colorgame_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1343,7 +1395,7 @@ func (x *NtfColorSettle) String() string {
func (*NtfColorSettle) ProtoMessage() {}
func (x *NtfColorSettle) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[17]
mi := &file_colorgame_proto_msgTypes[18]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1356,7 +1408,7 @@ func (x *NtfColorSettle) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorSettle.ProtoReflect.Descriptor instead.
func (*NtfColorSettle) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{17}
return file_colorgame_proto_rawDescGZIP(), []int{18}
}
func (x *NtfColorSettle) GetUserAreaWin() []*NtfColorSettle_UserBetAreaMul {
@ -1415,7 +1467,7 @@ type ColorUser struct {
func (x *ColorUser) Reset() {
*x = ColorUser{}
mi := &file_colorgame_proto_msgTypes[18]
mi := &file_colorgame_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1427,7 +1479,7 @@ func (x *ColorUser) String() string {
func (*ColorUser) ProtoMessage() {}
func (x *ColorUser) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[18]
mi := &file_colorgame_proto_msgTypes[19]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1440,7 +1492,7 @@ func (x *ColorUser) ProtoReflect() protoreflect.Message {
// Deprecated: Use ColorUser.ProtoReflect.Descriptor instead.
func (*ColorUser) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{18}
return file_colorgame_proto_rawDescGZIP(), []int{19}
}
func (x *ColorUser) GetNick() string {
@ -1488,7 +1540,7 @@ type NtfColorBigUser struct {
func (x *NtfColorBigUser) Reset() {
*x = NtfColorBigUser{}
mi := &file_colorgame_proto_msgTypes[19]
mi := &file_colorgame_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1500,7 +1552,7 @@ func (x *NtfColorBigUser) String() string {
func (*NtfColorBigUser) ProtoMessage() {}
func (x *NtfColorBigUser) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[19]
mi := &file_colorgame_proto_msgTypes[20]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1513,7 +1565,7 @@ func (x *NtfColorBigUser) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorBigUser.ProtoReflect.Descriptor instead.
func (*NtfColorBigUser) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{19}
return file_colorgame_proto_rawDescGZIP(), []int{20}
}
func (x *NtfColorBigUser) GetBigUser() []*ColorBigUser {
@ -1533,7 +1585,7 @@ type NtfColorTrend struct {
func (x *NtfColorTrend) Reset() {
*x = NtfColorTrend{}
mi := &file_colorgame_proto_msgTypes[20]
mi := &file_colorgame_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1545,7 +1597,7 @@ func (x *NtfColorTrend) String() string {
func (*NtfColorTrend) ProtoMessage() {}
func (x *NtfColorTrend) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[20]
mi := &file_colorgame_proto_msgTypes[21]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1558,7 +1610,7 @@ func (x *NtfColorTrend) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorTrend.ProtoReflect.Descriptor instead.
func (*NtfColorTrend) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{20}
return file_colorgame_proto_rawDescGZIP(), []int{21}
}
func (x *NtfColorTrend) GetColorRate() []*NtfColorTrend_ColorRate {
@ -1581,7 +1633,7 @@ type ColorBigUser struct {
func (x *ColorBigUser) Reset() {
*x = ColorBigUser{}
mi := &file_colorgame_proto_msgTypes[21]
mi := &file_colorgame_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1593,7 +1645,7 @@ func (x *ColorBigUser) String() string {
func (*ColorBigUser) ProtoMessage() {}
func (x *ColorBigUser) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[21]
mi := &file_colorgame_proto_msgTypes[22]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1606,7 +1658,7 @@ func (x *ColorBigUser) ProtoReflect() protoreflect.Message {
// Deprecated: Use ColorBigUser.ProtoReflect.Descriptor instead.
func (*ColorBigUser) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{21}
return file_colorgame_proto_rawDescGZIP(), []int{22}
}
func (x *ColorBigUser) GetNickName() string {
@ -1646,7 +1698,7 @@ type NtfColorKickOutUser struct {
func (x *NtfColorKickOutUser) Reset() {
*x = NtfColorKickOutUser{}
mi := &file_colorgame_proto_msgTypes[22]
mi := &file_colorgame_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1658,7 +1710,7 @@ func (x *NtfColorKickOutUser) String() string {
func (*NtfColorKickOutUser) ProtoMessage() {}
func (x *NtfColorKickOutUser) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[22]
mi := &file_colorgame_proto_msgTypes[23]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1671,7 +1723,7 @@ func (x *NtfColorKickOutUser) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorKickOutUser.ProtoReflect.Descriptor instead.
func (*NtfColorKickOutUser) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{22}
return file_colorgame_proto_rawDescGZIP(), []int{23}
}
func (x *NtfColorKickOutUser) GetCode() ErrCode {
@ -1692,7 +1744,7 @@ type NtfColorMaintain struct {
func (x *NtfColorMaintain) Reset() {
*x = NtfColorMaintain{}
mi := &file_colorgame_proto_msgTypes[23]
mi := &file_colorgame_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1704,7 +1756,7 @@ func (x *NtfColorMaintain) String() string {
func (*NtfColorMaintain) ProtoMessage() {}
func (x *NtfColorMaintain) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[23]
mi := &file_colorgame_proto_msgTypes[24]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1717,7 +1769,7 @@ func (x *NtfColorMaintain) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorMaintain.ProtoReflect.Descriptor instead.
func (*NtfColorMaintain) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{23}
return file_colorgame_proto_rawDescGZIP(), []int{24}
}
func (x *NtfColorMaintain) GetMsg() string {
@ -1734,74 +1786,6 @@ func (x *NtfColorMaintain) GetGold() int64 {
return 0
}
type NtfColorBetAreaInfo_BetAreaInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
Area ColorBetArea `protobuf:"varint,1,opt,name=area,proto3,enum=pb.ColorBetArea" json:"area,omitempty"` // 投注区域
TotalGold int64 `protobuf:"varint,2,opt,name=totalGold,proto3" json:"totalGold,omitempty"` // 所有玩家总投注金额
PlayerNum int32 `protobuf:"varint,3,opt,name=playerNum,proto3" json:"playerNum,omitempty"` // 投注该区域人数
MyBet int64 `protobuf:"varint,4,opt,name=myBet,proto3" json:"myBet,omitempty"` // 我的投注金额
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *NtfColorBetAreaInfo_BetAreaInfo) Reset() {
*x = NtfColorBetAreaInfo_BetAreaInfo{}
mi := &file_colorgame_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NtfColorBetAreaInfo_BetAreaInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NtfColorBetAreaInfo_BetAreaInfo) ProtoMessage() {}
func (x *NtfColorBetAreaInfo_BetAreaInfo) ProtoReflect() protoreflect.Message {
mi := &file_colorgame_proto_msgTypes[24]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NtfColorBetAreaInfo_BetAreaInfo.ProtoReflect.Descriptor instead.
func (*NtfColorBetAreaInfo_BetAreaInfo) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{13, 0}
}
func (x *NtfColorBetAreaInfo_BetAreaInfo) GetArea() ColorBetArea {
if x != nil {
return x.Area
}
return ColorBetArea_CBA_Yellow
}
func (x *NtfColorBetAreaInfo_BetAreaInfo) GetTotalGold() int64 {
if x != nil {
return x.TotalGold
}
return 0
}
func (x *NtfColorBetAreaInfo_BetAreaInfo) GetPlayerNum() int32 {
if x != nil {
return x.PlayerNum
}
return 0
}
func (x *NtfColorBetAreaInfo_BetAreaInfo) GetMyBet() int64 {
if x != nil {
return x.MyBet
}
return 0
}
type NtfColorSettle_UserBetAreaMul struct {
state protoimpl.MessageState `protogen:"open.v1"`
AreaMul *ColorBetAreaMul `protobuf:"bytes,1,opt,name=areaMul,proto3" json:"areaMul,omitempty"`
@ -1839,7 +1823,7 @@ func (x *NtfColorSettle_UserBetAreaMul) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorSettle_UserBetAreaMul.ProtoReflect.Descriptor instead.
func (*NtfColorSettle_UserBetAreaMul) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{17, 0}
return file_colorgame_proto_rawDescGZIP(), []int{18, 0}
}
func (x *NtfColorSettle_UserBetAreaMul) GetAreaMul() *ColorBetAreaMul {
@ -1905,7 +1889,7 @@ func (x *NtfColorTrend_ColorRate) ProtoReflect() protoreflect.Message {
// Deprecated: Use NtfColorTrend_ColorRate.ProtoReflect.Descriptor instead.
func (*NtfColorTrend_ColorRate) Descriptor() ([]byte, []int) {
return file_colorgame_proto_rawDescGZIP(), []int{20, 0}
return file_colorgame_proto_rawDescGZIP(), []int{21, 0}
}
func (x *NtfColorTrend_ColorRate) GetColor() ColorType {
@ -1968,19 +1952,17 @@ const file_colorgame_proto_rawDesc = "" +
"\aendTime\x18\x01 \x01(\x03R\aendTime\"I\n" +
"\x0fReqColorBetting\x12$\n" +
"\x04area\x18\x01 \x01(\x0e2\x10.pb.ColorBetAreaR\x04area\x12\x10\n" +
"\x03bet\x18\x02 \x01(\x03R\x03bet\"~\n" +
"\x03bet\x18\x02 \x01(\x03R\x03bet\"d\n" +
"\x0fRspColorBetting\x12\x1f\n" +
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12$\n" +
"\x04area\x18\x02 \x01(\x0e2\x10.pb.ColorBetAreaR\x04area\x12\x10\n" +
"\x03bet\x18\x03 \x01(\x03R\x03bet\x12\x12\n" +
"\x04gold\x18\x04 \x01(\x03R\x04gold\"\xe0\x01\n" +
"\x13NtfColorBetAreaInfo\x12A\n" +
"\tareaInfos\x18\x01 \x03(\v2#.pb.NtfColorBetAreaInfo.BetAreaInfoR\tareaInfos\x1a\x85\x01\n" +
"\vBetAreaInfo\x12$\n" +
"\x04area\x18\x01 \x01(\x0e2\x10.pb.ColorBetAreaR\x04area\x12\x1c\n" +
"\ttotalGold\x18\x02 \x01(\x03R\ttotalGold\x12\x1c\n" +
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x120\n" +
"\bareaInfo\x18\x02 \x01(\v2\x14.pb.ColorBetAreaInfoR\bareaInfo\"\x88\x01\n" +
"\x10ColorBetAreaInfo\x12$\n" +
"\x04area\x18\x01 \x01(\x0e2\x10.pb.ColorBetAreaR\x04area\x12\x1a\n" +
"\btotalBet\x18\x02 \x01(\x03R\btotalBet\x12\x1c\n" +
"\tplayerNum\x18\x03 \x01(\x05R\tplayerNum\x12\x14\n" +
"\x05myBet\x18\x04 \x01(\x03R\x05myBet\"\xad\x01\n" +
"\x05myBet\x18\x04 \x01(\x03R\x05myBet\"I\n" +
"\x13NtfColorBetAreaInfo\x122\n" +
"\tareaInfos\x18\x01 \x03(\v2\x14.pb.ColorBetAreaInfoR\tareaInfos\"\xad\x01\n" +
"\x0fColorBetAreaMul\x12$\n" +
"\x04area\x18\x01 \x01(\x0e2\x10.pb.ColorBetAreaR\x04area\x120\n" +
"\tprizeArea\x18\x02 \x01(\x0e2\x12.pb.ColorPrizeAreaR\tprizeArea\x120\n" +
@ -2117,18 +2099,18 @@ var file_colorgame_proto_goTypes = []any{
(*NtfColorBetting)(nil), // 15: pb.NtfColorBetting
(*ReqColorBetting)(nil), // 16: pb.ReqColorBetting
(*RspColorBetting)(nil), // 17: pb.RspColorBetting
(*NtfColorBetAreaInfo)(nil), // 18: pb.NtfColorBetAreaInfo
(*ColorBetAreaMul)(nil), // 19: pb.ColorBetAreaMul
(*NtfColorEndBetting)(nil), // 20: pb.NtfColorEndBetting
(*NtfColorOpenThreeDice)(nil), // 21: pb.NtfColorOpenThreeDice
(*NtfColorSettle)(nil), // 22: pb.NtfColorSettle
(*ColorUser)(nil), // 23: pb.ColorUser
(*NtfColorBigUser)(nil), // 24: pb.NtfColorBigUser
(*NtfColorTrend)(nil), // 25: pb.NtfColorTrend
(*ColorBigUser)(nil), // 26: pb.ColorBigUser
(*NtfColorKickOutUser)(nil), // 27: pb.NtfColorKickOutUser
(*NtfColorMaintain)(nil), // 28: pb.NtfColorMaintain
(*NtfColorBetAreaInfo_BetAreaInfo)(nil), // 29: pb.NtfColorBetAreaInfo.BetAreaInfo
(*ColorBetAreaInfo)(nil), // 18: pb.ColorBetAreaInfo
(*NtfColorBetAreaInfo)(nil), // 19: pb.NtfColorBetAreaInfo
(*ColorBetAreaMul)(nil), // 20: pb.ColorBetAreaMul
(*NtfColorEndBetting)(nil), // 21: pb.NtfColorEndBetting
(*NtfColorOpenThreeDice)(nil), // 22: pb.NtfColorOpenThreeDice
(*NtfColorSettle)(nil), // 23: pb.NtfColorSettle
(*ColorUser)(nil), // 24: pb.ColorUser
(*NtfColorBigUser)(nil), // 25: pb.NtfColorBigUser
(*NtfColorTrend)(nil), // 26: pb.NtfColorTrend
(*ColorBigUser)(nil), // 27: pb.ColorBigUser
(*NtfColorKickOutUser)(nil), // 28: pb.NtfColorKickOutUser
(*NtfColorMaintain)(nil), // 29: pb.NtfColorMaintain
(*NtfColorSettle_UserBetAreaMul)(nil), // 30: pb.NtfColorSettle.UserBetAreaMul
(*NtfColorTrend_ColorRate)(nil), // 31: pb.NtfColorTrend.ColorRate
(ErrCode)(0), // 32: pb.ErrCode
@ -2136,18 +2118,18 @@ var file_colorgame_proto_goTypes = []any{
var file_colorgame_proto_depIdxs = []int32{
0, // 0: pb.ColorPrizeAreaRange.pos:type_name -> pb.ColorPrizeArea
5, // 1: pb.ColorRoomConfig.mulRangeConfig:type_name -> pb.ColorPrizeAreaRange
25, // 2: pb.ColorRoomWaitStart.Trends:type_name -> pb.NtfColorTrend
26, // 2: pb.ColorRoomWaitStart.Trends:type_name -> pb.NtfColorTrend
14, // 3: pb.ColorRoomStart.start:type_name -> pb.NtfColorGameStart
25, // 4: pb.ColorRoomStart.Trends:type_name -> pb.NtfColorTrend
18, // 5: pb.ColorRoomBetting.betAreaInfo:type_name -> pb.NtfColorBetAreaInfo
20, // 6: pb.ColorRoomEndBet.areaMul:type_name -> pb.NtfColorEndBetting
18, // 7: pb.ColorRoomEndBet.betAreaInfo:type_name -> pb.NtfColorBetAreaInfo
24, // 8: pb.ColorRoomEndBet.bigUser:type_name -> pb.NtfColorBigUser
21, // 9: pb.ColorRoomOpenThreeDice.dices:type_name -> pb.NtfColorOpenThreeDice
22, // 10: pb.ColorRoomSettle.settle:type_name -> pb.NtfColorSettle
26, // 4: pb.ColorRoomStart.Trends:type_name -> pb.NtfColorTrend
19, // 5: pb.ColorRoomBetting.betAreaInfo:type_name -> pb.NtfColorBetAreaInfo
21, // 6: pb.ColorRoomEndBet.areaMul:type_name -> pb.NtfColorEndBetting
19, // 7: pb.ColorRoomEndBet.betAreaInfo:type_name -> pb.NtfColorBetAreaInfo
25, // 8: pb.ColorRoomEndBet.bigUser:type_name -> pb.NtfColorBigUser
22, // 9: pb.ColorRoomOpenThreeDice.dices:type_name -> pb.NtfColorOpenThreeDice
23, // 10: pb.ColorRoomSettle.settle:type_name -> pb.NtfColorSettle
3, // 11: pb.NtfColorRoomInfo.status:type_name -> pb.ColorGameStatus
6, // 12: pb.NtfColorRoomInfo.config:type_name -> pb.ColorRoomConfig
23, // 13: pb.NtfColorRoomInfo.user:type_name -> pb.ColorUser
24, // 13: pb.NtfColorRoomInfo.user:type_name -> pb.ColorUser
7, // 14: pb.NtfColorRoomInfo.waitStart:type_name -> pb.ColorRoomWaitStart
8, // 15: pb.NtfColorRoomInfo.start:type_name -> pb.ColorRoomStart
9, // 16: pb.NtfColorRoomInfo.betting:type_name -> pb.ColorRoomBetting
@ -2156,21 +2138,21 @@ var file_colorgame_proto_depIdxs = []int32{
12, // 19: pb.NtfColorRoomInfo.settle:type_name -> pb.ColorRoomSettle
2, // 20: pb.ReqColorBetting.area:type_name -> pb.ColorBetArea
32, // 21: pb.RspColorBetting.code:type_name -> pb.ErrCode
2, // 22: pb.RspColorBetting.area:type_name -> pb.ColorBetArea
29, // 23: pb.NtfColorBetAreaInfo.areaInfos:type_name -> pb.NtfColorBetAreaInfo.BetAreaInfo
2, // 24: pb.ColorBetAreaMul.area:type_name -> pb.ColorBetArea
0, // 25: pb.ColorBetAreaMul.prizeArea:type_name -> pb.ColorPrizeArea
4, // 26: pb.ColorBetAreaMul.prizeType:type_name -> pb.ColorPrizeType
19, // 27: pb.NtfColorEndBetting.areaMul:type_name -> pb.ColorBetAreaMul
1, // 28: pb.NtfColorOpenThreeDice.color:type_name -> pb.ColorType
2, // 29: pb.NtfColorOpenThreeDice.winArea:type_name -> pb.ColorBetArea
30, // 30: pb.NtfColorSettle.userAreaWin:type_name -> pb.NtfColorSettle.UserBetAreaMul
1, // 31: pb.NtfColorSettle.threeDice:type_name -> pb.ColorType
26, // 32: pb.NtfColorBigUser.bigUser:type_name -> pb.ColorBigUser
31, // 33: pb.NtfColorTrend.colorRate:type_name -> pb.NtfColorTrend.ColorRate
32, // 34: pb.NtfColorKickOutUser.code:type_name -> pb.ErrCode
2, // 35: pb.NtfColorBetAreaInfo.BetAreaInfo.area:type_name -> pb.ColorBetArea
19, // 36: pb.NtfColorSettle.UserBetAreaMul.areaMul:type_name -> pb.ColorBetAreaMul
18, // 22: pb.RspColorBetting.areaInfo:type_name -> pb.ColorBetAreaInfo
2, // 23: pb.ColorBetAreaInfo.area:type_name -> pb.ColorBetArea
18, // 24: pb.NtfColorBetAreaInfo.areaInfos:type_name -> pb.ColorBetAreaInfo
2, // 25: pb.ColorBetAreaMul.area:type_name -> pb.ColorBetArea
0, // 26: pb.ColorBetAreaMul.prizeArea:type_name -> pb.ColorPrizeArea
4, // 27: pb.ColorBetAreaMul.prizeType:type_name -> pb.ColorPrizeType
20, // 28: pb.NtfColorEndBetting.areaMul:type_name -> pb.ColorBetAreaMul
1, // 29: pb.NtfColorOpenThreeDice.color:type_name -> pb.ColorType
2, // 30: pb.NtfColorOpenThreeDice.winArea:type_name -> pb.ColorBetArea
30, // 31: pb.NtfColorSettle.userAreaWin:type_name -> pb.NtfColorSettle.UserBetAreaMul
1, // 32: pb.NtfColorSettle.threeDice:type_name -> pb.ColorType
27, // 33: pb.NtfColorBigUser.bigUser:type_name -> pb.ColorBigUser
31, // 34: pb.NtfColorTrend.colorRate:type_name -> pb.NtfColorTrend.ColorRate
32, // 35: pb.NtfColorKickOutUser.code:type_name -> pb.ErrCode
20, // 36: pb.NtfColorSettle.UserBetAreaMul.areaMul:type_name -> pb.ColorBetAreaMul
1, // 37: pb.NtfColorTrend.ColorRate.color:type_name -> pb.ColorType
38, // [38:38] is the sub-list for method output_type
38, // [38:38] is the sub-list for method input_type

View File

@ -45,19 +45,18 @@ const (
MsgId_RspMatchRoomId MsgId = 2201
MsgId_NtfUserEnterRoomId MsgId = 2202 // 玩家进入房间 所有玩法共用此消息
// color game 2300-2399
MsgId_NtfColorRoomInfoId MsgId = 2300
MsgId_NtfColorGameStartId MsgId = 2305
MsgId_NtfColorBettingId MsgId = 2310
MsgId_ReqColorBettingId MsgId = 2315
MsgId_NtfColorRoomInfoId MsgId = 2300 // 进房间推送房间所有信息
MsgId_NtfColorGameStartId MsgId = 2305 // 游戏开始
MsgId_NtfColorBettingId MsgId = 2310 // 通知可以下注
MsgId_ReqColorBettingId MsgId = 2315 // 下注
MsgId_RspColorBettingId MsgId = 2320
MsgId_NtfColorBetAreaInfoId MsgId = 2325
MsgId_NtfColorEndBettingId MsgId = 2330
MsgId_NtfColorOpenThreeDiceId MsgId = 2335
MsgId_NtfColorSettleId MsgId = 2340
MsgId_NtfColorBigUserId MsgId = 2345
MsgId_NtfColorTrendId MsgId = 2350
MsgId_NtfColorKickOutUserId MsgId = 2355
MsgId_NtfColorMaintainId MsgId = 2360
MsgId_NtfColorBetAreaInfoId MsgId = 2325 // 每秒更新投注区域信息
MsgId_NtfColorEndBettingId MsgId = 2330 // 通知下注结束
MsgId_NtfColorOpenThreeDiceId MsgId = 2335 // 开三个骰子
MsgId_NtfColorSettleId MsgId = 2340 // 结算
MsgId_NtfColorBigUserId MsgId = 2345 // 大客数据
MsgId_NtfColorTrendId MsgId = 2350 // 路途数据
MsgId_NtfColorKickOutUserId MsgId = 2355 // 踢出不下注玩家
)
// Enum value maps for MsgId.
@ -88,7 +87,6 @@ var (
2345: "NtfColorBigUserId",
2350: "NtfColorTrendId",
2355: "NtfColorKickOutUserId",
2360: "NtfColorMaintainId",
}
MsgId_value = map[string]int32{
"MI_Unknown": 0,
@ -116,7 +114,6 @@ var (
"NtfColorBigUserId": 2345,
"NtfColorTrendId": 2350,
"NtfColorKickOutUserId": 2355,
"NtfColorMaintainId": 2360,
}
)
@ -151,7 +148,7 @@ var File_msgId_proto protoreflect.FileDescriptor
const file_msgId_proto_rawDesc = "" +
"\n" +
"\vmsgId.proto\x12\x02pb*\xdb\x04\n" +
"\vmsgId.proto\x12\x02pb*\xc2\x04\n" +
"\x05MsgId\x12\x0e\n" +
"\n" +
"MI_Unknown\x10\x00\x12\x12\n" +
@ -178,8 +175,7 @@ const file_msgId_proto_rawDesc = "" +
"\x10NtfColorSettleId\x10\xa4\x12\x12\x16\n" +
"\x11NtfColorBigUserId\x10\xa9\x12\x12\x14\n" +
"\x0fNtfColorTrendId\x10\xae\x12\x12\x1a\n" +
"\x15NtfColorKickOutUserId\x10\xb3\x12\x12\x17\n" +
"\x12NtfColorMaintainId\x10\xb8\x12B\x11Z\x0fcommon/proto/pbb\x06proto3"
"\x15NtfColorKickOutUserId\x10\xb3\x12B\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_msgId_proto_rawDescOnce sync.Once

View File

@ -10,11 +10,49 @@ func (rm *ColorRoom) checkEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, re
return
}
func (rm *ColorRoom) OnEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) {
func (rm *ColorRoom) onEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) {
return
}
func (rm *ColorRoom) checkBet(user *ColorPlayer, _ *ipb.InternalMsg, req *pb.ReqColorBetting) pb.ErrCode {
if req.Area < pb.ColorBetArea_CBA_Yellow || req.Area > pb.ColorBetArea_CBA_Green3 {
return pb.ErrCode_ParamErr
}
// 金币不足,无法下注
if rm.GetGold(user) < user.totalBet+req.Bet {
return pb.ErrCode_GoldNotEnough
}
if rm.roomCfg.TotalBetLimit < user.totalBet+req.Bet {
return pb.ErrCode_TotalBetExceedsLimit
}
if rm.roomCfg.AreaBetLimit < user.totalBets[req.Area]+req.Bet {
return pb.ErrCode_AreaBetExceedsLimit
}
return pb.ErrCode_OK
}
func (rm *ColorRoom) onBet(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqColorBetting) {
code := rm.checkBet(user, iMsg, req)
if code != pb.ErrCode_OK {
rm.SendMsg(user, pb.MsgId_RspColorBettingId, &pb.RspColorBetting{Code: code})
}
curBetAreaInfo := rm.betAreaInfo[req.Area]
_, _ = rm.AddGold(user, -req.Bet)
curBetAreaInfo.TotalBet += req.Bet
if user.totalBets[req.Area] == 0 {
curBetAreaInfo.PlayerNum++
}
user.totalBets[req.Area] += req.Bet
curBetAreaInfo.MyBet = user.totalBets[req.Area]
rm.SendMsg(user, pb.MsgId_RspColorBettingId, &pb.RspColorBetting{
Code: code,
AreaInfo: curBetAreaInfo,
})
return
}
//---------------------------------------------------------------------------------------------------------------------
//
//func (rm *ColorRoom) ApplyLeave(buffer []byte, user inter.UserInetr) {

View File

@ -15,8 +15,6 @@ type ColorPlayer struct {
totalBet int64 // 总下注金额
totalBets []int64 // 各个区域的下注
settleMsg *pb.NtfColorSettle // 本局结算消息
costGold int64 // 本局消耗金币
}
func NewColorPlayer(gateTopicName string, roomId int, u *user.User, res *user.UserResources) *ColorPlayer {
@ -47,7 +45,6 @@ func (p *ColorPlayer) RoomId() int {
// 游戏开始前,清理玩家上局数据
func (p *ColorPlayer) resetData() {
p.settleMsg = &pb.NtfColorSettle{}
p.costGold = 0
p.totalBet = 0
p.totalBets = p.totalBets[:0]
for range pb.ColorBetArea_name {

View File

@ -27,6 +27,7 @@ type ColorRoom struct {
jackpotUser map[int64]int64 // 本局中jackpot的玩家用于游戏内广播
bigUsers []*pb.ColorBigUser // 前6个大客户
trend [][]pb.ColorType // 路途
betAreaInfo []*pb.ColorBetAreaInfo // 本局每个投注区域信息
}
func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.ErrCode) {
@ -43,6 +44,7 @@ func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.Er
jackpotMgr: jackpot.NewJackpotMgr(playType, model.UserRedis),
}
rm.trend = rm.initGameTrend()
rm.resetGameData()
code := pb.ErrCode_OK
rm.BaseRoom, code = baseroom.NewBaseRoom[ColorSeat](id, roomType, playType, srv)
@ -57,7 +59,8 @@ func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.Er
func (rm *ColorRoom) OnInit() {
rm.RegisterMessages(processor.RegisterMetas{
pb.MsgId_ReqMatchRoomId: {pb.ReqMatchRoom{}, rm.OnEnterRoom},
pb.MsgId_ReqMatchRoomId: {pb.ReqMatchRoom{}, rm.onEnterRoom},
pb.MsgId_ReqColorBettingId: {pb.ReqColorBetting{}, rm.onBet},
})
rm.RegisterTimerMessages(processor.RegisterTimerMetas{
TtGameStart: rm.gameStart,
@ -65,6 +68,7 @@ func (rm *ColorRoom) OnInit() {
TtEndBet: rm.gameEndBetting,
TtOpenThreeDices: rm.gameOpenThreeDices,
TtSettle: rm.gameSettle,
TtSecond: rm.onSecond,
})
rm.gameStart()
@ -78,6 +82,15 @@ func (rm *ColorRoom) resetGameData() {
rm.ntfOpenThreeDice = &pb.NtfColorOpenThreeDice{}
rm.jackpotValue = rm.jackpotMgr.GetJackpot()
rm.bigUsers = rm.bigUsers[0:0]
rm.betAreaInfo = rm.betAreaInfo[:0]
for area := pb.ColorBetArea_CBA_Yellow; area < pb.ColorBetArea_CBA_Green3; area++ {
rm.betAreaInfo = append(rm.betAreaInfo, &pb.ColorBetAreaInfo{
Area: area,
TotalBet: 0,
PlayerNum: 0,
MyBet: 0,
})
}
// 清理玩家身上数据
for _, st := range rm.Seats {
@ -89,16 +102,16 @@ func (rm *ColorRoom) resetGameData() {
// 当前拥有金币
func (rm *ColorRoom) GetGold(user *ColorPlayer) int64 {
return user.Gold - user.costGold
return user.Gold - user.totalBet
}
// 加减金币
func (rm *ColorRoom) AddGold(user *ColorPlayer, add int64) (int64, bool) {
if user.Gold-user.costGold+add < 0 {
return user.Gold - user.costGold, false
if user.Gold-user.totalBet+add < 0 {
return user.Gold - user.totalBet, false
}
user.costGold += add
return user.Gold - user.costGold, false
user.totalBet += add
return user.Gold - user.totalBet, true
}
// ---------------------------------------------------------------------------------------------------

View File

@ -16,6 +16,7 @@ func (rm *ColorRoom) gameStartBetting() {
rm.setStatus(pb.ColorGameStatus_CGS_Betting)
rm.notifyBetting()
rm.NewTimer(TtEndBet, time.Duration(rm.timingCfg.Betting)*time.Millisecond)
rm.NewTimer(TtSecond, time.Second)
}
func (rm *ColorRoom) gameEndBetting() {
@ -41,6 +42,14 @@ func (rm *ColorRoom) gameSettle() {
rm.NewTimer(TtGameStart, time.Duration(rm.timingCfg.Settle)*time.Millisecond)
}
// 每秒定时器干的活
func (rm *ColorRoom) onSecond() {
rm.notifyColorBetAreaInfo()
if rm.status < pb.ColorGameStatus_CGS_BetEnd {
rm.NewTimer(TtGameStart, time.Second)
}
}
//
// import (
// "encoding/json"

View File

@ -49,6 +49,20 @@ func (rm *ColorRoom) notifyTrend() {
rm.Broadcast(pb.MsgId_NtfColorTrendId, rm.getNotifyTrend())
}
// 每秒更新各投注区域投注信息
func (rm *ColorRoom) notifyColorBetAreaInfo() {
rm.RangePlayer(func(u baseroom.IPlayer) bool {
user := GetPlayer(u)
for _, areaInfo := range rm.betAreaInfo {
areaInfo.MyBet = user.totalBets[areaInfo.Area]
}
rm.SendMsg(user, pb.MsgId_NtfColorBetAreaInfoId, &pb.NtfColorBetAreaInfo{
AreaInfos: rm.betAreaInfo,
})
return true
})
}
//
// import (
// "encoding/json"