color game业务逻辑,包含进出房间,踢玩家,房间信息同步等。
This commit is contained in:
parent
50d10e8da7
commit
f250853e6c
26
README.md
26
README.md
@ -18,24 +18,32 @@
|
||||
9. login在创建帐号时,还需要创建user。(已实现,待验证) todo
|
||||
|
||||
3. 编写color game玩法
|
||||
1. 房间配置。(已完成)
|
||||
2. 创建房间、加载玩家数据。(doing)
|
||||
3. 停服时能及时关闭服务。(待验证)
|
||||
1. 房间配置。(已实现,待测试)
|
||||
2. 创建房间、加载玩家数据。(已实现,待测试)
|
||||
3. 玩家进出房间及房间信息同步。(已实现,待测试)
|
||||
3. 停服时能及时关闭服务。(已实现,待测试)
|
||||
4. 定制消息。(已完成)
|
||||
5. 具体业务实现。
|
||||
1. 开始游戏、通知下注、通知下注结束、开骰子、结算。(已实现)
|
||||
2. 玩家下注、每秒更新投注区域信息。(已实现)
|
||||
1. 开始游戏、通知下注、通知下注结束、开骰子、结算。(已实现,待测试)
|
||||
2. 玩家下注、每秒更新投注区域信息。(已实现,待测试)
|
||||
6. 机器人实现。(未开始)
|
||||
|
||||
4. 编写match服
|
||||
1. 初步实现框架,并转发color匹配消息。(无需匹配,匹配服直接转发给color game)
|
||||
4. 编写大厅lobby服 (未开始)
|
||||
1. 玩家上线时通知玩家他所在的玩法。方便玩家重连进入该玩法服。
|
||||
|
||||
5. 编写管理后台
|
||||
5. 编写match服
|
||||
1. 初步实现框架,并转发匹配消息。(已实现,待测试)
|
||||
2. color无需匹配,匹配服直接转发给color game。(已实现,待测试)
|
||||
|
||||
6. 编写管理后台
|
||||
1. 玩法配置
|
||||
2. 金流查询
|
||||
3. 牌局日志
|
||||
|
||||
6. 客户端编写 u3d
|
||||
7. log服
|
||||
1. 使用clickhouse做存储
|
||||
|
||||
8. 客户端编写 u3d
|
||||
1. 网络连接
|
||||
2. ui,动画等
|
||||
3. 玩法逻辑
|
@ -3,6 +3,7 @@ package baseroom
|
||||
import (
|
||||
"fmt"
|
||||
"game/common/proto/pb"
|
||||
"game/common/utils"
|
||||
"github.com/fox/fox/ipb"
|
||||
"github.com/fox/fox/log"
|
||||
"github.com/fox/fox/processor"
|
||||
@ -85,22 +86,24 @@ func (r *BaseRoom[Seat]) RobotPlayerNum() int {
|
||||
return num
|
||||
}
|
||||
|
||||
func (r *BaseRoom[Seat]) HasEmptySeat() bool {
|
||||
// 返回是否有空座位及空座位编号
|
||||
func (r *BaseRoom[Seat]) HasEmptySeat() (bool, int) {
|
||||
for _, seat := range r.Seats {
|
||||
if seat.Empty() {
|
||||
return true
|
||||
return true, seat.No()
|
||||
}
|
||||
}
|
||||
return false
|
||||
return false, -1
|
||||
}
|
||||
|
||||
func (r *BaseRoom[Seat]) HasPlayer(uid int64) bool {
|
||||
// 查找玩家及玩家所在的座位
|
||||
func (r *BaseRoom[Seat]) FindPlayer(uid int64) (IPlayer, Seat) {
|
||||
for _, seat := range r.Seats {
|
||||
if !seat.Empty() && seat.Player().Id() == uid {
|
||||
return true
|
||||
return seat.Player(), seat
|
||||
}
|
||||
}
|
||||
return false
|
||||
return nil, utils.TValue[Seat]{}.V
|
||||
}
|
||||
|
||||
func (r *BaseRoom[Seat]) AddPlayer(player IPlayer, seat int) {
|
||||
|
@ -12,7 +12,7 @@ type IRoom interface {
|
||||
OnInit()
|
||||
// SeatPlayerNum() int
|
||||
// HasEmptySeat() bool
|
||||
// HasPlayer(uid int64) bool
|
||||
// FindPlayer(uid int64) bool
|
||||
Unmarshal(cmd int32, data []byte) (any, error)
|
||||
Dispatch(user IPlayer, cmd int32, params ...any) error
|
||||
// ReleaseRoom()
|
||||
|
@ -16,8 +16,11 @@ enum ErrCode
|
||||
|
||||
Maintain = 120; // 系统维护
|
||||
GoldNotEnough = 125; // 金币不足
|
||||
TotalBetExceedsLimit = 130; // 总投注超过极限
|
||||
AreaBetExceedsLimit = 135; // 区域投注超过极限
|
||||
NotBetCount = 126; // 数场不投注被踢出
|
||||
NotLeaveRoom = 127; // 无法离开房间(有下注)
|
||||
// color game
|
||||
TotalBetExceedsLimit = 500; // 总投注超过极限
|
||||
AreaBetExceedsLimit = 505; // 区域投注超过极限
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,10 +261,7 @@ message ColorBigUser
|
||||
repeated int64 areaId = 3; // 赢钱区域(前6个)
|
||||
}
|
||||
|
||||
message NtfColorKickOutUser
|
||||
{
|
||||
ErrCode code = 1; // 踢出原因
|
||||
}
|
||||
|
||||
|
||||
// 系统维护或流局
|
||||
message NtfColorMaintain
|
||||
|
39
common/pb/common.proto
Normal file
39
common/pb/common.proto
Normal file
@ -0,0 +1,39 @@
|
||||
syntax = "proto3";
|
||||
package pb;
|
||||
option go_package = "common/proto/pb";
|
||||
|
||||
import "code.proto";
|
||||
|
||||
// 踢出玩家
|
||||
message NtfKickOutUser
|
||||
{
|
||||
ErrCode code = 1; // 踢出原因
|
||||
}
|
||||
|
||||
// 玩家进入房间。首次玩家通过匹配服匹配进入玩法服,不需要发该消息
|
||||
// 玩家上线后,lobby服查找玩家在哪个玩法服并通知给玩家
|
||||
// 玩家收到消息后,发送ReqEnterRoom进入对应玩法服
|
||||
message ReqEnterRoom
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 玩家进房间返回。之后玩法服同步房间信息给玩家
|
||||
message RspEnterRoom
|
||||
{
|
||||
ErrCode code = 1;
|
||||
int32 PlayType = 2; // 玩法id
|
||||
int32 RoomType = 3; // 房间类型,低级,中级,高级等
|
||||
}
|
||||
|
||||
// 玩家离开房间
|
||||
message ReqLeaveRoom
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
message RspLeaveRoom
|
||||
{
|
||||
ErrCode code = 1;
|
||||
}
|
||||
|
@ -13,6 +13,11 @@ enum MsgId
|
||||
MI_Unknown = 0;
|
||||
|
||||
NtfMaintainId = 1000; // 通知维护
|
||||
NtfKickOutUserId = 1001; // 踢出玩家
|
||||
ReqEnterRoomId = 1002; // 进入房间
|
||||
RspEnterRoomId = 1003;
|
||||
ReqLeaveRoomId = 1004; // 离开房间
|
||||
RspLeaveRoomId = 1005;
|
||||
|
||||
// 聊天服 2000-2099
|
||||
ReqChatId = 2000; // 玩家聊天消息
|
||||
@ -43,7 +48,7 @@ enum MsgId
|
||||
NtfColorSettleId = 2340; // 结算
|
||||
NtfColorBigUserId = 2345; // 大客数据
|
||||
NtfColorTrendId = 2350; // 路途数据
|
||||
NtfColorKickOutUserId = 2355; // 踢出不下注玩家
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,19 +24,22 @@ const (
|
||||
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 // 帐号已冻结
|
||||
ErrCode_AccountBanned ErrCode = 104 // 帐号已封禁
|
||||
ErrCode_RegisterUserExist ErrCode = 110 // 已有该帐号,无法注册
|
||||
ErrCode_VersionTooLow ErrCode = 115 // 版本太低,无法登陆
|
||||
ErrCode_Maintain ErrCode = 120 // 系统维护
|
||||
ErrCode_GoldNotEnough ErrCode = 125 // 金币不足
|
||||
ErrCode_TotalBetExceedsLimit ErrCode = 130 // 总投注超过极限
|
||||
ErrCode_AreaBetExceedsLimit ErrCode = 135 // 区域投注超过极限
|
||||
ErrCode_OK ErrCode = 0
|
||||
ErrCode_SystemErr ErrCode = 1 // 系统错误
|
||||
ErrCode_ParamErr ErrCode = 2 // 参数错误
|
||||
ErrCode_LoginDiffLoc ErrCode = 100 // 帐号在其它地方登陆
|
||||
ErrCode_LoginUserOrPwdErr ErrCode = 102 // 帐号或密码错误
|
||||
ErrCode_AccountFrozen ErrCode = 103 // 帐号已冻结
|
||||
ErrCode_AccountBanned ErrCode = 104 // 帐号已封禁
|
||||
ErrCode_RegisterUserExist ErrCode = 110 // 已有该帐号,无法注册
|
||||
ErrCode_VersionTooLow ErrCode = 115 // 版本太低,无法登陆
|
||||
ErrCode_Maintain ErrCode = 120 // 系统维护
|
||||
ErrCode_GoldNotEnough ErrCode = 125 // 金币不足
|
||||
ErrCode_NotBetCount ErrCode = 126 // 数场不投注被踢出
|
||||
ErrCode_NotLeaveRoom ErrCode = 127 // 无法离开房间(有下注)
|
||||
// color game
|
||||
ErrCode_TotalBetExceedsLimit ErrCode = 500 // 总投注超过极限
|
||||
ErrCode_AreaBetExceedsLimit ErrCode = 505 // 区域投注超过极限
|
||||
)
|
||||
|
||||
// Enum value maps for ErrCode.
|
||||
@ -53,8 +56,10 @@ var (
|
||||
115: "VersionTooLow",
|
||||
120: "Maintain",
|
||||
125: "GoldNotEnough",
|
||||
130: "TotalBetExceedsLimit",
|
||||
135: "AreaBetExceedsLimit",
|
||||
126: "NotBetCount",
|
||||
127: "NotLeaveRoom",
|
||||
500: "TotalBetExceedsLimit",
|
||||
505: "AreaBetExceedsLimit",
|
||||
}
|
||||
ErrCode_value = map[string]int32{
|
||||
"OK": 0,
|
||||
@ -68,8 +73,10 @@ var (
|
||||
"VersionTooLow": 115,
|
||||
"Maintain": 120,
|
||||
"GoldNotEnough": 125,
|
||||
"TotalBetExceedsLimit": 130,
|
||||
"AreaBetExceedsLimit": 135,
|
||||
"NotBetCount": 126,
|
||||
"NotLeaveRoom": 127,
|
||||
"TotalBetExceedsLimit": 500,
|
||||
"AreaBetExceedsLimit": 505,
|
||||
}
|
||||
)
|
||||
|
||||
@ -105,7 +112,7 @@ var File_code_proto protoreflect.FileDescriptor
|
||||
const file_code_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"code.proto\x12\x02pb*\xfd\x01\n" +
|
||||
"code.proto\x12\x02pb*\xa0\x02\n" +
|
||||
"\aErrCode\x12\x06\n" +
|
||||
"\x02OK\x10\x00\x12\r\n" +
|
||||
"\tSystemErr\x10\x01\x12\f\n" +
|
||||
@ -117,9 +124,11 @@ const file_code_proto_rawDesc = "" +
|
||||
"\x11RegisterUserExist\x10n\x12\x11\n" +
|
||||
"\rVersionTooLow\x10s\x12\f\n" +
|
||||
"\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"
|
||||
"\rGoldNotEnough\x10}\x12\x0f\n" +
|
||||
"\vNotBetCount\x10~\x12\x10\n" +
|
||||
"\fNotLeaveRoom\x10\x7f\x12\x19\n" +
|
||||
"\x14TotalBetExceedsLimit\x10\xf4\x03\x12\x18\n" +
|
||||
"\x13AreaBetExceedsLimit\x10\xf9\x03B\x11Z\x0fcommon/proto/pbb\x06proto3"
|
||||
|
||||
var (
|
||||
file_code_proto_rawDescOnce sync.Once
|
||||
|
@ -1689,50 +1689,6 @@ func (x *ColorBigUser) GetAreaId() []int64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
type NtfColorKickOutUser struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"` // 踢出原因
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *NtfColorKickOutUser) Reset() {
|
||||
*x = NtfColorKickOutUser{}
|
||||
mi := &file_colorgame_proto_msgTypes[23]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *NtfColorKickOutUser) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NtfColorKickOutUser) ProtoMessage() {}
|
||||
|
||||
func (x *NtfColorKickOutUser) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_colorgame_proto_msgTypes[23]
|
||||
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 NtfColorKickOutUser.ProtoReflect.Descriptor instead.
|
||||
func (*NtfColorKickOutUser) Descriptor() ([]byte, []int) {
|
||||
return file_colorgame_proto_rawDescGZIP(), []int{23}
|
||||
}
|
||||
|
||||
func (x *NtfColorKickOutUser) GetCode() ErrCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrCode_OK
|
||||
}
|
||||
|
||||
// 系统维护或流局
|
||||
type NtfColorMaintain struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -1744,7 +1700,7 @@ type NtfColorMaintain struct {
|
||||
|
||||
func (x *NtfColorMaintain) Reset() {
|
||||
*x = NtfColorMaintain{}
|
||||
mi := &file_colorgame_proto_msgTypes[24]
|
||||
mi := &file_colorgame_proto_msgTypes[23]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1756,7 +1712,7 @@ func (x *NtfColorMaintain) String() string {
|
||||
func (*NtfColorMaintain) ProtoMessage() {}
|
||||
|
||||
func (x *NtfColorMaintain) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_colorgame_proto_msgTypes[24]
|
||||
mi := &file_colorgame_proto_msgTypes[23]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1769,7 +1725,7 @@ func (x *NtfColorMaintain) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use NtfColorMaintain.ProtoReflect.Descriptor instead.
|
||||
func (*NtfColorMaintain) Descriptor() ([]byte, []int) {
|
||||
return file_colorgame_proto_rawDescGZIP(), []int{24}
|
||||
return file_colorgame_proto_rawDescGZIP(), []int{23}
|
||||
}
|
||||
|
||||
func (x *NtfColorMaintain) GetMsg() string {
|
||||
@ -1798,7 +1754,7 @@ type NtfColorSettle_UserBetAreaMul struct {
|
||||
|
||||
func (x *NtfColorSettle_UserBetAreaMul) Reset() {
|
||||
*x = NtfColorSettle_UserBetAreaMul{}
|
||||
mi := &file_colorgame_proto_msgTypes[25]
|
||||
mi := &file_colorgame_proto_msgTypes[24]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1810,7 +1766,7 @@ func (x *NtfColorSettle_UserBetAreaMul) String() string {
|
||||
func (*NtfColorSettle_UserBetAreaMul) ProtoMessage() {}
|
||||
|
||||
func (x *NtfColorSettle_UserBetAreaMul) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_colorgame_proto_msgTypes[25]
|
||||
mi := &file_colorgame_proto_msgTypes[24]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1864,7 +1820,7 @@ type NtfColorTrend_ColorRate struct {
|
||||
|
||||
func (x *NtfColorTrend_ColorRate) Reset() {
|
||||
*x = NtfColorTrend_ColorRate{}
|
||||
mi := &file_colorgame_proto_msgTypes[26]
|
||||
mi := &file_colorgame_proto_msgTypes[25]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1876,7 +1832,7 @@ func (x *NtfColorTrend_ColorRate) String() string {
|
||||
func (*NtfColorTrend_ColorRate) ProtoMessage() {}
|
||||
|
||||
func (x *NtfColorTrend_ColorRate) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_colorgame_proto_msgTypes[26]
|
||||
mi := &file_colorgame_proto_msgTypes[25]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2005,9 +1961,7 @@ const file_colorgame_proto_rawDesc = "" +
|
||||
"\bnickName\x18\x05 \x01(\tR\bnickName\x12\x16\n" +
|
||||
"\x06avatar\x18\x02 \x01(\tR\x06avatar\x12\x1a\n" +
|
||||
"\bwinChips\x18\x01 \x01(\x03R\bwinChips\x12\x16\n" +
|
||||
"\x06areaId\x18\x03 \x03(\x03R\x06areaId\"6\n" +
|
||||
"\x13NtfColorKickOutUser\x12\x1f\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\"8\n" +
|
||||
"\x06areaId\x18\x03 \x03(\x03R\x06areaId\"8\n" +
|
||||
"\x10NtfColorMaintain\x12\x10\n" +
|
||||
"\x03msg\x18\x02 \x01(\tR\x03msg\x12\x12\n" +
|
||||
"\x04gold\x18\x03 \x01(\x03R\x04gold*e\n" +
|
||||
@ -2079,7 +2033,7 @@ func file_colorgame_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_colorgame_proto_enumTypes = make([]protoimpl.EnumInfo, 5)
|
||||
var file_colorgame_proto_msgTypes = make([]protoimpl.MessageInfo, 27)
|
||||
var file_colorgame_proto_msgTypes = make([]protoimpl.MessageInfo, 26)
|
||||
var file_colorgame_proto_goTypes = []any{
|
||||
(ColorPrizeArea)(0), // 0: pb.ColorPrizeArea
|
||||
(ColorType)(0), // 1: pb.ColorType
|
||||
@ -2109,11 +2063,10 @@ var file_colorgame_proto_goTypes = []any{
|
||||
(*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
|
||||
(*NtfColorMaintain)(nil), // 28: pb.NtfColorMaintain
|
||||
(*NtfColorSettle_UserBetAreaMul)(nil), // 29: pb.NtfColorSettle.UserBetAreaMul
|
||||
(*NtfColorTrend_ColorRate)(nil), // 30: pb.NtfColorTrend.ColorRate
|
||||
(ErrCode)(0), // 31: pb.ErrCode
|
||||
}
|
||||
var file_colorgame_proto_depIdxs = []int32{
|
||||
0, // 0: pb.ColorPrizeAreaRange.pos:type_name -> pb.ColorPrizeArea
|
||||
@ -2137,7 +2090,7 @@ var file_colorgame_proto_depIdxs = []int32{
|
||||
11, // 18: pb.NtfColorRoomInfo.openThreeDice:type_name -> pb.ColorRoomOpenThreeDice
|
||||
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
|
||||
31, // 21: pb.RspColorBetting.code:type_name -> pb.ErrCode
|
||||
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
|
||||
@ -2147,18 +2100,17 @@ var file_colorgame_proto_depIdxs = []int32{
|
||||
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
|
||||
29, // 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
|
||||
38, // [38:38] is the sub-list for extension type_name
|
||||
38, // [38:38] is the sub-list for extension extendee
|
||||
0, // [0:38] is the sub-list for field type_name
|
||||
30, // 34: pb.NtfColorTrend.colorRate:type_name -> pb.NtfColorTrend.ColorRate
|
||||
20, // 35: pb.NtfColorSettle.UserBetAreaMul.areaMul:type_name -> pb.ColorBetAreaMul
|
||||
1, // 36: pb.NtfColorTrend.ColorRate.color:type_name -> pb.ColorType
|
||||
37, // [37:37] is the sub-list for method output_type
|
||||
37, // [37:37] is the sub-list for method input_type
|
||||
37, // [37:37] is the sub-list for extension type_name
|
||||
37, // [37:37] is the sub-list for extension extendee
|
||||
0, // [0:37] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_colorgame_proto_init() }
|
||||
@ -2173,7 +2125,7 @@ func file_colorgame_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_colorgame_proto_rawDesc), len(file_colorgame_proto_rawDesc)),
|
||||
NumEnums: 5,
|
||||
NumMessages: 27,
|
||||
NumMessages: 26,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
322
common/proto/pb/common.pb.go
Normal file
322
common/proto/pb/common.pb.go
Normal file
@ -0,0 +1,322 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.6
|
||||
// protoc v6.31.0
|
||||
// source: common.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 踢出玩家
|
||||
type NtfKickOutUser struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"` // 踢出原因
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *NtfKickOutUser) Reset() {
|
||||
*x = NtfKickOutUser{}
|
||||
mi := &file_common_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *NtfKickOutUser) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NtfKickOutUser) ProtoMessage() {}
|
||||
|
||||
func (x *NtfKickOutUser) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_common_proto_msgTypes[0]
|
||||
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 NtfKickOutUser.ProtoReflect.Descriptor instead.
|
||||
func (*NtfKickOutUser) Descriptor() ([]byte, []int) {
|
||||
return file_common_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *NtfKickOutUser) GetCode() ErrCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrCode_OK
|
||||
}
|
||||
|
||||
// 玩家进入房间。首次玩家通过匹配服匹配进入玩法服,不需要发该消息
|
||||
// 玩家上线后,lobby服查找玩家在哪个玩法服并通知给玩家
|
||||
// 玩家收到消息后,发送ReqEnterRoom进入对应玩法服
|
||||
type ReqEnterRoom struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReqEnterRoom) Reset() {
|
||||
*x = ReqEnterRoom{}
|
||||
mi := &file_common_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReqEnterRoom) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReqEnterRoom) ProtoMessage() {}
|
||||
|
||||
func (x *ReqEnterRoom) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_common_proto_msgTypes[1]
|
||||
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 ReqEnterRoom.ProtoReflect.Descriptor instead.
|
||||
func (*ReqEnterRoom) Descriptor() ([]byte, []int) {
|
||||
return file_common_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
// 玩家进房间返回。之后玩法服同步房间信息给玩家
|
||||
type RspEnterRoom struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"`
|
||||
PlayType int32 `protobuf:"varint,2,opt,name=PlayType,proto3" json:"PlayType,omitempty"` // 玩法id
|
||||
RoomType int32 `protobuf:"varint,3,opt,name=RoomType,proto3" json:"RoomType,omitempty"` // 房间类型,低级,中级,高级等
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RspEnterRoom) Reset() {
|
||||
*x = RspEnterRoom{}
|
||||
mi := &file_common_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RspEnterRoom) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RspEnterRoom) ProtoMessage() {}
|
||||
|
||||
func (x *RspEnterRoom) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_common_proto_msgTypes[2]
|
||||
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 RspEnterRoom.ProtoReflect.Descriptor instead.
|
||||
func (*RspEnterRoom) Descriptor() ([]byte, []int) {
|
||||
return file_common_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *RspEnterRoom) GetCode() ErrCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrCode_OK
|
||||
}
|
||||
|
||||
func (x *RspEnterRoom) GetPlayType() int32 {
|
||||
if x != nil {
|
||||
return x.PlayType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RspEnterRoom) GetRoomType() int32 {
|
||||
if x != nil {
|
||||
return x.RoomType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// 玩家离开房间
|
||||
type ReqLeaveRoom struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReqLeaveRoom) Reset() {
|
||||
*x = ReqLeaveRoom{}
|
||||
mi := &file_common_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReqLeaveRoom) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReqLeaveRoom) ProtoMessage() {}
|
||||
|
||||
func (x *ReqLeaveRoom) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_common_proto_msgTypes[3]
|
||||
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 ReqLeaveRoom.ProtoReflect.Descriptor instead.
|
||||
func (*ReqLeaveRoom) Descriptor() ([]byte, []int) {
|
||||
return file_common_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
type RspLeaveRoom struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RspLeaveRoom) Reset() {
|
||||
*x = RspLeaveRoom{}
|
||||
mi := &file_common_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RspLeaveRoom) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RspLeaveRoom) ProtoMessage() {}
|
||||
|
||||
func (x *RspLeaveRoom) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_common_proto_msgTypes[4]
|
||||
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 RspLeaveRoom.ProtoReflect.Descriptor instead.
|
||||
func (*RspLeaveRoom) Descriptor() ([]byte, []int) {
|
||||
return file_common_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *RspLeaveRoom) GetCode() ErrCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrCode_OK
|
||||
}
|
||||
|
||||
var File_common_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_common_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\fcommon.proto\x12\x02pb\x1a\n" +
|
||||
"code.proto\"1\n" +
|
||||
"\x0eNtfKickOutUser\x12\x1f\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\"\x0e\n" +
|
||||
"\fReqEnterRoom\"g\n" +
|
||||
"\fRspEnterRoom\x12\x1f\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12\x1a\n" +
|
||||
"\bPlayType\x18\x02 \x01(\x05R\bPlayType\x12\x1a\n" +
|
||||
"\bRoomType\x18\x03 \x01(\x05R\bRoomType\"\x0e\n" +
|
||||
"\fReqLeaveRoom\"/\n" +
|
||||
"\fRspLeaveRoom\x12\x1f\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04codeB\x11Z\x0fcommon/proto/pbb\x06proto3"
|
||||
|
||||
var (
|
||||
file_common_proto_rawDescOnce sync.Once
|
||||
file_common_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_common_proto_rawDescGZIP() []byte {
|
||||
file_common_proto_rawDescOnce.Do(func() {
|
||||
file_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_common_proto_rawDesc), len(file_common_proto_rawDesc)))
|
||||
})
|
||||
return file_common_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_common_proto_goTypes = []any{
|
||||
(*NtfKickOutUser)(nil), // 0: pb.NtfKickOutUser
|
||||
(*ReqEnterRoom)(nil), // 1: pb.ReqEnterRoom
|
||||
(*RspEnterRoom)(nil), // 2: pb.RspEnterRoom
|
||||
(*ReqLeaveRoom)(nil), // 3: pb.ReqLeaveRoom
|
||||
(*RspLeaveRoom)(nil), // 4: pb.RspLeaveRoom
|
||||
(ErrCode)(0), // 5: pb.ErrCode
|
||||
}
|
||||
var file_common_proto_depIdxs = []int32{
|
||||
5, // 0: pb.NtfKickOutUser.code:type_name -> pb.ErrCode
|
||||
5, // 1: pb.RspEnterRoom.code:type_name -> pb.ErrCode
|
||||
5, // 2: pb.RspLeaveRoom.code:type_name -> pb.ErrCode
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_common_proto_init() }
|
||||
func file_common_proto_init() {
|
||||
if File_common_proto != nil {
|
||||
return
|
||||
}
|
||||
file_code_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_common_proto_rawDesc), len(file_common_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_common_proto_goTypes,
|
||||
DependencyIndexes: file_common_proto_depIdxs,
|
||||
MessageInfos: file_common_proto_msgTypes,
|
||||
}.Build()
|
||||
File_common_proto = out.File
|
||||
file_common_proto_goTypes = nil
|
||||
file_common_proto_depIdxs = nil
|
||||
}
|
@ -28,8 +28,13 @@ const (
|
||||
type MsgId int32
|
||||
|
||||
const (
|
||||
MsgId_MI_Unknown MsgId = 0
|
||||
MsgId_NtfMaintainId MsgId = 1000 // 通知维护
|
||||
MsgId_MI_Unknown MsgId = 0
|
||||
MsgId_NtfMaintainId MsgId = 1000 // 通知维护
|
||||
MsgId_NtfKickOutUserId MsgId = 1001 // 踢出玩家
|
||||
MsgId_ReqEnterRoomId MsgId = 1002 // 进入房间
|
||||
MsgId_RspEnterRoomId MsgId = 1003
|
||||
MsgId_ReqLeaveRoomId MsgId = 1004 // 离开房间
|
||||
MsgId_RspLeaveRoomId MsgId = 1005
|
||||
// 聊天服 2000-2099
|
||||
MsgId_ReqChatId MsgId = 2000 // 玩家聊天消息
|
||||
MsgId_RspChatId MsgId = 2001 // 复用C2SChatMsg
|
||||
@ -56,7 +61,6 @@ const (
|
||||
MsgId_NtfColorSettleId MsgId = 2340 // 结算
|
||||
MsgId_NtfColorBigUserId MsgId = 2345 // 大客数据
|
||||
MsgId_NtfColorTrendId MsgId = 2350 // 路途数据
|
||||
MsgId_NtfColorKickOutUserId MsgId = 2355 // 踢出不下注玩家
|
||||
)
|
||||
|
||||
// Enum value maps for MsgId.
|
||||
@ -64,6 +68,11 @@ var (
|
||||
MsgId_name = map[int32]string{
|
||||
0: "MI_Unknown",
|
||||
1000: "NtfMaintainId",
|
||||
1001: "NtfKickOutUserId",
|
||||
1002: "ReqEnterRoomId",
|
||||
1003: "RspEnterRoomId",
|
||||
1004: "ReqLeaveRoomId",
|
||||
1005: "RspLeaveRoomId",
|
||||
2000: "ReqChatId",
|
||||
2001: "RspChatId",
|
||||
2100: "ReqUserLoginId",
|
||||
@ -86,11 +95,15 @@ var (
|
||||
2340: "NtfColorSettleId",
|
||||
2345: "NtfColorBigUserId",
|
||||
2350: "NtfColorTrendId",
|
||||
2355: "NtfColorKickOutUserId",
|
||||
}
|
||||
MsgId_value = map[string]int32{
|
||||
"MI_Unknown": 0,
|
||||
"NtfMaintainId": 1000,
|
||||
"NtfKickOutUserId": 1001,
|
||||
"ReqEnterRoomId": 1002,
|
||||
"RspEnterRoomId": 1003,
|
||||
"ReqLeaveRoomId": 1004,
|
||||
"RspLeaveRoomId": 1005,
|
||||
"ReqChatId": 2000,
|
||||
"RspChatId": 2001,
|
||||
"ReqUserLoginId": 2100,
|
||||
@ -113,7 +126,6 @@ var (
|
||||
"NtfColorSettleId": 2340,
|
||||
"NtfColorBigUserId": 2345,
|
||||
"NtfColorTrendId": 2350,
|
||||
"NtfColorKickOutUserId": 2355,
|
||||
}
|
||||
)
|
||||
|
||||
@ -148,11 +160,16 @@ var File_msgId_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_msgId_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\vmsgId.proto\x12\x02pb*\xc2\x04\n" +
|
||||
"\vmsgId.proto\x12\x02pb*\x91\x05\n" +
|
||||
"\x05MsgId\x12\x0e\n" +
|
||||
"\n" +
|
||||
"MI_Unknown\x10\x00\x12\x12\n" +
|
||||
"\rNtfMaintainId\x10\xe8\a\x12\x0e\n" +
|
||||
"\rNtfMaintainId\x10\xe8\a\x12\x15\n" +
|
||||
"\x10NtfKickOutUserId\x10\xe9\a\x12\x13\n" +
|
||||
"\x0eReqEnterRoomId\x10\xea\a\x12\x13\n" +
|
||||
"\x0eRspEnterRoomId\x10\xeb\a\x12\x13\n" +
|
||||
"\x0eReqLeaveRoomId\x10\xec\a\x12\x13\n" +
|
||||
"\x0eRspLeaveRoomId\x10\xed\a\x12\x0e\n" +
|
||||
"\tReqChatId\x10\xd0\x0f\x12\x0e\n" +
|
||||
"\tRspChatId\x10\xd1\x0f\x12\x13\n" +
|
||||
"\x0eReqUserLoginId\x10\xb4\x10\x12\x13\n" +
|
||||
@ -174,8 +191,7 @@ const file_msgId_proto_rawDesc = "" +
|
||||
"\x17NtfColorOpenThreeDiceId\x10\x9f\x12\x12\x15\n" +
|
||||
"\x10NtfColorSettleId\x10\xa4\x12\x12\x16\n" +
|
||||
"\x11NtfColorBigUserId\x10\xa9\x12\x12\x14\n" +
|
||||
"\x0fNtfColorTrendId\x10\xae\x12\x12\x1a\n" +
|
||||
"\x15NtfColorKickOutUserId\x10\xb3\x12B\x11Z\x0fcommon/proto/pbb\x06proto3"
|
||||
"\x0fNtfColorTrendId\x10\xae\x12B\x11Z\x0fcommon/proto/pbb\x06proto3"
|
||||
|
||||
var (
|
||||
file_msgId_proto_rawDescOnce sync.Once
|
||||
|
@ -2,6 +2,11 @@ package utils
|
||||
|
||||
import "math"
|
||||
|
||||
// 模板结构,语法拒绝T{},但能接受TValue[T].V
|
||||
type TValue[T any] struct {
|
||||
V T
|
||||
}
|
||||
|
||||
func Tie[T any](ret bool, v1, v2 T) T {
|
||||
if ret {
|
||||
return v1
|
||||
|
@ -1,441 +0,0 @@
|
||||
package room
|
||||
|
||||
//import (
|
||||
// "encoding/json"
|
||||
// "game/common/proto/pb"
|
||||
// "github.com/fox/fox/log"
|
||||
//)
|
||||
|
||||
//
|
||||
//
|
||||
//type LiveMgr struct {
|
||||
// // LiveWg *sync.WaitGroup
|
||||
// // Count int // 当前数量
|
||||
// // Mu *sync.Mutex
|
||||
// MaintenanceStatus int32 // 维护状态 0 正常 1 维护
|
||||
// // ProcessStatus int // 进程状态
|
||||
// Restting bool // 重置状态
|
||||
// MainteMsg string
|
||||
// DiscardMsg string
|
||||
// DiscardStatus int
|
||||
// DiscardRestting bool // 重置状态
|
||||
// RankList *pb.ColorPinoyLiveRankList
|
||||
// HasMainte bool
|
||||
//}
|
||||
//
|
||||
//func NewLiveMgr() *LiveMgr {
|
||||
// return &LiveMgr{
|
||||
// // LiveWg: new(sync.WaitGroup),
|
||||
// // Mu: new(sync.Mutex),
|
||||
// RankList: new(pb.ColorPinoyLiveRankList),
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (lm *LiveMgr) Reset() {
|
||||
// lm.Restting = false
|
||||
// lm.DiscardRestting = false
|
||||
// lm.DiscardStatus = 0
|
||||
//}
|
||||
//
|
||||
//
|
||||
//func (lm *LiveMgr) NeedMaintenance() bool {
|
||||
// return !lm.HasMainte && (lm.MaintenanceStatus == 1 || lm.DiscardStatus == 1)
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveDelayUpdate() error {
|
||||
// event := &events.ServCmdKafka{
|
||||
// ServCmd: common.ServCmd_sc_live_delay_update,
|
||||
// }
|
||||
// data := &common.ServLiveDelayUpdate{
|
||||
// GameId: gconfig.GConfig.GRoomConfig.GameId,
|
||||
// MainteStatus: rm.LiveMgr.MaintenanceStatus,
|
||||
// MainteMsg: rm.LiveMgr.MainteMsg,
|
||||
// }
|
||||
// event.Data, _ = proto.Marshal(data)
|
||||
// err := gconfig.Produce(context.Background(), define.TopicSysServerCmd, event)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log("fail to Produce Event(%+v), err: %v", event, err))
|
||||
// return err
|
||||
// }
|
||||
// return nil
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) NotifyLiveDelayUpdate() {
|
||||
// if !gconfig.DelayUpdateServer {
|
||||
// return
|
||||
// }
|
||||
// if rm.LiveDelayUpdate() != nil {
|
||||
// return
|
||||
// }
|
||||
// gconfig.DelayUpdateServer = false
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) ServerMaintenanceKickPlayer() {
|
||||
// rm.Traverse(func(u *model.User) bool {
|
||||
// kMsg := new(pb.ColorPinoyLiveKickOutUserMsg)
|
||||
// kMsg.Reason = int32(pb.ColorPinoyLiveLeaveReason_ColorPinoyLiveLeaveReason_Server_Update)
|
||||
// u.SendMsg(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeKickOutUser), kMsg)
|
||||
// rm.KickOutUser(u)
|
||||
// return true
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) SyncServerMaintenance(st int32, ss string) {
|
||||
// _ = st
|
||||
// _ = ss
|
||||
// rm.LoadDealerNames()
|
||||
// // 可能即将变为 normal
|
||||
// if gconfig.GConfig.GServConfig.Status != define.GameStatusNoraml {
|
||||
// rm.LiveMgr.MaintenanceStatus = 0
|
||||
// rm.LiveMgr.MainteMsg = ""
|
||||
// return
|
||||
// }
|
||||
// ssv := redisf.RSC.LiveMainteGet(gconfig.GConfig.GDataConfig.VersionMode, gconfig.GConfig.GRoomConfig.GameId)
|
||||
// resp := new(pb.ColorPinoyLiveCommResp)
|
||||
// _ = json.Unmarshal([]byte(ssv), resp)
|
||||
// rm.LiveMgr.MaintenanceStatus = resp.MaintainStatus
|
||||
// rm.LiveMgr.MainteMsg = resp.MaintainMsg
|
||||
//
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) OnLiveGameMessage(subCmd int32, buffer []byte) ([]byte, error) {
|
||||
// // log.Debug("收到后台消息:", subCmd)
|
||||
// var result proto.Message
|
||||
// _, err := rm.Table.RunAndWait(func() any {
|
||||
// switch subCmd {
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGGameGetStatus):
|
||||
// result = rm.LiveGetGameStatus(buffer)
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGReady):
|
||||
// result = rm.LiveGameReady(buffer) // 点击finish
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGBetting):
|
||||
// result = rm.LiveGameBetting(buffer) // 点击start
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGMStartDice):
|
||||
// result = rm.LiveGameStartDice(buffer)
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGMResultImg):
|
||||
// result = rm.LiveGameResultImg(buffer)
|
||||
// // case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGLucky):
|
||||
// // result = rm.LiveGameLucky(buffer)
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGResult):
|
||||
// result = rm.LiveGameResult(buffer)
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGMMainteSet):
|
||||
// result = rm.LiveGameMainte(buffer)
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGMDiscard):
|
||||
// result = rm.LiveGameDiscard(buffer)
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGMRankList):
|
||||
// result = rm.LiveGameRankList(buffer)
|
||||
// case int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGSetDealer):
|
||||
// result = rm.LiveGameSetDealerName(buffer)
|
||||
// default:
|
||||
// log.Error(rm.Log("no protocol"))
|
||||
// return nil
|
||||
// }
|
||||
// return result
|
||||
// })
|
||||
// if err == nil && result != nil {
|
||||
// b, _ := proto.Marshal(result)
|
||||
// canLog := true
|
||||
// if subCmd == int32(pb.ColorPinoyLiveProcessCmd_ColorPinoyLiveMSGGameGetStatus) {
|
||||
// if rd := rand.RandInt(0, 100); rd < 90 {
|
||||
// canLog = false
|
||||
// }
|
||||
// }
|
||||
// if canLog {
|
||||
// j, _ := json.Marshal(result)
|
||||
// log.Debug(rm.Log("返回后台消息 subCmd:%d, msg:%s", subCmd, string(j)))
|
||||
// }
|
||||
// return b, nil
|
||||
// }
|
||||
// return nil, err
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) getStatus() (int32, int64) {
|
||||
// switch rm.Status {
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveStartUnReady:
|
||||
// return int32(rm.Status), rm.StatusTime + int64(rm.RoomCfg.TimeConf.Readymove)
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveStartReady:
|
||||
// return int32(rm.Status), rm.StatusTime + int64(rm.RoomCfg.TimeConf.Startmove)
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveStartMovie:
|
||||
// return int32(pb.ColorPinoyLiveGameStatus_ColorPinoyLiveBetStatus), rm.StatusTime + int64(rm.RoomCfg.TimeConf.Startbet)
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveBetStatus:
|
||||
// return int32(rm.Status), rm.StatusTime + int64(rm.RoomCfg.TimeConf.Startbet)
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveEndBetMovie:
|
||||
// return int32(rm.Status), rm.StatusTime + int64(rm.RoomCfg.TimeConf.Endmove)
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveOpenThreeDice:
|
||||
// return int32(rm.Status), rm.StatusTime + int64(rm.RoomCfg.TimeConf.OpenThreeDice)
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveSettleStatus:
|
||||
// return int32(rm.Status), rm.StatusTime + int64(rm.RoomCfg.TimeConf.Endpay)
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveRankStatus:
|
||||
// return int32(rm.Status), rm.StatusTime + int64(rm.RoomCfg.TimeConf.Rank)
|
||||
// default:
|
||||
// return int32(rm.Status), rm.StatusTime
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveStatus() *pb.ColorPinoyLiveCommResp {
|
||||
// resp := &pb.ColorPinoyLiveCommResp{
|
||||
// GameId: gconfig.GConfig.GRoomConfig.GameId,
|
||||
// MaintainStatus: rm.LiveMgr.MaintenanceStatus,
|
||||
// MaintainMsg: rm.LiveMgr.MainteMsg,
|
||||
// Times: rm.RoomCfg.TimeConf.Get(),
|
||||
// GameNo: rm.Table.GetGameRoundId(),
|
||||
// DealerName: rm.dealerName,
|
||||
// Jackpot: rm.jackpotMgr.GetJackpotCopy(),
|
||||
// }
|
||||
// resp.GameStatus, resp.Countdown = rm.getStatus()
|
||||
// resp.BetAreaMul = rm.betEndBetAreasOdds
|
||||
// for _, dice := range rm.StartDices {
|
||||
// resp.StartDice = append(resp.StartDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// resp.ResultImg = rm.ResultImgs
|
||||
// switch rm.Status {
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveOpenThreeDice:
|
||||
// resp.LuckyStar = pb.ColorPinoyLiveDiceColorType(model.GetColor(rm.LuckyDice))
|
||||
// for _, dice := range rm.NormalDices {
|
||||
// resp.DrawResult = append(resp.DrawResult, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// case pb.ColorPinoyLiveGameStatus_ColorPinoyLiveSettleStatus, pb.ColorPinoyLiveGameStatus_ColorPinoyLiveRankStatus:
|
||||
// resp.LuckyStar = pb.ColorPinoyLiveDiceColorType(model.GetColor(rm.LuckyDice))
|
||||
// for _, dice := range rm.NormalDices {
|
||||
// resp.DrawResult = append(resp.DrawResult, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// resp.RankList = rm.LiveMgr.RankList
|
||||
// default:
|
||||
// }
|
||||
// // 结束下注后,后台可看到更新爆奖后的投注面板
|
||||
// if rm.Status > pb.ColorPinoyLiveGameStatus_ColorPinoyLiveBetStatus {
|
||||
// resp.BetAreaMul = rm.betEndBetAreasOdds
|
||||
// }
|
||||
// return resp
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGetGameStatus(buffer []byte) proto.Message {
|
||||
// _ = buffer
|
||||
// return rm.LiveStatus()
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameReady(buffer []byte) proto.Message {
|
||||
// _ = buffer
|
||||
// log.Debug(rm.Log("LiveGameReady"))
|
||||
// // rm.MutexStatus.Lock()
|
||||
// // defer rm.MutexStatus.Unlock()
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// if rm.Status != pb.ColorPinoyLiveGameStatus_ColorPinoyLiveRankStatus {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorGameSatus)
|
||||
// return resp
|
||||
// }
|
||||
// rm.Ready()
|
||||
// resp.GameStatus, resp.Countdown = rm.getStatus()
|
||||
// return resp
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameBetting(buffer []byte) proto.Message {
|
||||
// _ = buffer
|
||||
// log.Debug(rm.Log("LiveGameBetting"))
|
||||
// // rm.MutexStatus.Lock()
|
||||
// // defer rm.MutexStatus.Unlock()
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// if rm.Status != pb.ColorPinoyLiveGameStatus_ColorPinoyLiveStartReady {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorGameSatus)
|
||||
// return resp
|
||||
// }
|
||||
//
|
||||
// rm.StartBet()
|
||||
// return resp
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameStartDice(buffer []byte) proto.Message {
|
||||
// log.Debug(rm.Log("LiveGameStartDice"))
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// if rm.Status != pb.ColorPinoyLiveGameStatus_ColorPinoyLiveEndBetMovie {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorGameSatus)
|
||||
// return resp
|
||||
// }
|
||||
// req := new(pb.ColorPinoyLiveStartDice)
|
||||
// _ = proto.Unmarshal(buffer, req)
|
||||
// if len(req.GetStartDice()) != 3 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorDice)
|
||||
// return resp
|
||||
// }
|
||||
// for i := 0; i < len(req.GetStartDice()); i++ {
|
||||
// rm.StartDices[i] = byte(req.GetStartDice()[i])
|
||||
// }
|
||||
// log.Debug(rm.Log("req:", req.GetStartDice(), ",StartDice:", rm.StartDices))
|
||||
// resp.StartDice = make([]pb.ColorPinoyLiveDiceColorType, 0)
|
||||
// for _, dice := range rm.StartDices {
|
||||
// resp.StartDice = append(resp.StartDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// resp.ResultImg = rm.ResultImgs
|
||||
// return resp
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameResultImg(buffer []byte) proto.Message {
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// req := new(pb.ColorPinoyLiveResultImg)
|
||||
// _ = proto.Unmarshal(buffer, req)
|
||||
// rm.ResultImgs = append(rm.ResultImgs, req.GetResultImg()...)
|
||||
// log.Debug(rm.Log("req:", req.GetResultImg(), ",ResultImg:", rm.ResultImgs))
|
||||
// resp.StartDice = make([]pb.ColorPinoyLiveDiceColorType, 0)
|
||||
// for _, dice := range rm.StartDices {
|
||||
// resp.StartDice = append(resp.StartDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// resp.ResultImg = rm.ResultImgs
|
||||
// return resp
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameResult(buffer []byte) proto.Message {
|
||||
// // rm.MutexStatus.Lock()
|
||||
// // defer rm.MutexStatus.Unlock()
|
||||
// log.Debug(rm.Log("LiveGameResult"))
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// log.Debug(rm.Log("LiveGameResult status:%v ", rm.Status))
|
||||
// if rm.Status != pb.ColorPinoyLiveGameStatus_ColorPinoyLiveEndBetMovie {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorGameSatus)
|
||||
// return resp
|
||||
// }
|
||||
// req := new(pb.ColorPinoyLiveResult)
|
||||
// _ = proto.Unmarshal(buffer, req)
|
||||
// if len(req.GetColor()) != 3 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorDice)
|
||||
// return resp
|
||||
// } else {
|
||||
// for i := 0; i < len(req.GetColor()); i++ {
|
||||
// if !model.IsLogic(int32(req.GetColor()[i])) {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorDice)
|
||||
// return resp
|
||||
// }
|
||||
// rm.NormalDices[i] = byte(req.GetColor()[i])
|
||||
// }
|
||||
// }
|
||||
// log.Debug(rm.Log("LiveGameResult req:%v NormalDices:%v", req.GetColor(), rm.NormalDices))
|
||||
//
|
||||
// rm.Table.Run(rm.openThreeDice)
|
||||
// return resp
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameMainte(buffer []byte) proto.Message {
|
||||
// req := new(pb.ColorPinoyLiveMaintain)
|
||||
// _ = proto.Unmarshal(buffer, req)
|
||||
// b, _ := json.Marshal(req)
|
||||
// log.Debug(rm.Log("LiveGameMainte:%v", string(b)))
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.Restting {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// resp.Msg = "Restting"
|
||||
// return resp
|
||||
// }
|
||||
// if req.TargetStatus == rm.LiveMgr.MaintenanceStatus {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// if rm.GetGameStatus() == pb.ColorPinoyLiveGameStatus_ColorPinoyLiveSettleStatus {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorGameSatus)
|
||||
// resp.Msg = "SettleStatus"
|
||||
// return resp
|
||||
// }
|
||||
// defer func() {
|
||||
// _ = pushGate.NotifyConfigUpdated(msg.ConfigUpdateType_ConfigUpdateTypeLiveConfig)
|
||||
// rm.SetLiveGameStatus()
|
||||
// }()
|
||||
// if req.TargetStatus == 0 {
|
||||
// rm.LiveMgr.MaintenanceStatus = 0
|
||||
// rm.LiveMgr.MainteMsg = ""
|
||||
// rm.LiveMgr.HasMainte = false
|
||||
// } else {
|
||||
// rm.LiveMgr.MaintenanceStatus = req.TargetStatus
|
||||
// rm.LiveMgr.MainteMsg = req.GetMsg()
|
||||
// rm.LiveMainteCnt()
|
||||
// }
|
||||
// resp.MaintainStatus = rm.LiveMgr.MaintenanceStatus
|
||||
// resp.MaintainMsg = rm.LiveMgr.MainteMsg
|
||||
// resp.GameStatus, resp.Countdown = rm.getStatus()
|
||||
// br, _ := json.Marshal(resp)
|
||||
// redisf.RSC.LiveMainteSet(gconfig.GConfig.GDataConfig.VersionMode, gconfig.GConfig.GRoomConfig.GameId, string(br))
|
||||
// redisf.RSC.LiveMainteLobbySet(gconfig.GConfig.GDataConfig.VersionMode, gconfig.GConfig.GRoomConfig.GameId, rm.LiveMgr.MaintenanceStatus, rm.LiveMgr.MainteMsg)
|
||||
// return resp
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveMainteCnt() {
|
||||
// rm.LiveMainte()
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveMainte() {
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// rm.LiveMgr.HasMainte = true
|
||||
// rm.LiveMgr.Restting = true
|
||||
// }
|
||||
// if rm.LiveMgr.DiscardStatus == 1 {
|
||||
// rm.LiveMgr.DiscardRestting = true
|
||||
// }
|
||||
// rm.GameDiscard()
|
||||
// // rm.LiveMgr.SetProcessStatus(LiveProcessInit)
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// rm.LiveMgr.Restting = false
|
||||
// }
|
||||
// if rm.LiveMgr.DiscardStatus == 1 {
|
||||
// rm.LiveMgr.DiscardRestting = false
|
||||
// rm.LiveMgr.DiscardStatus = 0
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameDiscard(_ []byte) proto.Message {
|
||||
// log.Debug(rm.Log("LiveGameDiscard"))
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// log.Error(rm.Log("rm.LiveMgr.MaintenanceStatus"))
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// if rm.LiveMgr.DiscardRestting {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// resp.Msg = "DiscardRestting"
|
||||
// return resp
|
||||
// }
|
||||
// // if rm.GetGameStatus() == pb.ColorPinoyLiveGameStatus_ColorPinoyLiveSettleStatus {
|
||||
// // resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorGameSatus)
|
||||
// // resp.Msg = "SettleStatus"
|
||||
// // return resp
|
||||
// // }
|
||||
// rm.LiveMgr.DiscardStatus = 1
|
||||
// rm.LiveMgr.DiscardMsg = ""
|
||||
// rm.LiveMainteCnt()
|
||||
// resp.GameStatus, resp.Countdown = rm.getStatus()
|
||||
// return resp
|
||||
//}
|
||||
//func (rm *ColorRoom) LiveGameRankList(buffer []byte) proto.Message {
|
||||
// _ = buffer
|
||||
// return rm.LiveMgr.RankList
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) LiveGameSetDealerName(buffer []byte) proto.Message {
|
||||
// resp := rm.LiveStatus()
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// resp.Code = int32(pb.ColorPinoyLiveProcessError_ColorPinoyLiveProcessErrorMainteStatus)
|
||||
// return resp
|
||||
// }
|
||||
// req := new(pb.ColorPinoyLiveSetDealer)
|
||||
// _ = proto.Unmarshal(buffer, req)
|
||||
// rm.UpdateDealerName(req.DealerName)
|
||||
// log.Debug(rm.Log("set dealer:", req.DealerName))
|
||||
// resp.DealerName = rm.dealerName
|
||||
// return resp
|
||||
//}
|
@ -1,17 +1,79 @@
|
||||
package room
|
||||
|
||||
import (
|
||||
"game/common/baseroom"
|
||||
"game/common/proto/pb"
|
||||
"github.com/fox/fox/ipb"
|
||||
)
|
||||
|
||||
func (rm *ColorRoom) checkEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) {
|
||||
func (rm *ColorRoom) checkEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqEnterRoom) pb.ErrCode {
|
||||
_ = user
|
||||
_ = iMsg
|
||||
_ = req
|
||||
return pb.ErrCode_OK
|
||||
}
|
||||
|
||||
func (rm *ColorRoom) onMatchRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) {
|
||||
_ = req
|
||||
code := rm.checkEnterRoom(user, iMsg, &pb.ReqEnterRoom{})
|
||||
if code != pb.ErrCode_OK {
|
||||
rm.SendMsg(user, pb.MsgId_RspMatchRoomId, &pb.RspMatchRoom{Code: code})
|
||||
return
|
||||
}
|
||||
rm.enterRoom(user)
|
||||
return
|
||||
}
|
||||
|
||||
func (rm *ColorRoom) onEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) {
|
||||
func (rm *ColorRoom) enterRoom(user *ColorPlayer) {
|
||||
// 第一次进房间分配座位
|
||||
if u, _ := rm.FindPlayer(user.ID); u == nil {
|
||||
var seat *baseroom.BaseSeat
|
||||
if exist, no := rm.HasEmptySeat(); exist {
|
||||
seat = rm.Seats[no]
|
||||
} else {
|
||||
rm.Seats = append(rm.Seats, baseroom.NewBaseSeat(len(rm.Seats)))
|
||||
seat = rm.Seats[len(rm.Seats)-1]
|
||||
}
|
||||
seat.SetPlayer(user)
|
||||
}
|
||||
rm.notifyColorRoomInfo(user)
|
||||
}
|
||||
|
||||
func (rm *ColorRoom) onEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqEnterRoom) {
|
||||
code := rm.checkEnterRoom(user, iMsg, req)
|
||||
rm.SendMsg(user, pb.MsgId_RspEnterRoomId, &pb.RspEnterRoom{Code: code})
|
||||
if code != pb.ErrCode_OK {
|
||||
return
|
||||
}
|
||||
rm.enterRoom(user)
|
||||
return
|
||||
}
|
||||
|
||||
func (rm *ColorRoom) checkLeaveRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqLeaveRoom) pb.ErrCode {
|
||||
_ = iMsg
|
||||
_ = req
|
||||
if rm.status >= pb.ColorGameStatus_CGS_Settle || rm.status < pb.ColorGameStatus_CGS_Betting {
|
||||
return pb.ErrCode_OK
|
||||
}
|
||||
if user.totalBet == 0 {
|
||||
return pb.ErrCode_NotLeaveRoom
|
||||
}
|
||||
return pb.ErrCode_OK
|
||||
}
|
||||
|
||||
func (rm *ColorRoom) leaveRoom(user *ColorPlayer) {
|
||||
_, st := rm.FindPlayer(user.Id())
|
||||
st.SetPlayer(nil)
|
||||
rm.userMgr.Del(user.ID)
|
||||
}
|
||||
|
||||
func (rm *ColorRoom) onLeaveRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqLeaveRoom) {
|
||||
code := rm.checkLeaveRoom(user, iMsg, req)
|
||||
rm.SendMsg(user, pb.MsgId_RspEnterRoomId, &pb.RspEnterRoom{Code: code})
|
||||
if code == pb.ErrCode_OK {
|
||||
rm.leaveRoom(user)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -34,9 +96,9 @@ func (rm *ColorRoom) checkBet(user *ColorPlayer, _ *ipb.InternalMsg, req *pb.Req
|
||||
|
||||
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})
|
||||
return
|
||||
}
|
||||
curBetAreaInfo := rm.betAreaInfo[req.Area]
|
||||
_, _ = rm.AddGold(user, -req.Bet)
|
||||
@ -52,213 +114,3 @@ func (rm *ColorRoom) onBet(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.Req
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
//func (rm *ColorRoom) ApplyLeave(buffer []byte, user inter.UserInetr) {
|
||||
// _ = buffer
|
||||
// resp := new(pb.ColorPinoyLiveLeaveResp)
|
||||
// u := rm.GetPlayer(user.GetId())
|
||||
// if u == nil {
|
||||
// rm.Table.KickOut(user)
|
||||
// return
|
||||
// }
|
||||
// // 有下注时不让玩家离开
|
||||
// if u.totalBet != 0 {
|
||||
// resp.Code = 1
|
||||
// _ = user.SendMsg(int32(pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyLeave), resp)
|
||||
// return
|
||||
// }
|
||||
// rm.KickOutUser(u)
|
||||
// _ = user.SendMsg(int32(pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyLeave), resp)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) checkNoBet() bool {
|
||||
// return rm.GetGameStatus() != pb.ColorPinoyLiveGameStatus_ColorPinoyLiveBetStatus ||
|
||||
// rm.LiveMgr.MaintenanceStatus == 1 ||
|
||||
// rm.LiveMgr.DiscardRestting
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) Bet(buffer []byte, user inter.UserInetr) {
|
||||
// u := rm.getUser(user)
|
||||
// u.MutexBet.Lock()
|
||||
// defer u.MutexBet.Unlock()
|
||||
// if rm.checkNoBet() {
|
||||
// log.Error(rm.Log("game bet status err:%v", rm.GetGameStatus()))
|
||||
// model.SendBetFailMessageInetr(model.StatusError, user)
|
||||
// return
|
||||
// }
|
||||
// // 用户下注
|
||||
// BetPb := &pb.ColorPinoyLiveBetReqs{}
|
||||
// err := proto.Unmarshal(buffer, BetPb)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log("proto.Unmarshal err:%v", err))
|
||||
// model.SendBetFailMessageInetr(model.DataErr, user)
|
||||
// return
|
||||
// }
|
||||
// log.Debug(rm.Log("Bet pb = ", BetPb))
|
||||
// var bets []*pb.ColorPinoyLiveBetReq
|
||||
//
|
||||
// for _, bet := range BetPb.Info {
|
||||
// req := &pb.ColorPinoyLiveBetReq{
|
||||
// BetType: bet.BetType,
|
||||
// BetLevel: bet.BetLevel,
|
||||
// BetIndex: bet.BetIndex,
|
||||
// BetAmount: bet.BetAmount,
|
||||
// }
|
||||
// bets = append(bets, req)
|
||||
// }
|
||||
//
|
||||
// // log.Debug("Bet bets =", bets)
|
||||
// rm.CheckAndBet(u, bets)
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) UserSitDown(buffer []byte, user inter.UserInetr) {
|
||||
// us := &pb.ColorPinoyLiveUserSitDown{}
|
||||
// _ = proto.Unmarshal(buffer, us)
|
||||
// // u, ok := rm.AllUserList[user.GetId()]
|
||||
// u := rm.GetPlayer(user.GetId())
|
||||
// if u != nil {
|
||||
// if rm.SceneInfo.SitScene(u, int(us.ChairNo)) {
|
||||
// u.SceneChairId = int(us.ChairNo)
|
||||
// rm.Traverse(func(v *model.User) bool {
|
||||
// // rm.SendSceneMsg(v)
|
||||
// return true
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) SendUserListInfo(user inter.UserInetr) {
|
||||
// msg := new(pb.ColorPinoyLiveUserList)
|
||||
// for _, u := range rm.OnlineUserList {
|
||||
// userinfo := new(pb.ColorPinoyLiveUserInfo)
|
||||
// userinfo.NikeName = u.UserInetr.GetNike()
|
||||
// userinfo.UserGlod = u.Balance
|
||||
// userinfo.Head = u.UserInetr.GetHead()
|
||||
// userinfo.UserID = u.UserID
|
||||
// msg.UserList = append(msg.UserList, userinfo)
|
||||
// }
|
||||
// // log.Debug("SendUserListInfo", msg)
|
||||
// _ = user.SendMsg(int32(pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyGetUserListInfo), msg)
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) SendTrend(u inter.UserInetr) {
|
||||
// // log.Debug("发送走势图")
|
||||
// msg := new(pb.ColorPinoyLiveTrend)
|
||||
// msg.ListTrendGroup = rm.GameTrend.ListTrendGroup
|
||||
// msg.LuckStarRate = rm.GetGameTrend()
|
||||
// _ = u.SendMsg(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameTrendInfo), msg)
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) OnUserStanUp(user *model.User) {
|
||||
// rm.SceneInfo.UserStandUp(user.UserInetr)
|
||||
// user.Mn.Lock()
|
||||
// user.SceneChairId = 0
|
||||
// user.Mn.Unlock()
|
||||
// if rm.GetGameStatus() < pb.ColorPinoyLiveGameStatus_ColorPinoyLiveOpenThreeDice {
|
||||
// rm.SelectUserListBalanceTopSitDownChair()
|
||||
// } else {
|
||||
// // rm.Traverse(func(v *model.User) bool {
|
||||
// // rm.SendSceneMsg(v)
|
||||
// // return true
|
||||
// // })
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) AgainBet(user inter.UserInetr) {
|
||||
// u := rm.getUser(user)
|
||||
// u.MutexBet.Lock()
|
||||
// defer u.MutexBet.Unlock()
|
||||
// if rm.checkNoBet() {
|
||||
// log.Error(rm.Log("game bet status err ", rm.GetGameStatus()))
|
||||
// model.SendBetFailMessageInetr(model.StatusError, user)
|
||||
// return
|
||||
// }
|
||||
// // u := rm.getUser(user)
|
||||
// var bets []*pb.ColorPinoyLiveBetReq
|
||||
// if u.TempLastTimeBet != nil {
|
||||
// for _, bet := range u.TempLastTimeBet {
|
||||
// bets = append(bets, bet...)
|
||||
// }
|
||||
// }
|
||||
// rm.CheckAndBet(u, bets)
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) BetDouble(user inter.UserInetr) {
|
||||
// u := rm.getUser(user)
|
||||
// u.MutexBet.Lock()
|
||||
// defer u.MutexBet.Unlock()
|
||||
// if rm.checkNoBet() {
|
||||
// log.Error(rm.Log("game bet status err ", rm.GetGameStatus()))
|
||||
// model.SendBetFailMessageInetr(model.StatusError, user)
|
||||
// return
|
||||
// }
|
||||
// // u := rm.getUser(user)
|
||||
// var bets []*pb.ColorPinoyLiveBetReq
|
||||
// if u.LastTimeBet != nil {
|
||||
// for _, bet := range u.LastTimeBet {
|
||||
// bets = append(bets, bet...)
|
||||
// }
|
||||
// // log.Debug("BetDouble 上次下注:", u.LastTimeBet, "bets:", bets)
|
||||
// }
|
||||
// if len(bets) > 1000 {
|
||||
// log.Error(rm.Log("game bet status err ", rm.GetGameStatus()))
|
||||
// model.SendBetFailMessageInetr(12, user)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// rm.CheckAndBet(u, bets)
|
||||
//}
|
||||
//
|
||||
//func (rm *ColorRoom) OnUndoBet(buffer []byte, user inter.UserInetr) {
|
||||
// u := rm.getUser(user)
|
||||
// u.MutexBet.Lock()
|
||||
// defer u.MutexBet.Unlock()
|
||||
// if rm.checkNoBet() {
|
||||
// log.Error(rm.Log("game bet status err:%v", rm.GetGameStatus()))
|
||||
// model.SendBetFailMessageInetr(model.StatusError, user)
|
||||
// return
|
||||
// }
|
||||
// reqInfo := &pb.ColorPinoyLiveC2SUndoBet{}
|
||||
// err := proto.Unmarshal(buffer, reqInfo)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log("proto.Unmarshal err:%v", err))
|
||||
// model.SendBetFailMessageInetr(model.DataErr, user)
|
||||
// return
|
||||
// }
|
||||
// rm.UndoBet(u, reqInfo.UndoType)
|
||||
//}
|
||||
//
|
||||
//// ApplyUseProps todo
|
||||
//func (rm *ColorRoom) ApplyUseProps(buffer []byte, userInter inter.UserInetr) {
|
||||
// applyInfo := new(pb.ColorPinoyLiveApplyPropsReq)
|
||||
// err := proto.Unmarshal(buffer, applyInfo)
|
||||
// user := rm.getUser(userInter)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log("proto.Unmarshal err:%v", err))
|
||||
// model.SendBetFailMessage(model.DataErr, user)
|
||||
// return
|
||||
// }
|
||||
// AcceptUser := rm.GetPlayer(applyInfo.AcceptUserId)
|
||||
// if AcceptUser == nil {
|
||||
// log.Error(rm.Log("AcceptUser is null"))
|
||||
// model.SendBetFailMessage(model.UserNull, user)
|
||||
// return
|
||||
// }
|
||||
// _, err = user.GetPropsReal(rm.RoomCfg.Prop, rm.Table, rm.RoomCfg)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log("GetPropsReal err", err))
|
||||
// model.SendBetFailMessage(model.ScoreLess, user)
|
||||
// return
|
||||
// }
|
||||
// leftCoins := user.Balance
|
||||
// propsResp := &pb.ColorPinoyLivePlayerPropsResp{
|
||||
// ApplyUserId: user.UserID,
|
||||
// AcceptUserId: AcceptUser.UserID,
|
||||
// PropsId: applyInfo.PropsId,
|
||||
// Chips: leftCoins,
|
||||
// }
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticePlayerUseProps), propsResp)
|
||||
//}
|
||||
|
@ -12,9 +12,10 @@ type ColorPlayer struct {
|
||||
gateTopicName string
|
||||
roomId int
|
||||
|
||||
totalBet int64 // 总下注金额
|
||||
totalBets []int64 // 各个区域的下注
|
||||
settleMsg *pb.NtfColorSettle // 本局结算消息
|
||||
notBetCount int // 不投注局数
|
||||
totalBet int64 // 总下注金额
|
||||
totalBets []int64 // 各个区域的下注
|
||||
settleMsg *pb.NtfColorSettle // 本局结算消息
|
||||
}
|
||||
|
||||
func NewColorPlayer(gateTopicName string, roomId int, u *user.User, res *user.UserResources) *ColorPlayer {
|
||||
@ -42,6 +43,11 @@ func (p *ColorPlayer) RoomId() int {
|
||||
return p.roomId
|
||||
}
|
||||
|
||||
// 没有投注的局数
|
||||
func (p *ColorPlayer) addNotBetCount() {
|
||||
p.notBetCount++
|
||||
}
|
||||
|
||||
// 游戏开始前,清理玩家上局数据
|
||||
func (p *ColorPlayer) resetData() {
|
||||
p.settleMsg = &pb.NtfColorSettle{}
|
||||
|
@ -12,13 +12,15 @@ import (
|
||||
)
|
||||
|
||||
type ColorRoom struct {
|
||||
*baseroom.BaseRoom[ColorSeat]
|
||||
*baseroom.BaseRoom[*baseroom.BaseSeat]
|
||||
userMgr *baseroom.PlayerMgr
|
||||
|
||||
roomCfg *game.ColorRoomConfig
|
||||
timingCfg *game.ColorGameTiming
|
||||
status pb.ColorGameStatus
|
||||
statusTime int64 // 毫秒时间戳
|
||||
|
||||
prizeAreaRange []*pb.ColorPrizeAreaRange // 五个档位(single有三个加上double,three两个)的赔率范围
|
||||
endBetAreaMul []*pb.ColorBetAreaMul // 下注结束后,每个区域更新是否爆奖以及实际赔率
|
||||
ntfOpenThreeDice *pb.NtfColorOpenThreeDice // 开骰子的消息
|
||||
winBetAreaMul []*pb.ColorBetAreaMul // 中奖区域及实际赔率
|
||||
@ -30,10 +32,11 @@ type ColorRoom struct {
|
||||
betAreaInfo []*pb.ColorBetAreaInfo // 本局每个投注区域信息
|
||||
}
|
||||
|
||||
func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.ErrCode) {
|
||||
func newColorRoom(id, roomType int, srv service.IService, userMgr *baseroom.PlayerMgr) (baseroom.IRoom, pb.ErrCode) {
|
||||
playType := int(pb.ServiceTypeId_STI_ColorGame)
|
||||
rm := &ColorRoom{
|
||||
BaseRoom: nil,
|
||||
userMgr: userMgr,
|
||||
roomCfg: &game.ColorRoomConfig{},
|
||||
timingCfg: &game.ColorGameTiming{},
|
||||
status: 0,
|
||||
@ -47,7 +50,7 @@ func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.Er
|
||||
rm.resetGameData()
|
||||
|
||||
code := pb.ErrCode_OK
|
||||
rm.BaseRoom, code = baseroom.NewBaseRoom[ColorSeat](id, roomType, playType, srv)
|
||||
rm.BaseRoom, code = baseroom.NewBaseRoom[*baseroom.BaseSeat](id, roomType, playType, srv)
|
||||
if code != pb.ErrCode_OK {
|
||||
log.ErrorF("new color room err code:%v", code)
|
||||
return nil, code
|
||||
@ -59,8 +62,10 @@ 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.onMatchRoom},
|
||||
pb.MsgId_ReqColorBettingId: {pb.ReqColorBetting{}, rm.onBet},
|
||||
pb.MsgId_ReqEnterRoomId: {pb.ReqEnterRoom{}, rm.onEnterRoom},
|
||||
pb.MsgId_ReqLeaveRoomId: {pb.ReqLeaveRoom{}, rm.onLeaveRoom},
|
||||
})
|
||||
rm.RegisterTimerMessages(processor.RegisterTimerMetas{
|
||||
TtGameStart: rm.gameStart,
|
||||
@ -91,6 +96,7 @@ func (rm *ColorRoom) resetGameData() {
|
||||
MyBet: 0,
|
||||
})
|
||||
}
|
||||
rm.initPrizeAreaRange()
|
||||
|
||||
// 清理玩家身上数据
|
||||
for _, st := range rm.Seats {
|
||||
@ -98,6 +104,9 @@ func (rm *ColorRoom) resetGameData() {
|
||||
GetPlayer(st.Player()).resetData()
|
||||
}
|
||||
}
|
||||
|
||||
// 游戏开始前清理不下注玩家
|
||||
rm.kickoutUsers()
|
||||
}
|
||||
|
||||
// 当前拥有金币
|
||||
@ -113,329 +122,3 @@ func (rm *ColorRoom) AddGold(user *ColorPlayer, add int64) (int64, bool) {
|
||||
user.totalBet += add
|
||||
return user.Gold - user.totalBet, true
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// const (
|
||||
// BigWinnerCount = 6
|
||||
// GameName = "ColorPinoyLive"
|
||||
// )
|
||||
//
|
||||
// func (rm *ColorRoom) SetGameStatus(status pb.ColorPinoyLiveGameStatus) {
|
||||
// rm.Status = status
|
||||
// rm.StatusTime = time.Now().UnixMilli()
|
||||
// log.DebugF(rm.Log("设置房间状态:%v", status))
|
||||
// }
|
||||
// func (rm *ColorRoom) GetGameStatus() pb.ColorPinoyLiveGameStatus {
|
||||
// return rm.Status
|
||||
// }
|
||||
//
|
||||
// // 客户端显示赔率范围
|
||||
// func (rm *ColorRoom) MulRangeConfig() []*pb.BetAreaMulRangeConfig {
|
||||
// var mulRangeCfg []*pb.BetAreaMulRangeConfig
|
||||
// for pos, mul := range rm.RoomCfg.WinSingleColorMul {
|
||||
// if len(mul) > 0 {
|
||||
// mulRangeCfg = append(mulRangeCfg, &pb.BetAreaMulRangeConfig{
|
||||
// Pos: pb.ColorPinoyLiveBigBetAreaPos(pos),
|
||||
// MinMul: mul[0].Mul,
|
||||
// MaxMul: mul[len(mul)-1].Mul,
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// if len(rm.RoomCfg.WinDoubleColorMul) > 0 {
|
||||
// mul := rm.RoomCfg.WinDoubleColorMul
|
||||
// mulRangeCfg = append(mulRangeCfg, &pb.BetAreaMulRangeConfig{
|
||||
// Pos: pb.ColorPinoyLiveBigBetAreaPos_BBA_Double,
|
||||
// MinMul: mul[0].Mul,
|
||||
// MaxMul: mul[0].Mul,
|
||||
// })
|
||||
// }
|
||||
// if len(rm.RoomCfg.WinThreeColorMul) > 0 {
|
||||
// mul := rm.RoomCfg.WinThreeColorMul
|
||||
// mulRangeCfg = append(mulRangeCfg, &pb.BetAreaMulRangeConfig{
|
||||
// Pos: pb.ColorPinoyLiveBigBetAreaPos_BBA_Three,
|
||||
// MinMul: mul[0].Mul,
|
||||
// MaxMul: mul[0].Mul,
|
||||
// })
|
||||
// }
|
||||
// if len(mulRangeCfg) != len(pb.ColorPinoyLiveBigBetAreaPos_name) {
|
||||
// log.Error(rm.Log(("配置错误")))
|
||||
// return nil
|
||||
// }
|
||||
// for pos, v := range mulRangeCfg {
|
||||
// log.Debug(rm.Log("pos:%v 赔率区间:%v-%v", pos, v.MinMul, v.MaxMul))
|
||||
// }
|
||||
// return mulRangeCfg
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) InitBigOddsBetAreas() {
|
||||
// if len(rm.betEndBetAreasOdds) == 0 {
|
||||
// rm.betEndBetAreasOdds = make([]*pb.ColorPinoyLiveGameBetAreaInfo, 0, len(pb.ColorPinoyLiveBetTypeJP_name))
|
||||
// }
|
||||
// rm.betEndBetAreasOdds = rm.betEndBetAreasOdds[0:0]
|
||||
// for betType := 0; betType < BET_TYPE_NUM; betType++ {
|
||||
// rm.betEndBetAreasOdds = append(rm.betEndBetAreasOdds, &pb.ColorPinoyLiveGameBetAreaInfo{
|
||||
// BetType: pb.ColorPinoyLiveBetTypeJP(betType),
|
||||
// BetChipsInfo: nil,
|
||||
// IsWin: 0,
|
||||
// Odd: nil,
|
||||
// IsBigOdd: false,
|
||||
// BigSingleColorOddPos: 0,
|
||||
// })
|
||||
// }
|
||||
// for pos, betArea := range rm.betEndBetAreasOdds {
|
||||
// betArea.IsBigOdd = false
|
||||
// index := pos / int(pb.ColorPinoyLiveDiceColorType_ColorPinoyLiveType_GREEN)
|
||||
// if index == 0 {
|
||||
// betArea.BigSingleColorOddPos = pb.ColorPinoyLiveBigBetAreaPos_BBA_Single_0
|
||||
// var mulRangeW []*MulRangeW
|
||||
// begin := 0
|
||||
// for _, mul := range rm.RoomCfg.WinSingleColorMul[0] {
|
||||
// mulRangeW = append(mulRangeW, &MulRangeW{MulRate: mul, ColorPos: pb.ColorPinoyLiveBigBetAreaPos(pos), MinW: begin, MaxW: begin + mul.Rate})
|
||||
// begin += mul.Rate
|
||||
// }
|
||||
// rdv := xrand.RandRange[int](mulRangeW[0].MinW, mulRangeW[len(mulRangeW)-1].MaxW)
|
||||
// singleMul := rm.Cfg.WinSingleColorMul[0][0].Mul
|
||||
// for _, mul := range mulRangeW {
|
||||
// if rdv < mul.MinW || rdv >= mul.MaxW {
|
||||
// continue
|
||||
// }
|
||||
// singleMul = mul.Mul
|
||||
// break
|
||||
// }
|
||||
// log.Debug(rm.Log("单色区域基础权重区间:[%v,%v],随机数:%v 基础赔率:%v", mulRangeW[0].MinW, mulRangeW[len(mulRangeW)-1].MaxW, rdv, singleMul))
|
||||
// betArea.Odd = append(betArea.Odd, singleMul)
|
||||
// betArea.Odd = append(betArea.Odd, rm.Cfg.WinSingleColorMul[1][0].Mul)
|
||||
// betArea.Odd = append(betArea.Odd, rm.Cfg.WinSingleColorMul[2][0].Mul)
|
||||
// } else if index == 1 {
|
||||
// betArea.BigSingleColorOddPos = pb.ColorPinoyLiveBigBetAreaPos_BBA_Double
|
||||
// betArea.Odd = append(betArea.Odd, rm.Cfg.WinDoubleColorMul[0].Mul)
|
||||
// } else {
|
||||
// betArea.BigSingleColorOddPos = pb.ColorPinoyLiveBigBetAreaPos_BBA_Three
|
||||
// betArea.Odd = append(betArea.Odd, rm.Cfg.WinThreeColorMul[0].Mul)
|
||||
// }
|
||||
// }
|
||||
// for _, betArea := range rm.betEndBetAreasOdds {
|
||||
// log.Debug(rm.Log("初始化投注区域:%v 倍率:%v 是否爆奖:%v 是否jackpot:%v", betArea.BetType, betArea.Odd, betArea.IsBigOdd, betArea.IsJackpot))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) Log(format string, args ...any) string {
|
||||
// s := fmt.Sprintf(format, args...)
|
||||
// head := fmt.Sprintf("gameno:%v ", rm.Table.GetGameRoundId())
|
||||
// return head + s
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) LogEx(user *model.User, format string, args ...any) string {
|
||||
// s := fmt.Sprintf(format, args...)
|
||||
// head := fmt.Sprintf("gameno:%v user:%v", rm.Table.GetGameRoundId(), user.UserID)
|
||||
// return head + s
|
||||
// }
|
||||
//
|
||||
//
|
||||
// func (rm *ColorRoom) ResetConfigPrivate() bool {
|
||||
// rm.RoomCfg = config.ResetConfigPrivate()
|
||||
// rm.Cfg = &rm.RoomCfg.ColorPinoyLiveConfig
|
||||
// return true
|
||||
// }
|
||||
// func (rm *ColorRoom) GetPlayer(userid int64) *model.User {
|
||||
// user, ok := rm.AllUserList.Load(userid)
|
||||
// if !ok {
|
||||
// return nil
|
||||
// }
|
||||
// player, ok := user.(*model.User)
|
||||
// if !ok {
|
||||
// return nil
|
||||
// }
|
||||
// return player
|
||||
// }
|
||||
// func (rm *ColorRoom) AddPlayer(player *model.User) {
|
||||
// rm.AllUserList.Store(player.UserInetr.GetId(), player)
|
||||
// rm.MutexUserList.Lock()
|
||||
// rm.OnlineUserList = append(rm.OnlineUserList, player)
|
||||
// rm.MutexUserList.Unlock()
|
||||
// }
|
||||
//
|
||||
// type TraverseFunc func(v *model.User) bool
|
||||
//
|
||||
// func (rm *ColorRoom) Traverse(f TraverseFunc) {
|
||||
// function := func(key, value interface{}) bool {
|
||||
// if value != nil {
|
||||
// us, ok := value.(*model.User)
|
||||
// if !ok {
|
||||
// log.Warn("user is not *UserInetr")
|
||||
// } else {
|
||||
// return f(us)
|
||||
// }
|
||||
// }
|
||||
// return true
|
||||
// }
|
||||
// rm.AllUserList.Range(function)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// func (rm *ColorRoom) DeletePlayer(uid int64) {
|
||||
// p := rm.GetPlayer(uid)
|
||||
// if p != nil {
|
||||
// rm.AllUserList.Delete(uid)
|
||||
// rm.DeleteExitUserFromOnlineUserListSlice(p)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// func (rm *ColorRoom) UserExit(user inter.UserInetr) bool {
|
||||
// u := rm.getUser(user)
|
||||
// // 有下注时不让玩家离开
|
||||
// if u.totalBet != 0 {
|
||||
// return false
|
||||
// }
|
||||
// rm.KickOutUser(u)
|
||||
// return true
|
||||
// }
|
||||
// func (rm *ColorRoom) LeaveGame(user inter.UserInetr) bool {
|
||||
// u := rm.getUser(user)
|
||||
// if u.totalBet != 0 {
|
||||
// // msg := new(pb.KickOutUserMsg)
|
||||
// // msg.KickOutReason = "游戏中不能退出!"
|
||||
// // u.SendMsg(int32(pb.SendToClientMessageType_NoticeExitRet), msg)
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// rm.KickOutUser(u)
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// // 游戏消息
|
||||
// func (rm *ColorRoom) OnGameMessage(subCmd int32, buffer []byte, user inter.UserInetr) {
|
||||
// // log.Debug("收到客户端消息:", subCmd)
|
||||
// switch pb.ColorPinoyLiveReceiveFromClientMessageType(subCmd) {
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyRefresh:
|
||||
// rm.GameSync(user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyBetChips:
|
||||
// monitor.GoSafe(rm.Bet, buffer, user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyGetUserListInfo:
|
||||
// monitor.GoSafe(rm.SendUserListInfo, user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyGetTrend:
|
||||
// monitor.GoSafe(rm.SendTrend, user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyBetAgain:
|
||||
// // go rm.AgainBet(user)
|
||||
// monitor.GoSafe(rm.AgainBet, user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyBetDouble:
|
||||
// monitor.GoSafe(rm.BetDouble, user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyUndoBet:
|
||||
// monitor.GoSafe(rm.OnUndoBet, buffer, user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyUseProps:
|
||||
// monitor.GoSafe(rm.ApplyUseProps, buffer, user)
|
||||
// case pb.ColorPinoyLiveReceiveFromClientMessageType_ColorPinoyLiveApplyLeave:
|
||||
// monitor.GoSafe(rm.ApplyLeave, buffer, user)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) initDefaultDiceGameRoundReady() {
|
||||
// // rm.DefaultLuckyDice = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// //
|
||||
// // rm.DefaultNormalDices[0] = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// // rm.DefaultNormalDices[1] = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// // rm.DefaultNormalDices[2] = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// }
|
||||
//
|
||||
// // 开lucky dice
|
||||
// func (rm *ColorRoom) OpenLuckyDice() {
|
||||
//
|
||||
// dealDice := rm.GetPairDice(1, 0, 1)
|
||||
//
|
||||
// if dealDice == nil || len(dealDice) < 1 {
|
||||
// rm.LuckyDice = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// } else {
|
||||
// deck := model.GetInitialDeck()
|
||||
// rm.LuckyDice = deck[dealDice[0]-1]
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 开3个普通 dice
|
||||
// func (rm *ColorRoom) OpenThreeDice() {
|
||||
//
|
||||
// dealDice := rm.GetPairDice(3, 1, 4)
|
||||
// if dealDice == nil || len(dealDice) < 3 {
|
||||
// rm.NormalDices[0] = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// rm.NormalDices[1] = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// rm.NormalDices[2] = rm.GamePoker.ShuffleDices(1)[0]
|
||||
// } else {
|
||||
// deck := model.GetInitialDeck()
|
||||
// rm.NormalDices[0] = deck[dealDice[0]-1]
|
||||
// rm.NormalDices[1] = deck[dealDice[1]-1]
|
||||
// rm.NormalDices[2] = deck[dealDice[2]-1]
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) getUser(user inter.UserInetr) *model.User {
|
||||
// // u, ok := rm.AllUserList[user.GetId()]
|
||||
// u := rm.GetPlayer(user.GetId())
|
||||
// if u == nil {
|
||||
// u = new(model.User)
|
||||
// u.UserID = user.GetId()
|
||||
// u.UserInetr = user
|
||||
// u.Balance = user.GetScore()
|
||||
// u.Carry = user.GetCarry()
|
||||
// u.Time = time.Now().UnixNano() / 1e6
|
||||
// u.UserInetr = user
|
||||
// rm.AddPlayer(u)
|
||||
// u.ResetUserData()
|
||||
// }
|
||||
//
|
||||
// return u
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) getRobotUser(user inter.UserInetr) *model.User {
|
||||
// // u, ok := rm.AllUserList[user.GetId()]
|
||||
// u := rm.GetPlayer(user.GetId())
|
||||
// if u == nil {
|
||||
// u = new(model.User)
|
||||
// u.UserID = user.GetId()
|
||||
// u.UserInetr = user
|
||||
// u.Balance = user.GetScore()
|
||||
// u.Carry = user.GetCarry()
|
||||
// u.Time = time.Now().UnixNano() / 1e6
|
||||
// u.UserInetr = user
|
||||
// u.IsRobot = true
|
||||
// rm.AddPlayer(u)
|
||||
// u.ResetUserData()
|
||||
// }
|
||||
//
|
||||
// return u
|
||||
// }
|
||||
//
|
||||
// // 游戏开始入口.....
|
||||
// func (rm *ColorRoom) GameStart() bool {
|
||||
// if rm.GetGameStatus() == 0 {
|
||||
// rm.Ready()
|
||||
// rm.SyncServerMaintenance(0, "")
|
||||
// _ = rm.LiveDelayUpdate()
|
||||
// // 防止卡房间
|
||||
// rm.Table.AddTimerRepeat(60, 0, func() {
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// rm.Table.EndGame()
|
||||
// }
|
||||
// })
|
||||
// } else if rm.TimerJob != nil {
|
||||
// }
|
||||
//
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) GameRoundStart() {
|
||||
// rm.RoomCfg = config.ResetConfig()
|
||||
// rm.Cfg = &rm.RoomCfg.ColorPinoyLiveConfig
|
||||
// rm.ServerStatus = gconfig.GConfig.GServConfig.Status
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) ResetTable() {
|
||||
// rm.SetGameStatus(0)
|
||||
// }
|
||||
//
|
||||
// // 关闭桌子
|
||||
// func (rm *ColorRoom) CloseTable() {
|
||||
// }
|
||||
|
@ -1,7 +0,0 @@
|
||||
package room
|
||||
|
||||
import "game/common/baseroom"
|
||||
|
||||
type ColorSeat struct {
|
||||
*baseroom.BaseSeat
|
||||
}
|
@ -9,17 +9,8 @@ import (
|
||||
type RoomFactory struct {
|
||||
}
|
||||
|
||||
func (r *RoomFactory) CreateRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.ErrCode) {
|
||||
return newColorRoom(id, roomType, srv)
|
||||
}
|
||||
|
||||
type PlayerFactory struct {
|
||||
}
|
||||
|
||||
func (r *PlayerFactory) CreatePlayer(uid int64) (baseroom.IPlayer, pb.ErrCode) {
|
||||
player := &ColorPlayer{}
|
||||
code := pb.ErrCode_OK
|
||||
return player, code
|
||||
func (r *RoomFactory) CreateRoom(id, roomType int, srv service.IService, userMgr *baseroom.PlayerMgr) (baseroom.IRoom, pb.ErrCode) {
|
||||
return newColorRoom(id, roomType, srv, userMgr)
|
||||
}
|
||||
|
||||
func GetPlayer(p baseroom.IPlayer) *ColorPlayer {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
package room
|
||||
|
||||
import (
|
||||
"game/common/baseroom"
|
||||
"game/common/proto/pb"
|
||||
"time"
|
||||
)
|
||||
@ -50,119 +51,14 @@ func (rm *ColorRoom) onSecond() {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// import (
|
||||
// "encoding/json"
|
||||
// "game/common/proto/pb"
|
||||
// "github.com/fox/fox/ipb"
|
||||
// "time"
|
||||
// )
|
||||
//
|
||||
// func (rm *ColorRoom) Ready() {
|
||||
// rm.Table.ResetGameRoundId()
|
||||
// rm.ResetData(true)
|
||||
// rm.Table.EndGame()
|
||||
//
|
||||
// if isFunding := rm.jackpotMgr.Load(rm.RoomCfg.ColorPinoyLiveConfig.InitJackpot); isFunding {
|
||||
// rm.kafkaJackpotFunding(rm.RoomCfg.ColorPinoyLiveConfig.InitJackpot)
|
||||
// rm.jackpotFunding = rm.RoomCfg.ColorPinoyLiveConfig.InitJackpot
|
||||
// log.Debugf(rm.Log("发生垫资:%v", rm.jackpotFunding))
|
||||
// } else {
|
||||
// rm.jackpotFunding = 0
|
||||
// log.Debugf(rm.Log("没有垫资"))
|
||||
// }
|
||||
// rm.jackpotUser = nil
|
||||
// rm.costJackpot = 0
|
||||
// log.Debugf(rm.Log("游戏开始costJackpot重置为0"))
|
||||
// rm.SetGameStatus(pb.ColorPinoyLiveGameStatus_ColorPinoyLiveStartReady)
|
||||
// rm.TimerJob, _ = rm.Table.AddTimer(time.Duration(rm.RoomCfg.TimeConf.Readymove), func() {
|
||||
// rm.Start()
|
||||
// })
|
||||
//
|
||||
// // 初始化默认骰子
|
||||
// // rm.initDefaultDiceGameRoundReady()
|
||||
// // 开始动画消息
|
||||
// msg := new(pb.ColorPinoyLiveStatusMessage)
|
||||
// msg.Status = int32(rm.GetGameStatus())
|
||||
// msg.StatusTime = int32(rm.RoomCfg.TimeConf.Startmove)
|
||||
// msg.Jackpot = rm.jackpotMgr.GetJackpot()
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameReady), msg)
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) Start() {
|
||||
// rm.GameRoundStart()
|
||||
// rm.InitBigOddsBetAreas()
|
||||
// // 推送房间筹码选择规则
|
||||
// rm.SendRuleInfo()
|
||||
// rm.checkUserBet()
|
||||
// // 选择列表中前6个用户上座
|
||||
// rm.SelectUserListBalanceTopSitDownChair()
|
||||
// rm.startAt = time.Now().Unix()
|
||||
// rm.Table.StartGame()
|
||||
// // 开始动画消息
|
||||
// msg := new(pb.ColorPinoyLiveStatusMessage)
|
||||
// msg.Status = int32(rm.GetGameStatus())
|
||||
// msg.StatusTime = int32(rm.RoomCfg.TimeConf.Startmove)
|
||||
// // rm.jackpotMgr.Load(rm.Cfg.InitJackpot)
|
||||
// msg.Jackpot = rm.jackpotMgr.GetJackpot()
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameStart), msg)
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) StartBet() {
|
||||
// rm.SetGameStatus(pb.ColorPinoyLiveGameStatus_ColorPinoyLiveBetStatus)
|
||||
// rm.TimerJob, _ = rm.Table.AddTimer(time.Duration(rm.RoomCfg.TimeConf.Startbet), func() {
|
||||
// rm.EndBet()
|
||||
// })
|
||||
//
|
||||
// // 发送开始下注消息
|
||||
// msg := new(pb.ColorPinoyLiveStatusMessage)
|
||||
// msg.Status = int32(rm.GetGameStatus())
|
||||
// msg.StatusTime = int32(rm.RoomCfg.TimeConf.Startbet)
|
||||
// msg.Jackpot = rm.jackpotMgr.GetJackpot()
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameStartBet), msg)
|
||||
// // log.Debug("pb. 开始下注.....StartBet()")
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) EndBet() {
|
||||
// rm.SetGameStatus(pb.ColorPinoyLiveGameStatus_ColorPinoyLiveEndBetMovie)
|
||||
// // 停止下注就扣钱
|
||||
// rm.StartTransInoutBet()
|
||||
//
|
||||
// // 发送停止下注消息
|
||||
// msg := new(pb.ColorPinoyLiveStatusMessage)
|
||||
// msg.Status = int32(rm.GetGameStatus())
|
||||
// msg.StatusTime = int32(rm.RoomCfg.TimeConf.Endmove)
|
||||
// msg.Jackpot = rm.jackpotMgr.GetJackpot()
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameEndBet), msg)
|
||||
//
|
||||
// // log.Debug("pb. 停止下注.....EndBet()")
|
||||
// }
|
||||
//
|
||||
// // 开3个 dice
|
||||
// func (rm *ColorRoom) openThreeDice() {
|
||||
// // log.Debug("aabb openThreeDice")
|
||||
// rm.SetGameStatus(pb.ColorPinoyLiveGameStatus_ColorPinoyLiveOpenThreeDice)
|
||||
// rm.Table.AddTimer(time.Duration(rm.RoomCfg.TimeConf.OpenThreeDice), func() {
|
||||
// // log.Debug("aabb gameSettle")
|
||||
// rm.CompareDiceResult()
|
||||
// rm.Settle()
|
||||
// })
|
||||
// // 发送开三个骰子消息
|
||||
// rm._aniThreeDiceRouteIndex = int32(rand.RandIntM(0, 48))
|
||||
// msg := new(pb.ColorPinoyLiveGameOpenThreeDice)
|
||||
// msg.Status = int32(rm.GetGameStatus())
|
||||
// msg.AniRouteIndex = rm._aniThreeDiceRouteIndex // 掉落路径
|
||||
//
|
||||
// for _, dice := range rm.NormalDices {
|
||||
// msg.Color = append(msg.Color, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameOpenThreeDice), msg)
|
||||
// }
|
||||
//
|
||||
// // 结算
|
||||
// func (rm *ColorRoom) Settle() {
|
||||
// // log.Debug("aabb 结算")
|
||||
// rm.SetGameStatus(pb.ColorPinoyLiveGameStatus_ColorPinoyLiveSettleStatus)
|
||||
// rm.endAt = time.Now().Unix()
|
||||
// rm.SetUserSettleMsg()
|
||||
// }
|
||||
// 踢出不投注玩家,清空座位及从玩家管理器中删除
|
||||
func (rm *ColorRoom) kickoutUsers() {
|
||||
rm.RangePlayer(func(u baseroom.IPlayer) bool {
|
||||
user := GetPlayer(u)
|
||||
if user.notBetCount >= rm.roomCfg.NoBetCountMax {
|
||||
rm.leaveRoom(user)
|
||||
rm.notifyKickoutUser(user, pb.ErrCode_NotBetCount)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
@ -63,706 +63,60 @@ func (rm *ColorRoom) notifyColorBetAreaInfo() {
|
||||
})
|
||||
}
|
||||
|
||||
//
|
||||
// import (
|
||||
// "encoding/json"
|
||||
// "fmt"
|
||||
// "game/common/config/game"
|
||||
// "game/common/proto/pb"
|
||||
// "github.com/fox/fox/ipb"
|
||||
// "github.com/fox/fox/log"
|
||||
// "math"
|
||||
// "sort"
|
||||
// "time"
|
||||
// )
|
||||
//
|
||||
// // 发送场景消息
|
||||
// func (rm *ColorRoom) SendSceneMsg(u *model.User) {
|
||||
//
|
||||
// rm.MutexUserList.RLock()
|
||||
// defer rm.MutexUserList.RUnlock()
|
||||
//
|
||||
// msg := new(pb.SceneMessage)
|
||||
//
|
||||
// msg.RoomID = int32(rm.Table.GetId())
|
||||
// // 游戏状态信息
|
||||
// msg.GameStatus = new(pb.ColorPinoyLiveStatusMessage)
|
||||
// msg.GameStatus.Status = int32(rm.GetGameStatus())
|
||||
// msg.GameStatus.StatusTime = int32(rm.StatusTime / 1000) // 转成秒
|
||||
// msg.GameStatus.StatusRemainTime = int32(math.Floor(float64(rm.TimerJob.GetTimeDifference() / 1000))) // 转成秒
|
||||
// msg.GameStatus.Jackpot = rm.jackpotMgr.GetJackpot()
|
||||
// msg.Jackpot = msg.GameStatus.Jackpot
|
||||
//
|
||||
// // 玩家信息 和下注信息
|
||||
// var betAreaInfo []*pb.ColorPinoyLiveGameBetAreaInfo
|
||||
// for _, betArea := range rm.betEndBetAreasOdds {
|
||||
// areaInfo := new(pb.ColorPinoyLiveGameBetAreaInfo)
|
||||
// areaInfo.BetType = betArea.BetType
|
||||
// areaInfo.Odd = betArea.Odd
|
||||
// areaInfo.IsBigOdd = betArea.IsBigOdd
|
||||
// areaInfo.IsJackpot = betArea.IsJackpot
|
||||
// areaInfo.BigSingleColorOddPos = betArea.BigSingleColorOddPos
|
||||
//
|
||||
// areaInfo.BetChipsInfo = []*pb.ColorPinoyLiveGameBetAreaUserInfo{}
|
||||
// betAreaInfo = append(betAreaInfo, areaInfo)
|
||||
// }
|
||||
// rm.Traverse(func(u *model.User) bool {
|
||||
// if u.totalBet > 0 {
|
||||
// // 下注玩家下注区域信息
|
||||
// for _, info := range betAreaInfo {
|
||||
// for betType, betChips := range u.totalBets {
|
||||
// if pb.ColorPinoyLiveBetTypeJP(betType) == info.BetType && betChips != 0 {
|
||||
// var betAearUser = new(pb.ColorPinoyLiveGameBetAreaUserInfo)
|
||||
// betAearUser.UserID = u.UserID
|
||||
// betAearUser.BetChips = betChips
|
||||
// info.BetChipsInfo = append(info.BetChipsInfo, betAearUser)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true
|
||||
// })
|
||||
// msg.BetAreaInfo = betAreaInfo
|
||||
// msg.MulRangeConfig = rm.MulRangeConfig()
|
||||
//
|
||||
// if u != nil {
|
||||
// // 后台配置的下注档位信息
|
||||
// roomBetRule := new(pb.ColorPinoyLiveRoomBetRuleMsg)
|
||||
// for _, v := range rm.RoomCfg.ColorPinoyLiveConfig.BetList {
|
||||
// betArr := new(pb.ColorPinoyLiveBetArr)
|
||||
// betArr.BetArr = v
|
||||
// roomBetRule.BetLevels = append(roomBetRule.BetLevels, betArr)
|
||||
// }
|
||||
// roomBetRule.BetMinLimit = rm.RoomCfg.BaseBet
|
||||
// roomBetRule.Level = rm.RoomCfg.ColorPinoyLiveConfig.BetLevel
|
||||
// msg.BetRule = roomBetRule
|
||||
// // 上局下注数据
|
||||
// if u.TempLastTimeBet != nil {
|
||||
// msg.LastTimeBet = make([]*pb.ColorPinoyLiveBetReqs, 0)
|
||||
// for _, reqs := range u.TempLastTimeBet {
|
||||
// betreq := &pb.ColorPinoyLiveBetReqs{}
|
||||
// for _, req := range reqs {
|
||||
// betreq.Info = append(betreq.Info, req)
|
||||
// }
|
||||
// msg.LastTimeBet = append(msg.LastTimeBet, betreq)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if rm.Status == pb.ColorPinoyLiveGameStatus_ColorPinoyLiveOpenThreeDice || rm.Status == pb.ColorPinoyLiveGameStatus_ColorPinoyLiveSettleStatus {
|
||||
// // 3个骰子
|
||||
// // log.Debug("同步房间信息发送场景信息 rm.NormalDices:", rm.NormalDices)
|
||||
// msg.LuckyDice = pb.ColorPinoyLiveDiceColorType(model.GetColor(rm.LuckyDice))
|
||||
// msg.ThreeDice = []pb.ColorPinoyLiveDiceColorType{}
|
||||
// for _, dice := range rm.NormalDices {
|
||||
// msg.ThreeDice = append(msg.ThreeDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// // log.Debug("同步房间信息发送场景信息 i:", i, "dice:", dice, "color:", pb.DiceColorType(model.GetColor(dice)), "msg.ThreeDice:", msg.ThreeDice)
|
||||
// }
|
||||
// msg.AniThreeDiceRouteIndex = rm._aniThreeDiceRouteIndex
|
||||
// }
|
||||
// // 走势图
|
||||
// msg.TrendList = rm.GameTrend
|
||||
// if msg.TrendList != nil {
|
||||
// msg.TrendList.LuckStarRate = rm.GetGameTrend()
|
||||
// }
|
||||
//
|
||||
// // 在线人数
|
||||
// msg.OnlineNums = int32(len(rm.OnlineUserList))
|
||||
// if rm.LiveMgr.RankList != nil {
|
||||
// msg.RankList = rm.LiveMgr.RankList.PlayerData
|
||||
// }
|
||||
// // msg.Bonus = int32(rm.RoomCfg.ColorPinoyLiveConfig.Bonus)
|
||||
//
|
||||
// liveAuthDuration := time.Hour * 24
|
||||
// //goland:noinspection GoDfaNilDereference
|
||||
// msg.ArtcUrl, _ = artc.GetAuthedUrl(
|
||||
// gconfig.LiveRtcConfig.Uri,
|
||||
// gconfig.LiveRtcConfig.Key,
|
||||
// u.UserInetr.GetId(),
|
||||
// liveAuthDuration,
|
||||
// )
|
||||
// roomArgs, _ := trtc.GetRoomArgs(
|
||||
// gconfig.LiveTrtcConfig.AppId,
|
||||
// gconfig.LiveTrtcConfig.SecretKey,
|
||||
// int64(gconfig.LiveTrtcConfig.GameId),
|
||||
// u.UserInetr.GetId(),
|
||||
// liveAuthDuration,
|
||||
// gconfig.GConfig.GDataConfig.VersionMode,
|
||||
// )
|
||||
// msg.TrtcRoomArgs = &pb.TRTCRoomArgs{
|
||||
// AppId: roomArgs.AppId,
|
||||
// StrRoomId: roomArgs.StrRoomId,
|
||||
// UserId: roomArgs.UserId,
|
||||
// UserSig: roomArgs.UserSig,
|
||||
// }
|
||||
// msg.Balance = u.Balance
|
||||
// msg.BigWinner = rm.BigWinner
|
||||
// if rm.GetGameStatus() < pb.ColorPinoyLiveGameStatus_ColorPinoyLiveEndBetMovie {
|
||||
// msg.BigWinner = nil
|
||||
// }
|
||||
// msg.DealerName = rm.dealerName
|
||||
// // log.Debug("同步房间信息发送场景信息 msg:", msg)
|
||||
// // log.Debug(msg)
|
||||
// u.SendMsg(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameSync), msg)
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) SendUserBet(u *model.User) {
|
||||
// msg := new(pb.ColorPinoyLiveSceneBetInfo)
|
||||
// msg.UserBets = u.totalBets[:]
|
||||
// msg.totalBets = rm.totalBets[:]
|
||||
// msg.UserBetTotal = u.totalBet
|
||||
// // msg.MasterBetType = rm.LastMasterBetType
|
||||
// msg.UserInfo = new(pb.ColorPinoyLiveUserInfo)
|
||||
// msg.UserInfo.UserID = u.UserID
|
||||
// msg.UserInfo.UserGlod = u.Balance
|
||||
// msg.UserInfo.NikeName = u.UserInetr.GetNike()
|
||||
// msg.UserInfo.Head = u.UserInetr.GetHead()
|
||||
// _ = u.UserInetr.SendMsg(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameUserBet), msg)
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) SendRuleInfo() {
|
||||
// // 后台配置的下注档位信息
|
||||
// msg := new(pb.ColorPinoyLiveRoomBetRuleMsg)
|
||||
// for _, v := range rm.RoomCfg.ColorPinoyLiveConfig.BetList {
|
||||
// betArr := new(pb.ColorPinoyLiveBetArr)
|
||||
// betArr.BetArr = v
|
||||
// msg.BetLevels = append(msg.BetLevels, betArr)
|
||||
// }
|
||||
// msg.BetMinLimit = rm.RoomCfg.BaseBet
|
||||
// msg.Level = rm.RoomCfg.ColorPinoyLiveConfig.BetLevel
|
||||
// msg.MulRangeConfig = rm.MulRangeConfig()
|
||||
// // log.Debug("发送规则 2222 BroadcastRuleInfo:", msg)
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeRoomBetRuleMsg), msg)
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) SendScene(user inter.UserInetr) bool {
|
||||
// _ = user
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) copyBetAreaOdds() []*pb.ColorPinoyLiveBetAreaOdd {
|
||||
// var betAreaMul []*pb.ColorPinoyLiveBetAreaOdd
|
||||
// // 游戏下注区域倍率
|
||||
// for _, areaOdds := range rm.afterBetAreaOdds {
|
||||
// area := &pb.ColorPinoyLiveBetAreaOdd{
|
||||
// BetArea: areaOdds.BetArea,
|
||||
// Odd: areaOdds.Odd,
|
||||
// ViewOdd: areaOdds.ViewOdd,
|
||||
// IsBigOdd: areaOdds.IsBigOdd,
|
||||
// BigSingleColorOddPos: areaOdds.BigSingleColorOddPos,
|
||||
// IsWin: areaOdds.IsWin,
|
||||
// IsJackpot: areaOdds.IsJackpot,
|
||||
// }
|
||||
// betAreaMul = append(betAreaMul, area)
|
||||
// }
|
||||
// return betAreaMul
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) GameSync(user inter.UserInetr) {
|
||||
// // 玩家加入 牌桌
|
||||
// u := rm.getUser(user)
|
||||
// rm.SendSceneMsg(u)
|
||||
// rm.Table.AddTimer(100, func() {
|
||||
// if rm.LiveMgr.MaintenanceStatus == 1 {
|
||||
// rm.sendUserMainte(u, int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameMainte))
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// // 向客户端发送结算消息
|
||||
// func (rm *ColorRoom) sendSettleMsg2Client() {
|
||||
//
|
||||
// MaxWinGold := int64(0)
|
||||
// MaxWinUserID := int64(0)
|
||||
// var RealSystemWins [config.BET_TYPE_NUM]int64
|
||||
// var RealSystemWin int64
|
||||
// var SystemTax int64
|
||||
// var PlayerData []*pb.ColorPinoyLivePlayerData
|
||||
// betTypePlayerCount := [config.BET_TYPE_NUM]int64{}
|
||||
// wins := rm.PokerMsg.WinBetArea
|
||||
//
|
||||
// // 玩家各个下注区域的输赢情况
|
||||
// var betAreaInfo []*pb.ColorPinoyLiveGameBetAreaInfo
|
||||
// for i := 0; i < config.BET_TYPE_NUM; i++ {
|
||||
// areaInfo := new(pb.ColorPinoyLiveGameBetAreaInfo)
|
||||
// areaInfo.BetType = pb.ColorPinoyLiveBetTypeJP(i)
|
||||
// for _, win := range wins {
|
||||
// if win.BetArea == areaInfo.BetType {
|
||||
// areaInfo.IsWin = 1
|
||||
// }
|
||||
// }
|
||||
// areaInfo.BetChipsInfo = []*pb.ColorPinoyLiveGameBetAreaUserInfo{}
|
||||
// betAreaInfo = append(betAreaInfo, areaInfo)
|
||||
// }
|
||||
//
|
||||
// // 获取有座玩家下注情况 暂时没有有座玩家下注
|
||||
// var betUserInfo []*pb.ColorPinoyLiveSceneUserInfo
|
||||
// noChairTotalWin := int64(0)
|
||||
// rm.Traverse(func(u *model.User) bool {
|
||||
// if u.totalBet > 0 && u.SettleMsg != nil {
|
||||
// user := new(pb.ColorPinoyLiveSceneUserInfo)
|
||||
// user.UserID = u.UserID
|
||||
// user.TotalWin = u.SettleMsg.TotalWin
|
||||
// user.UserScore = u.SettleMsg.UserScore
|
||||
//
|
||||
// for _, info := range betAreaInfo {
|
||||
// for betType, betChips := range u.SettleMsg.UserBets {
|
||||
// if pb.ColorPinoyLiveBetTypeJP(betType) == info.BetType && betChips != 0 {
|
||||
// var betAearUser = new(pb.ColorPinoyLiveGameBetAreaUserInfo)
|
||||
// betAearUser.UserID = u.UserID
|
||||
// betAearUser.BetChips = betChips
|
||||
// info.BetChipsInfo = append(info.BetChipsInfo, betAearUser)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// betUserInfo = append(betUserInfo, user)
|
||||
// noChairTotalWin += u.SettleMsg.TotalWin
|
||||
//
|
||||
// }
|
||||
// return true
|
||||
// })
|
||||
//
|
||||
// // 单播每个玩家的结算信息
|
||||
// copyBetAreaMul := rm.copyBetAreaOdds()
|
||||
// betCount := int64(0)
|
||||
// GameTotalBets := [config.BET_TYPE_NUM]int64{}
|
||||
// rm.Traverse(func(u *model.User) bool {
|
||||
//
|
||||
// SceneUserInfo := new(pb.ColorPinoyLiveSceneSettleMsg)
|
||||
// // 下注区域投注信息
|
||||
// SceneUserInfo.BetAreaInfo = betAreaInfo
|
||||
// // 本局走势图数据
|
||||
// trendGroup := new(pb.ColorPinoyLiveTrendGroup)
|
||||
// trendGroup.LuckyDice = pb.ColorPinoyLiveDiceColorType(model.GetColor(rm.LuckyDice))
|
||||
// for _, dice := range rm.NormalDices {
|
||||
// trendGroup.ThreeDice = append(trendGroup.ThreeDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// SceneUserInfo.TrendGroup = trendGroup
|
||||
// // 有座玩家下注信息 暂时没有有座玩家
|
||||
// // SceneUserInfo.UserList = betUserInfo
|
||||
// // 幸运骰子
|
||||
// SceneUserInfo.LuckyDice = pb.ColorPinoyLiveDiceColorType(model.GetColor(rm.LuckyDice))
|
||||
// // 3个骰子
|
||||
// SceneUserInfo.ThreeDice = []pb.ColorPinoyLiveDiceColorType{}
|
||||
// for _, dice := range rm.NormalDices {
|
||||
// SceneUserInfo.ThreeDice = append(SceneUserInfo.ThreeDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
// // 自己的投注信息
|
||||
// if u.SettleMsg != nil {
|
||||
// SceneUserInfo.SelfWinInfo = new(pb.ColorPinoyLiveSceneUserInfo)
|
||||
// SceneUserInfo.SelfWinInfo.UserID = int64(u.UserInetr.GetId())
|
||||
// SceneUserInfo.SelfWinInfo.SceneSeatID = int32(u.SceneChairId)
|
||||
// SceneUserInfo.SelfWinInfo.TotalWin = u.SettleMsg.TotalWin // 净利 + 投注本金
|
||||
// SceneUserInfo.SelfWinInfo.UserScore = u.SettleMsg.UserScore
|
||||
// SceneUserInfo.SelfWinInfo.JackpotWin = u.SettleMsg.JackpotWin
|
||||
// SceneUserInfo.SelfWinInfo.NormalWin = u.SettleMsg.TotalWin - u.SettleMsg.JackpotWin
|
||||
// }
|
||||
// // 上局投注信息
|
||||
// SceneUserInfo.LastTimeBet = make([]*pb.ColorPinoyLiveBetReqs, 0)
|
||||
// for _, reqs := range u.LastTimeBet {
|
||||
// betreq := &pb.ColorPinoyLiveBetReqs{}
|
||||
// for _, req := range reqs {
|
||||
// betreq.Info = append(betreq.Info, req)
|
||||
// }
|
||||
// SceneUserInfo.LastTimeBet = append(SceneUserInfo.LastTimeBet, betreq)
|
||||
// }
|
||||
// SceneUserInfo.TrendGroupEx = &pb.ColorPinoyLiveTrend{}
|
||||
// SceneUserInfo.TrendGroupEx.ListTrendGroup = rm.GameTrend.ListTrendGroup
|
||||
// SceneUserInfo.TrendGroupEx.LuckStarRate = rm.GetGameTrend()
|
||||
// SceneUserInfo.BigWinner = rm.BigWinner
|
||||
// SceneUserInfo.Jackpot = rm.jackpotMgr.GetJackpot()
|
||||
// SceneUserInfo.JackpotUserName = u.SettleMsg.JackpotUserName
|
||||
// // 单播玩家结算信息
|
||||
// // log.Debug("发送结算信息 SceneUserInfo BetAreaInfo:", SceneUserInfo.BetAreaInfo)
|
||||
// // log.Debug("发送结算信息 SceneUserInfo UserList:", SceneUserInfo.UserList)
|
||||
// // log.Debug("发送结算信息 SceneUserInfo SelfWinInfo:", SceneUserInfo.SelfWinInfo)
|
||||
// u.SendMsg(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeGameUserSettle), SceneUserInfo)
|
||||
//
|
||||
// if !u.IsRobot && u.SettleMsg != nil {
|
||||
// RealSystemWin += u.totalBet
|
||||
// RealSystemWin -= u.SettleMsg.TotalWin
|
||||
// betCount += u.totalBet
|
||||
// SystemTax += u.SettleMsg.Tax
|
||||
// if MaxWinGold < u.SettleMsg.TotalWin-u.totalBet {
|
||||
// MaxWinGold = u.SettleMsg.TotalWin - u.totalBet
|
||||
// MaxWinUserID = u.UserInetr.GetId()
|
||||
// }
|
||||
// for i, bet := range u.totalBets {
|
||||
// if bet > 0 {
|
||||
// RealSystemWins[i] += bet
|
||||
// betTypePlayerCount[i] += 1
|
||||
// RealSystemWins[i] -= u.SettleMsg.UserRealWins[i]
|
||||
// GameTotalBets[i] += bet
|
||||
// }
|
||||
// }
|
||||
// // 写入数据库统计信息
|
||||
// if u.totalBet > 0 {
|
||||
// // 玩家下注区域统计
|
||||
// u.SettleMsg.UserBetsCount = make([]int64, config.BET_TYPE_NUM)
|
||||
// for i, count := range u.TotalBetsCount {
|
||||
// u.SettleMsg.UserBetsCount[i] = count
|
||||
// }
|
||||
// PlayerData = append(PlayerData, &pb.ColorPinoyLivePlayerData{
|
||||
// Uid: u.UserID,
|
||||
// totalBets: u.SettleMsg.UserBets, // 玩家各个区域的总下注额
|
||||
// totalBet: u.totalBet,
|
||||
// Profit: u.SettleMsg.TotalWin,
|
||||
// Tax: u.SettleMsg.Tax,
|
||||
// Balance: u.Balance,
|
||||
// PreBalance: u.PreBalance,
|
||||
// UserWins: u.SettleMsg.UserWins, // 玩家赢取的下注区域总下注额
|
||||
// UserRealWins: u.SettleMsg.UserRealWins, // 玩家赢取的下注区域总下注额 扣税后
|
||||
// AreaOdds: copyBetAreaMul, // 投注区域赔率
|
||||
// StartTime: u.StartAt,
|
||||
// TransBet: u.TransBet,
|
||||
// TransWin: u.TransWin,
|
||||
// DevMode: u.UserInetr.GetDevMode(),
|
||||
// UserBetsCount: u.SettleMsg.UserBetsCount,
|
||||
// Nickname: u.UserInetr.GetNike(),
|
||||
// Avatar: u.UserInetr.GetHead(),
|
||||
// })
|
||||
// }
|
||||
// // log.Debug("开奖倍率:", u.SettleMsg.OddsWins)
|
||||
// }
|
||||
//
|
||||
// // u.ResetUserData()
|
||||
// return true
|
||||
// })
|
||||
// // rm.Table.GameBetInfo(gameBetInfos)
|
||||
// cou := model.Usercount{}
|
||||
// cou = rm.OnlineUserList
|
||||
// sort.Sort(cou)
|
||||
//
|
||||
// for key, v := range pb.ColorPinoyLiveBetTypeJP_value {
|
||||
// if rm.totalBets[v] > 0 || betTypePlayerCount[v] > 0 || RealSystemWins[v] > 0 {
|
||||
// log.Debug(rm.Log("%v 区域:总:%v 真:%v 真人数量:%v 真输赢:%v", key, score.GetScoreStr(rm.totalBets[v]), score.GetScoreStr(GameTotalBets[v]), betTypePlayerCount[v], score.GetScoreStr(rm.totalBets[v]-RealSystemWins[v])))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// str := fmt.Sprintf("开局结果 幸运骰子:%v :普通骰子:%v ,%v ,%v ,",
|
||||
// model.GetColorString(rm.LuckyDice), model.GetColorString(rm.NormalDices[0]), model.GetColorString(rm.NormalDices[1]), model.GetColorString(rm.NormalDices[2]))
|
||||
//
|
||||
// str += fmt.Sprintf("总押注:%v ", score.GetScoreStr(rm.totalBet))
|
||||
//
|
||||
// str += fmt.Sprintf("真人 总押注:%v , 系统输赢额度:%v ",
|
||||
// score.GetScoreStr(betCount),
|
||||
// score.GetScoreStr(RealSystemWin),
|
||||
// )
|
||||
//
|
||||
// str += fmt.Sprintf("最高获利用户ID:%v 获得:%v",
|
||||
// MaxWinUserID, score.GetScoreStr(MaxWinGold))
|
||||
//
|
||||
// log.Debug(rm.Log(str))
|
||||
// log.Debug(rm.Log("各区域投注:%v", rm.totalBets))
|
||||
// log.Debug(rm.Log("真人各区域投注:%v", GameTotalBets))
|
||||
// log.Debug(rm.Log("真人各区域中奖:%v", RealSystemWins))
|
||||
// log.Debug(rm.Log("中奖区域:%v", wins))
|
||||
//
|
||||
// // SceneSettleMsg.NoChairTotalWin = noChairTotalWin
|
||||
// // rm.Table.Broadcast(int32(pb.SendToClientMessageType_NoticeGameSettle), SceneSettleMsg)
|
||||
// rm.LiveMgr.RankList = &pb.ColorPinoyLiveRankList{
|
||||
// PlayerData: nil,
|
||||
// GameNo: rm.Table.GetGameRoundId(),
|
||||
// StartTime: rm.startAt,
|
||||
// EndTime: rm.endAt,
|
||||
// }
|
||||
//
|
||||
// // 发布事件
|
||||
// if PlayerData == nil || len(PlayerData) == 0 {
|
||||
// return
|
||||
// }
|
||||
// // 开奖结果
|
||||
// var threeDice []pb.ColorPinoyLiveDiceColorType
|
||||
// for _, dice := range rm.NormalDices {
|
||||
// threeDice = append(threeDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
//
|
||||
// var startDice []pb.ColorPinoyLiveDiceColorType
|
||||
// for _, dice := range rm.StartDices {
|
||||
// startDice = append(startDice, pb.ColorPinoyLiveDiceColorType(model.GetColor(dice)))
|
||||
// }
|
||||
//
|
||||
// gameDetail := &pb.ColorPinoyLiveDetail{
|
||||
// // LuckyDice: pb.ColorPinoyLiveDiceColorType(model.GetColor(rm.LuckyDice)),
|
||||
// ThreeDice: threeDice,
|
||||
// // Bonus: rm.RoomCfg.ColorPinoyLiveConfig.Bonus,
|
||||
// StartDice: startDice,
|
||||
// ResultImg: rm.ResultImgs,
|
||||
// DealerName: rm.dealerName,
|
||||
// BetAreaMul: copyBetAreaMul,
|
||||
// JackpotFunding: rm.jackpotFunding,
|
||||
// JackpotX: rm.jackpotX,
|
||||
// JackpotY: rm.jackpotY,
|
||||
// }
|
||||
//
|
||||
// gameRecordData := &pb.ColorPinoyLiveEnd{
|
||||
// GameNo: rm.Table.GetGameRoundId(),
|
||||
// StartTime: rm.startAt,
|
||||
// EndTime: rm.endAt,
|
||||
// Level: gconfig.GConfig.GRoomConfig.Level,
|
||||
// BaseBet: rm.RoomCfg.BaseBet,
|
||||
// PlayerData: PlayerData,
|
||||
// TaxRate: rm.RoomCfg.Rate,
|
||||
// totalBet: betCount,
|
||||
// totalBets: GameTotalBets[:],
|
||||
// RealSystemWin: RealSystemWin,
|
||||
// RealSystemWins: RealSystemWins[:],
|
||||
// Tax: SystemTax,
|
||||
// Wins: nil,
|
||||
// OpToken: gconfig.GConfig.GServConfig.ChannelId,
|
||||
// Detail: gameDetail,
|
||||
// }
|
||||
// for _, winArea := range rm.PokerMsg.WinBetArea {
|
||||
// gameRecordData.Wins = append(gameRecordData.Wins, winArea.BetArea)
|
||||
// }
|
||||
//
|
||||
// sort.Slice(PlayerData, func(i, j int) bool {
|
||||
// return PlayerData[i].Profit > PlayerData[j].Profit
|
||||
// })
|
||||
//
|
||||
// for i := 0; i < 6 && i < len(PlayerData); i++ {
|
||||
// if PlayerData[i].TransWin == 0 {
|
||||
// continue
|
||||
// }
|
||||
// rm.LiveMgr.RankList.PlayerData = append(rm.LiveMgr.RankList.PlayerData, PlayerData[i])
|
||||
// }
|
||||
// log.Debug(rm.Log("玩家数量:%v 赢家数量:%v", len(PlayerData), len(rm.LiveMgr.RankList.PlayerData)))
|
||||
// go func() {
|
||||
// // log.Debug("color game 游戏记录:", gameDetail)
|
||||
// // log.Debug("color game 游戏记录 Tax:", gameRecordData.Tax)
|
||||
// // log.Debug("color game 游戏记录 Wins:", gameRecordData.Wins)
|
||||
// // log.Debug("color game 游戏记录 PlayerData:", gameRecordData.PlayerData)
|
||||
// s, _ := json.Marshal(gameRecordData)
|
||||
// log.Debug(rm.Log("记录区域数据:%v", string(s)))
|
||||
// err := gconfig.Produce(context.Background(), define.TopicColoLiveGameGameEnd, gameRecordData)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log("[%s] fail to Produce TongitsGameEndEvent(%+v), err: %v", gameRecordData.GameNo, gameRecordData, err))
|
||||
// }
|
||||
// }()
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) SendOnlinePlayerNum() {
|
||||
// msg := new(pb.ColorPinoyLiveS2COnlinePlayerNum)
|
||||
// msg.Num = int64(len(rm.OnlineUserList))
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeOnlinePlayerNum), msg)
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) SendRoomInfo() {
|
||||
// // if rm.GetGameStatus() == 0 {
|
||||
// // return
|
||||
// // }
|
||||
// // msg := new(pb.UpdateRoomInfoMsg)
|
||||
// // msg.OnlineNum = int64(len(rm.OnlineUserList))
|
||||
// // rm.Table.Broadcast(int32(pb.SendToClientMessageType_NoticeUpdateRoomInfo), msg)
|
||||
// }
|
||||
//
|
||||
// // 广播主播名字
|
||||
// func (rm *ColorRoom) NotifyDealerName() {
|
||||
// msg := new(pb.ColorPinoyLiveDealerName)
|
||||
// msg.DealerName = rm.dealerName
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeDealerName), msg)
|
||||
// log.Debug(rm.Log("NotifyDealerName:%v", msg))
|
||||
// }
|
||||
//
|
||||
// type MulRangeW struct {
|
||||
// *game.ColorMulRate
|
||||
// MinW int // 权重转换成数值区间
|
||||
// MaxW int // 权重转换成数值区间
|
||||
// ColorPos pb.ColorPinoyLiveBigBetAreaPos // 0:单色区域基础倍率 1:单色区域双色倍率 2:单色区域开三色倍率 3:双色区域 4:三色区域
|
||||
// }
|
||||
//
|
||||
// // 带有权重信息的五行倍率数组(单色单,单色双,单色三,双色,三色倍率数组)
|
||||
// func (rm *ColorRoom) initMulRangeW() (mulRangeW [][]*MulRangeW) {
|
||||
// mulRangeW = make([][]*MulRangeW, 0, 5)
|
||||
//
|
||||
// for pos, mulWs := range rm.Cfg.WinSingleColorMul {
|
||||
// var single []*MulRangeW
|
||||
// for _, mul := range mulWs {
|
||||
// single = append(single, &MulRangeW{MulRate: mul, ColorPos: pb.ColorPinoyLiveBigBetAreaPos(pos)})
|
||||
// }
|
||||
// mulRangeW = append(mulRangeW, single)
|
||||
// }
|
||||
//
|
||||
// var double []*MulRangeW
|
||||
// for _, mul := range rm.Cfg.WinDoubleColorMul {
|
||||
// double = append(double, &MulRangeW{MulRate: mul, ColorPos: pb.ColorPinoyLiveBigBetAreaPos_BBA_Double})
|
||||
// }
|
||||
// mulRangeW = append(mulRangeW, double)
|
||||
//
|
||||
// var three []*MulRangeW
|
||||
// for _, mul := range rm.Cfg.WinThreeColorMul {
|
||||
// three = append(three, &MulRangeW{MulRate: mul, ColorPos: pb.ColorPinoyLiveBigBetAreaPos_BBA_Three})
|
||||
// }
|
||||
// mulRangeW = append(mulRangeW, three)
|
||||
//
|
||||
// for _, mulRws := range mulRangeW {
|
||||
// begin := 0
|
||||
// for _, v := range mulRws {
|
||||
// v.MinW = begin
|
||||
// v.MaxW = begin + v.Rate
|
||||
// begin += v.Rate
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return mulRangeW
|
||||
// }
|
||||
//
|
||||
// // 返回单色投注区爆奖的权重数组及是爆在双色还是三色位置
|
||||
// func (rm *ColorRoom) randSingle(cfg *config.ColorPinoyLiveConfig) (singleMul []*MulRangeW, singlePos int) {
|
||||
// maxWeight := 0
|
||||
// for _, w := range cfg.WinSingleColorWeight {
|
||||
// maxWeight += w
|
||||
// }
|
||||
// weight := rand.RandInt(0, maxWeight)
|
||||
// log.Debug(rm.Log("单色投注区获取爆奖在双色还是三色,随机值为:%v 最大值:%v", weight, maxWeight))
|
||||
// for pos, w := range cfg.WinSingleColorWeight {
|
||||
// if weight > w {
|
||||
// weight -= w
|
||||
// continue
|
||||
// }
|
||||
// log.Debug(rm.Log("单色投注区获取爆奖根据权重随机出来的爆奖位置为:%v", pos))
|
||||
// // 爆奖只会提高开出双色或三色的赔率,基础赔率区不会爆奖
|
||||
// if pos == 0 {
|
||||
// log.Debug(rm.Log("单色投注区的基础赔率区不会爆奖"))
|
||||
// return nil, pos
|
||||
// }
|
||||
// for _, mul := range cfg.WinSingleColorMul[pos] {
|
||||
// singleMul = append(singleMul, &MulRangeW{MulRate: mul, ColorPos: pb.ColorPinoyLiveBigBetAreaPos(pos)})
|
||||
// }
|
||||
// begin := 0
|
||||
// for _, v := range singleMul {
|
||||
// v.MinW = begin
|
||||
// v.MaxW = begin + v.Rate
|
||||
// begin += v.Rate
|
||||
// }
|
||||
// return singleMul, pos
|
||||
// }
|
||||
// return nil, 0
|
||||
// }
|
||||
//
|
||||
// // 更新
|
||||
// func (rm *ColorRoom) updateBetEndBetAreasOdds(mulRangeWs [][]*MulRangeW) {
|
||||
// for pos, betArea := range rm.betEndBetAreasOdds {
|
||||
// log.Debug(rm.Log("区域:%v 随机前 爆奖状态:%v", pb.ColorPinoyLiveBetTypeJP(pos), betArea.IsBigOdd))
|
||||
// betArea.IsBigOdd = false
|
||||
// // 区域位置 0-2分别为单色、双色、三色投注区域,
|
||||
// index := pos / 6
|
||||
// singlePos := 0
|
||||
// var mulRangeW []*MulRangeW
|
||||
// if index == 0 {
|
||||
// mulRangeW, singlePos = rm.randSingle(rm.Cfg)
|
||||
// } else {
|
||||
// mulRangeW = mulRangeWs[index+2]
|
||||
// }
|
||||
// if mulRangeW == nil {
|
||||
// log.Error(rm.Log("投注区域:%v 获取爆奖权重数组为nil", pos))
|
||||
// continue
|
||||
// }
|
||||
// rdv := rand.RandInt(mulRangeW[0].MinW, mulRangeW[len(mulRangeW)-1].MaxW)
|
||||
// for mulPos, mul := range mulRangeW {
|
||||
// if rdv < mul.MinW || rdv >= mul.MaxW {
|
||||
// continue
|
||||
// }
|
||||
// if index == 0 {
|
||||
// betArea.Odd[singlePos] = mul.Mul
|
||||
// if singlePos != 0 && mulPos != 0 {
|
||||
// log.Debug(rm.Log("区域:%v 爆奖位置:%v", pb.ColorPinoyLiveBetTypeJP(pos), mul.ColorPos))
|
||||
// betArea.IsBigOdd = true
|
||||
// }
|
||||
// } else {
|
||||
// betArea.Odd[0] = mul.Mul
|
||||
// if mulPos != 0 {
|
||||
// log.Debug(rm.Log("区域:%v 爆奖位置:%v", pb.ColorPinoyLiveBetTypeJP(pos), mul.ColorPos))
|
||||
// betArea.IsBigOdd = true
|
||||
// }
|
||||
// }
|
||||
// betArea.BigSingleColorOddPos = mul.ColorPos
|
||||
// break
|
||||
// }
|
||||
// log.Debug(rm.Log("区域:%v 爆奖权重区间:[%v,%v],随机数:%v betArea:%+v", pb.ColorPinoyLiveBetTypeJP(pos),
|
||||
// mulRangeW[0].MinW, mulRangeW[len(mulRangeW)-1].MaxW, rdv, betArea))
|
||||
// }
|
||||
// // 更新jackpot标记
|
||||
// _ = rm.randJackpotArea()
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) randJackpotArea() []pb.ColorPinoyLiveBetTypeJP {
|
||||
// betAreaInfo := make(map[int]*pb.ColorPinoyLiveGameBetAreaInfo)
|
||||
// for pos, betArea := range rm.betEndBetAreasOdds {
|
||||
// betAreaInfo[pos] = betArea
|
||||
// }
|
||||
// // 利用map的随机特性
|
||||
// for pos, betArea := range betAreaInfo {
|
||||
// // 区域位置 0-2分别为单色、双色、三色投注区域,
|
||||
// index := pos / 6
|
||||
// if index > 0 {
|
||||
// continue
|
||||
// }
|
||||
// _, singlePos := rm.randSingle(rm.Cfg)
|
||||
// // 在单色区域 命中三同色爆奖之后 再随jackpot概率
|
||||
// // 只会有一个区域有jackpot标签
|
||||
// if singlePos == 2 {
|
||||
// if rand.RandInt(0, 10000) < rm.Cfg.JackpotRate {
|
||||
// betArea.IsJackpot = true
|
||||
// return []pb.ColorPinoyLiveBetTypeJP{betArea.BetType}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
//
|
||||
// // 区域爆奖
|
||||
// func (rm *ColorRoom) NotifyBigBetAreaMul() {
|
||||
// mulRangeW := rm.initMulRangeW()
|
||||
// rm.updateBetEndBetAreasOdds(mulRangeW)
|
||||
//
|
||||
// for _, betArea := range rm.betEndBetAreasOdds {
|
||||
// log.Debug(rm.Log("投注区域:%v 倍率:%v 是否爆奖:%v 是否jackpot:%v 倍率位置:%v", betArea.BetType, betArea.Odd, betArea.IsBigOdd, betArea.IsJackpot, betArea.BigSingleColorOddPos))
|
||||
// }
|
||||
//
|
||||
// msg := new(pb.ColorPinoyLiveNtfBigOddBetArea)
|
||||
// msg.BetAreas = rm.betEndBetAreasOdds
|
||||
// rm.Table.Broadcast(int32(pb.ColorPinoyLiveSendToClientMessageType_ColorPinoyLiveNoticeBigOddBetArea), msg)
|
||||
// log.Debug(rm.Log("ColorPinoyLiveNtfBigOddBetArea:%v", msg))
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) formatScore(score int64) string {
|
||||
// s := float64(score / 100.0)
|
||||
// numStr := fmt.Sprintf("%.2f", s)
|
||||
//
|
||||
// // result := ""
|
||||
// // for i := len(numStr) - 1; i >= 0; i-- {
|
||||
// // result = string(numStr[i]) + result
|
||||
// // if (len(numStr)-i)%3 == 0 && i != 0 {
|
||||
// // result = "," + result
|
||||
// // }
|
||||
// // }
|
||||
// return numStr
|
||||
// // return result
|
||||
// }
|
||||
//
|
||||
// func (rm *ColorRoom) BroadHitJackpot(user *model.User, jpScore int64) {
|
||||
// go func() {
|
||||
// req := &fmsg.ChatReq{
|
||||
// Uid: user.UserID,
|
||||
// GameId: rm.RoomCfg.GameId,
|
||||
// Content: fmt.Sprintf("%v WIN ₱ %v FROM JACKPOT", user.UserInetr.GetNike(), rm.formatScore(jpScore)),
|
||||
// Type: 0,
|
||||
// }
|
||||
// bReq, err := proto.Marshal(req)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log(err.Error()))
|
||||
// return
|
||||
// }
|
||||
// lobbyMsg := &events.SingleMsgToLobbyEvent{
|
||||
// Module: events.SingleMsgToLobbyEvent_mtl_chat,
|
||||
// Data: bReq,
|
||||
// }
|
||||
// err = gconfig.Produce(context.Background(), define.TopicSingleMsgToLobby, lobbyMsg)
|
||||
// if err != nil {
|
||||
// log.Error(rm.Log("fail to Produce SingleMsgToLobbyEvent_mtl_chat, err: %v", err))
|
||||
// }
|
||||
// }()
|
||||
// }
|
||||
// 每秒更新各投注区域投注信息
|
||||
func (rm *ColorRoom) notifyKickoutUser(user *ColorPlayer, code pb.ErrCode) {
|
||||
rm.SendMsg(user, pb.MsgId_NtfKickOutUserId, &pb.NtfKickOutUser{Code: code})
|
||||
}
|
||||
|
||||
// 推送房间信息给玩家
|
||||
func (rm *ColorRoom) notifyColorRoomInfo(user *ColorPlayer) {
|
||||
ntf := &pb.NtfColorRoomInfo{
|
||||
Status: rm.status,
|
||||
EndTime: rm.endTimeStatus(),
|
||||
Config: rm.getUserRoomConfig(user),
|
||||
User: rm.getProtoUser(user),
|
||||
WaitStart: nil,
|
||||
Start: nil,
|
||||
Betting: nil,
|
||||
EndBet: nil,
|
||||
OpenThreeDice: nil,
|
||||
Settle: nil,
|
||||
}
|
||||
switch rm.status {
|
||||
case pb.ColorGameStatus_CGS_WaitStart:
|
||||
ntf.WaitStart = &pb.ColorRoomWaitStart{Trends: rm.getNotifyTrend()}
|
||||
case pb.ColorGameStatus_CGS_Start:
|
||||
ntf.Start = &pb.ColorRoomStart{
|
||||
Trends: rm.getNotifyTrend(),
|
||||
Start: &pb.NtfColorGameStart{
|
||||
EndTime: rm.endTimeStatus(),
|
||||
Jackpot: rm.jackpotValue,
|
||||
},
|
||||
}
|
||||
case pb.ColorGameStatus_CGS_Betting:
|
||||
ntf.Betting = &pb.ColorRoomBetting{
|
||||
BetAreaInfo: &pb.NtfColorBetAreaInfo{
|
||||
AreaInfos: rm.betAreaInfo,
|
||||
},
|
||||
}
|
||||
case pb.ColorGameStatus_CGS_BetEnd:
|
||||
ntf.EndBet = &pb.ColorRoomEndBet{
|
||||
AreaMul: &pb.NtfColorEndBetting{
|
||||
EndTime: rm.endTimeStatus(),
|
||||
Jackpot: rm.jackpotValue,
|
||||
AreaMul: rm.endBetAreaMul,
|
||||
},
|
||||
BetAreaInfo: &pb.NtfColorBetAreaInfo{
|
||||
AreaInfos: rm.betAreaInfo,
|
||||
},
|
||||
BigUser: &pb.NtfColorBigUser{BigUser: rm.bigUsers},
|
||||
}
|
||||
case pb.ColorGameStatus_CGS_OpenThreeDice:
|
||||
ntf.OpenThreeDice = &pb.ColorRoomOpenThreeDice{Dices: rm.ntfOpenThreeDice}
|
||||
case pb.ColorGameStatus_CGS_Settle:
|
||||
ntf.Settle = &pb.ColorRoomSettle{
|
||||
Settle: user.settleMsg,
|
||||
}
|
||||
}
|
||||
rm.SendMsg(user, pb.MsgId_NtfColorRoomInfoId, ntf)
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ func Stop() {
|
||||
func newColorService(serviceId int) service.IService {
|
||||
var err error
|
||||
s := new(ColorService)
|
||||
s.playerMgr = baseroom.NewPlayerMgr(&room.PlayerFactory{})
|
||||
s.playerMgr = baseroom.NewPlayerMgr(nil)
|
||||
factory := &room.RoomFactory{}
|
||||
s.room, _ = factory.CreateRoom(int(pb.ServiceTypeId_STI_ColorGame), 0, s)
|
||||
s.room, _ = factory.CreateRoom(int(pb.ServiceTypeId_STI_ColorGame), 0, s, s.playerMgr)
|
||||
s.status = baseroom.SsWorking
|
||||
//s.roomMgr = baseroom.NewRoomMgr(&room.RoomFactory{})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user