业务逻辑

This commit is contained in:
liuxiaobo 2025-06-09 19:10:18 +08:00
parent a70aa79e31
commit 774604644c
8 changed files with 540 additions and 343 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/fox/fox/log" "github.com/fox/fox/log"
"github.com/fox/fox/processor" "github.com/fox/fox/processor"
"github.com/fox/fox/service" "github.com/fox/fox/service"
"github.com/fox/fox/timer"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"time" "time"
) )
@ -18,9 +19,9 @@ type BaseRoom[Seat ISeat] struct {
gameNo string gameNo string
Seats []Seat Seats []Seat
processor *processor.Processor processor *processor.Processor
timeProcessor *processor.Processor timeProcessor *processor.TimerProcessor
timeTypes map[TimerType]uint32 timeTypes map[timer.ITimeType]uint32
srv service.IService srv service.IService
} }
@ -30,10 +31,10 @@ func NewBaseRoom[Seat ISeat](id, roomType, playType int, srv service.IService) (
roomType: roomType, roomType: roomType,
playType: playType, playType: playType,
gameNo: "", gameNo: "",
timeTypes: make(map[TimerType]uint32), timeTypes: make(map[timer.ITimeType]uint32),
srv: srv, srv: srv,
processor: processor.NewProcessor(), processor: processor.NewProcessor(),
timeProcessor: processor.NewProcessor(), timeProcessor: processor.NewTimerProcessor(),
} }
return room, pb.ErrCode_OK return room, pb.ErrCode_OK
@ -157,7 +158,7 @@ func (r *BaseRoom[Seat]) Broadcast(msgId pb.MsgId, msg proto.Message, exclude ..
} }
} }
func (r *BaseRoom[Seat]) NewTimer(timerType TimerType, duration time.Duration, args ...any) { func (r *BaseRoom[Seat]) NewTimer(timerType timer.ITimeType, duration time.Duration, args ...any) {
if _, ok := r.timeTypes[timerType]; ok { if _, ok := r.timeTypes[timerType]; ok {
log.Error(r.Log("timer type:%v is exist.can not new timer", timerType.String())) log.Error(r.Log("timer type:%v is exist.can not new timer", timerType.String()))
// if timerType == TtPlayerAct { // if timerType == TtPlayerAct {
@ -166,7 +167,7 @@ func (r *BaseRoom[Seat]) NewTimer(timerType TimerType, duration time.Duration, a
return return
} }
tid := r.srv.NewTimer(duration+time.Duration(10)*time.Millisecond, func() { tid := r.srv.NewTimer(duration+time.Duration(10)*time.Millisecond, func() {
if err := r.timeProcessor.Dispatch(int32(timerType), args...); err != nil { if err := r.timeProcessor.Dispatch(timerType, args...); err != nil {
log.ErrorF(r.Log("timer dispatch err:%v", err)) log.ErrorF(r.Log("timer dispatch err:%v", err))
} }
}, true, r.Log("start type:%v timer", timerType.String())) }, true, r.Log("start type:%v timer", timerType.String()))
@ -174,7 +175,7 @@ func (r *BaseRoom[Seat]) NewTimer(timerType TimerType, duration time.Duration, a
// log.Debug(r.Log("start type:%v timer", timerType.String())) // log.Debug(r.Log("start type:%v timer", timerType.String()))
} }
func (r *BaseRoom[Seat]) CancelTimer(timerType TimerType) { func (r *BaseRoom[Seat]) CancelTimer(timerType timer.ITimeType) {
if tid, ok := r.timeTypes[timerType]; ok { if tid, ok := r.timeTypes[timerType]; ok {
r.srv.CancelTimer(tid) r.srv.CancelTimer(tid)
delete(r.timeTypes, timerType) delete(r.timeTypes, timerType)
@ -187,7 +188,7 @@ func (r *BaseRoom[Seat]) CancelAllTimer() {
r.srv.CancelTimer(tid) r.srv.CancelTimer(tid)
// log.Debug(r.Log("start type:%v timer", timerType.String())) // log.Debug(r.Log("start type:%v timer", timerType.String()))
} }
r.timeTypes = make(map[TimerType]uint32) r.timeTypes = make(map[timer.ITimeType]uint32)
} }
func (r *BaseRoom[Seat]) Log(format string, a ...any) string { func (r *BaseRoom[Seat]) Log(format string, a ...any) string {
@ -238,7 +239,7 @@ func (r *BaseRoom[Seat]) RegisterMessages(metas processor.RegisterMetas) {
r.processor.RegisterMessages(metas) r.processor.RegisterMessages(metas)
} }
func (r *BaseRoom[Seat]) timerDispatch(user IPlayer, cmd int32, params ...any) error { func (r *BaseRoom[Seat]) timerDispatch(user IPlayer, cmd timer.ITimeType, params ...any) error {
inp := make([]any, len(params)+1) inp := make([]any, len(params)+1)
inp = append(inp, user) inp = append(inp, user)
inp = append(inp, params...) inp = append(inp, params...)
@ -246,7 +247,7 @@ func (r *BaseRoom[Seat]) timerDispatch(user IPlayer, cmd int32, params ...any) e
} }
// 注册时间事件及处理 // 注册时间事件及处理
func (r *BaseRoom[Seat]) RegisterTimerMessages(metas processor.RegisterMetas) { func (r *BaseRoom[Seat]) RegisterTimerMessages(metas processor.RegisterTimerMetas) {
r.timeProcessor.RegisterMessages(metas) r.timeProcessor.RegisterMessages(metas)
} }

View File

@ -1,55 +0,0 @@
package baseroom
type TimerType int
const (
TtUnknown TimerType = 0
TtDealPoker TimerType = 200 // 发牌结束后通知玩家行动
TtDecidingGame TimerType = 201 // 决胜局展示手牌及同意,放弃行动
TtPlayerAct TimerType = 202 // 玩家行动
TtPlayerRspRaise TimerType = 204 // 玩家回应行动
TtCmpPoker TimerType = 205 // 比牌
TtNextGame TimerType = 208 // 下一小局
// TtGameEnd TimerType = 205 // 大局结束,询问玩家是否继续
// TtContinue TimerType = 206 // 继续
TtSecond TimerType = 220 // 每秒定时器
TtGameReadyStart TimerType = 221 // 游戏开始倒计时
TtEnterRoom TimerType = 222
// TtEmote TimerType = 223 // 发送表情
TtPlayerCutLine TimerType = 401 // 插队
TtDelDisbandRoomInfo TimerType = 402 // 删除解散房间投票
)
func (t TimerType) String() string {
switch t {
case TtUnknown:
return "unknown"
case TtDealPoker:
return "TtDealPoker"
case TtDecidingGame:
return "TtDecidingGame"
case TtPlayerAct:
return "TtPlayerAct"
case TtPlayerRspRaise:
return "TtPlayerRspRaise"
case TtCmpPoker:
return "TtCmpPoker"
case TtNextGame:
return "TtNextGame"
case TtPlayerCutLine:
return "TtPlayerCutLine"
// case TtContinue:
// return "TtContinue"
case TtSecond:
return "TtSecond"
case TtGameReadyStart:
return "TtGameReadyStart"
case TtDelDisbandRoomInfo:
return "TtDelDisbandRoomInfo"
case TtEnterRoom:
return "TtEnterRoom"
}
return ""
}

View File

@ -11,6 +11,11 @@ import (
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
) )
const (
Hundred = 100 // 放大100倍
RateBase = 10000 // 概率或者权重的底数是1万
)
var Command *config.Command var Command *config.Command
var Cfg *config.Common[game.ColorConfig] var Cfg *config.Common[game.ColorConfig]
@ -56,27 +61,26 @@ func LoadColorConfig(rdb *redis.Client) {
WinSingleColorWeight := [3]int{50, 25, 25} WinSingleColorWeight := [3]int{50, 25, 25}
WinSingleColorMul := [3][]*game.ColorMulRate{ WinSingleColorMul := [3][]*game.ColorMulRate{
{{Mul: 0.6 * 100, Rate: 75 * 100}, {Mul: 1 * 100, Rate: 12 * 100}, {{Mul: 1 * Hundred, Rate: 100 * Hundred}},
{Mul: 1.5 * 100, Rate: 7.5 * 100}, {Mul: 2 * 100, Rate: 5.5 * 100}},
{{Mul: 2 * 100, Rate: 82.5 * 100}, {Mul: 3 * 100, Rate: 4 * 100}, {{Mul: 2 * Hundred, Rate: 82.5 * Hundred}, {Mul: 3 * Hundred, Rate: 4 * Hundred},
{Mul: 4 * 100, Rate: 3.5 * 100}, {Mul: 5 * 100, Rate: 3.2 * 100}, {Mul: 4 * Hundred, Rate: 3.5 * Hundred}, {Mul: 5 * Hundred, Rate: 3.2 * Hundred},
{Mul: 6 * 100, Rate: 230}, {Mul: 7 * 100, Rate: 1.8 * 100}, {Mul: 6 * Hundred, Rate: 230}, {Mul: 7 * Hundred, Rate: 1.8 * Hundred},
{Mul: 8 * 100, Rate: 1.5 * 100}, {Mul: 9 * 100, Rate: 1.2 * 100}}, {Mul: 8 * Hundred, Rate: 1.5 * Hundred}, {Mul: 9 * Hundred, Rate: 1.2 * Hundred}},
{{Mul: 3 * 100, Rate: 94 * 100}, {Mul: 9 * 100, Rate: 1.4 * 100}, {{Mul: 3 * Hundred, Rate: 94 * Hundred}, {Mul: 9 * Hundred, Rate: 1.4 * Hundred},
{Mul: 14 * 100, Rate: 110}, {Mul: 19 * 100, Rate: 0.9 * 100}, {Mul: 14 * Hundred, Rate: 110}, {Mul: 19 * Hundred, Rate: 0.9 * Hundred},
{Mul: 29 * 100, Rate: 0.8 * 100}, {Mul: 49 * 100, Rate: 0.7 * 100}, {Mul: 29 * Hundred, Rate: 0.8 * Hundred}, {Mul: 49 * Hundred, Rate: 0.7 * Hundred},
{Mul: 99 * 100, Rate: 0.6 * 100}, {Mul: 9 * 100, Rate: 0.5 * 100}}, {Mul: 99 * Hundred, Rate: 0.6 * Hundred}, {Mul: 9 * Hundred, Rate: 0.5 * Hundred}},
} }
WinDoubleColorMul := []*game.ColorMulRate{{Mul: 8 * 100, Rate: 66 * 100}, {Mul: 11 * 100, Rate: 17 * 100}, WinDoubleColorMul := []*game.ColorMulRate{{Mul: 8 * Hundred, Rate: 66 * Hundred}, {Mul: 11 * Hundred, Rate: 17 * Hundred},
{Mul: 14 * 100, Rate: 9 * 100}, {Mul: 19 * 100, Rate: 3.5 * 100}, {Mul: 14 * Hundred, Rate: 9 * Hundred}, {Mul: 19 * Hundred, Rate: 3.5 * Hundred},
{Mul: 24 * 100, Rate: 1.9 * 100}, {Mul: 54 * 100, Rate: 1.5 * 100}, {Mul: 24 * Hundred, Rate: 1.9 * Hundred}, {Mul: 54 * Hundred, Rate: 1.5 * Hundred},
{Mul: 74 * 100, Rate: 1.05 * 100}, {Mul: 99 * 100, Rate: 0.05 * 100}} {Mul: 74 * Hundred, Rate: 1.05 * Hundred}, {Mul: 99 * Hundred, Rate: 0.05 * Hundred}}
WinThreeColorMul := []*game.ColorMulRate{{Mul: 150 * 100, Rate: 84.5 * 100}, {Mul: 199 * 100, Rate: 5.5 * 100}, WinThreeColorMul := []*game.ColorMulRate{{Mul: 150 * Hundred, Rate: 84.5 * Hundred}, {Mul: 199 * Hundred, Rate: 5.5 * Hundred},
{Mul: 299 * 100, Rate: 4 * 100}, {Mul: 599 * 100, Rate: 3 * 100}, {Mul: 299 * Hundred, Rate: 4 * Hundred}, {Mul: 599 * Hundred, Rate: 3 * Hundred},
{Mul: 799 * 100, Rate: 2 * 100}, {Mul: 999 * 100, Rate: 1 * 100}} {Mul: 799 * Hundred, Rate: 2 * Hundred}, {Mul: 999 * Hundred, Rate: 1 * Hundred}}
rmConfig := &game.ColorRoomConfig{ rmConfig := &game.ColorRoomConfig{
BetList: [][]int64{ BetList: [][]int64{
@ -89,27 +93,14 @@ func LoadColorConfig(rdb *redis.Client) {
WinSingleColorMul: WinSingleColorMul[:], WinSingleColorMul: WinSingleColorMul[:],
WinDoubleColorMul: WinDoubleColorMul, WinDoubleColorMul: WinDoubleColorMul,
WinThreeColorMul: WinThreeColorMul, WinThreeColorMul: WinThreeColorMul,
InitJackpot: 2000000 * 100, InitJackpot: 2000000 * Hundred,
JackpotRate: 0.05 * 100, JackpotRate: 0.05 * Hundred,
JpXRate: 2 * 100, JpXRate: 2 * Hundred,
JpYRate: 1 * 100, JpYRate: 1 * Hundred,
JpXYRate: 1.5 * 100, JpXYRate: 1.5 * Hundred,
AreaBetLimit: 500000, AreaBetLimit: 500000,
NoBetCountMax: 10, NoBetCountMax: 10,
OpenRobot: false,
OneCreateMin: 3,
OneCreateMax: 5,
UserAddRobotNum: 80,
UserAddRobotNumMax: 100,
OneDeleteNum: 1,
BalanceMinDelete: 4000,
BalanceMin: 100000,
BalanceMax: 500000,
RobotCreateTime: 8000,
RobotDeleteTime: 5000,
RobotBetNumMin: 2,
RobotBetNumMax: 4,
} }
Cfg.Special.Rooms = append(Cfg.Special.Rooms, rmConfig) Cfg.Special.Rooms = append(Cfg.Special.Rooms, rmConfig)

View File

@ -2,19 +2,22 @@ package room
import ( import (
"game/common/baseroom" "game/common/baseroom"
"game/common/config/game"
"game/common/proto/pb" "game/common/proto/pb"
"github.com/fox/fox/log" "github.com/fox/fox/log"
"github.com/fox/fox/processor" "github.com/fox/fox/processor"
"github.com/fox/fox/service" "github.com/fox/fox/service"
) )
const (
BET_TYPE_NUM = 18
)
type ColorRoom struct { type ColorRoom struct {
*baseroom.BaseRoom[ColorSeat] *baseroom.BaseRoom[ColorSeat]
roomCfg game.ColorRoomConfig
timingCfg game.ColorGameTiming
status pb.ColorGameStatus
statusTime int64 // 毫秒时间戳
jackpot int64
endBetAreaMul []*pb.ColorBetAreaMul // 下注结束后,每个区域更新是否爆奖以及实际赔率
// --------------------------------- // ---------------------------------
// Status pb.ColorPinoyLiveGameStatus // 房间状态1 表示 // Status pb.ColorPinoyLiveGameStatus // 房间状态1 表示
// StatusTime int64 // 切换状态时的时间戳 // StatusTime int64 // 切换状态时的时间戳
@ -51,7 +54,16 @@ type ColorRoom struct {
} }
func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.ErrCode) { func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.ErrCode) {
rm := &ColorRoom{} rm := &ColorRoom{
BaseRoom: nil,
roomCfg: game.ColorRoomConfig{},
timingCfg: game.ColorGameTiming{},
status: 0,
statusTime: 0,
jackpot: 0,
endBetAreaMul: make([]*pb.ColorBetAreaMul, 0, len(pb.ColorBetArea_name)),
}
playType := 0 playType := 0
code := pb.ErrCode_OK code := pb.ErrCode_OK
rm.BaseRoom, code = baseroom.NewBaseRoom[ColorSeat](id, roomType, playType, srv) rm.BaseRoom, code = baseroom.NewBaseRoom[ColorSeat](id, roomType, playType, srv)
@ -65,8 +77,17 @@ func newColorRoom(id, roomType int, srv service.IService) (baseroom.IRoom, pb.Er
func (rm *ColorRoom) OnInit() { func (rm *ColorRoom) OnInit() {
rm.RegisterMessages(processor.RegisterMetas{ rm.RegisterMessages(processor.RegisterMetas{
pb.MsgId_C2SMatchRoomId: {pb.C2SMatchRoom{}, rm.OnEnterRoom}, pb.MsgId_ReqMatchRoomId: {pb.ReqMatchRoom{}, rm.OnEnterRoom},
}) })
rm.RegisterTimerMessages(processor.RegisterTimerMetas{
TtGameStart: rm.gameStart,
TtStartBetting: rm.startBetting,
TtEndBet: rm.endBetting,
TtOpenThreeDices: rm.openThreeDices,
TtSettle: rm.settle,
})
rm.gameStart()
return return
} }

View File

@ -1,5 +1,129 @@
package room package room
import (
"game/common/config/game"
"game/common/proto/pb"
"github.com/fox/fox/log"
"github.com/fox/fox/xrand"
"github.com/fox/fox/xtime"
)
func (rm *ColorRoom) setStatus(status pb.ColorGameStatus) {
rm.status = status
rm.statusTime = xtime.Now().TimestampMilli()
}
// 状态结束时间点,毫秒
func (rm *ColorRoom) endTimeStatus() int64 {
duration := int64(0)
switch rm.status {
case pb.ColorGameStatus_CGS_Start:
duration = rm.timingCfg.Start
case pb.ColorGameStatus_CGS_Betting:
duration = rm.timingCfg.Betting
case pb.ColorGameStatus_CGS_BetEnd:
duration = rm.timingCfg.EndBetting
case pb.ColorGameStatus_CGS_OpenThreeDice:
duration = rm.timingCfg.OpenThreeDice
case pb.ColorGameStatus_CGS_Settle:
duration = rm.timingCfg.Settle
}
return rm.statusTime + duration
}
// 游戏开始时展示每个区域的默认赔率
func (rm *ColorRoom) initEndBetAreaMul() {
rm.endBetAreaMul = rm.endBetAreaMul[0:0]
for pos := 0; pos < len(pb.ColorBetArea_name); pos++ {
prizeArea := pb.ColorPrizeArea_CPA_Single_0
var mul = rm.roomCfg.WinSingleColorMul[0]
switch pos / 6 {
case 1:
prizeArea = pb.ColorPrizeArea_CPA_Double
mul = rm.roomCfg.WinDoubleColorMul
case 2:
prizeArea = pb.ColorPrizeArea_CPA_Three
mul = rm.roomCfg.WinThreeColorMul
}
rm.endBetAreaMul = append(rm.endBetAreaMul, &pb.ColorBetAreaMul{
Area: pb.ColorBetArea(pos),
PrizeArea: prizeArea,
PrizeType: pb.ColorPrizeType_CPT_Normal,
Mul: mul[0].Mul,
})
}
}
// 随机出某个奖励档位下的赔率数组,档位,赔率数组概率之和
func (rm *ColorRoom) randArrMul(area pb.ColorBetArea) (singleMul []*game.ColorMulRate, prizeArea pb.ColorPrizeArea, sumRate int) {
switch area / 6 {
case 0:
maxWeight := 0
for _, w := range rm.roomCfg.WinSingleColorWeight {
maxWeight += w
}
weight := xrand.RandRange[int](0, maxWeight)
case 1:
case 2:
default:
log.Error("area:%v is not exist")
return
}
// log.Debug(rm.Log("单色投注区获取爆奖在双色还是三色,随机值为:%v 最大值:%v", weight, maxWeight))
return nil, 0
}
// 下注结束后,更新每个区域的实际赔率
func (rm *ColorRoom) updateEndBetAreaMul() {
for pos, _ := range pb.ColorBetArea_name {
}
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))
}
}
// //
// import ( // import (
// "encoding/json" // "encoding/json"

View File

@ -1,5 +1,41 @@
package room package room
import (
"game/common/proto/pb"
"time"
)
func (rm *ColorRoom) gameStart() {
rm.setStatus(pb.ColorGameStatus_CGS_Start)
rm.notifyGameStart()
rm.NewTimer(TtStartBetting, time.Duration(rm.timingCfg.Start)*time.Millisecond)
}
func (rm *ColorRoom) startBetting() {
rm.setStatus(pb.ColorGameStatus_CGS_Betting)
rm.notifyBetting()
rm.NewTimer(TtEndBet, time.Duration(rm.timingCfg.Betting)*time.Millisecond)
}
func (rm *ColorRoom) endBetting() {
rm.setStatus(pb.ColorGameStatus_CGS_BetEnd)
rm.updateEndBetAreaMul()
rm.notifyEndBetting()
rm.NewTimer(TtOpenThreeDices, time.Duration(rm.timingCfg.EndBetting)*time.Millisecond)
}
func (rm *ColorRoom) openThreeDices() {
rm.setStatus(pb.ColorGameStatus_CGS_OpenThreeDice)
rm.notifyOpenThreeDice()
rm.NewTimer(TtSettle, time.Duration(rm.timingCfg.OpenThreeDice)*time.Millisecond)
}
func (rm *ColorRoom) settle() {
rm.setStatus(pb.ColorGameStatus_CGS_Settle)
rm.notifySettle()
rm.NewTimer(TtGameStart, time.Duration(rm.timingCfg.Settle)*time.Millisecond)
}
// //
// import ( // import (
// "encoding/json" // "encoding/json"

View File

@ -1,5 +1,45 @@
package room package room
import "game/common/proto/pb"
func (rm *ColorRoom) notifyGameStart() {
ntf := &pb.NtfColorGameStart{
EndTime: rm.endTimeStatus(),
Jackpot: rm.jackpot,
}
rm.Broadcast(pb.MsgId_NtfColorGameStartId, ntf)
}
func (rm *ColorRoom) notifyBetting() {
ntf := &pb.NtfColorBetting{EndTime: rm.endTimeStatus()}
rm.Broadcast(pb.MsgId_NtfColorBettingId, ntf)
}
func (rm *ColorRoom) notifyEndBetting() {
ntf := &pb.NtfColorEndBetting{
EndTime: rm.endTimeStatus(),
AreaMul: rm.endBetAreaMul,
Jackpot: rm.jackpot,
}
rm.Broadcast(pb.MsgId_NtfColorEndBettingId, ntf)
}
func (rm *ColorRoom) notifyOpenThreeDice() {
ntf := &pb.NtfColorEndBetting{
// EndTime: rm.statusTime + rm.timingCfg.Start,
// Jackpot: 0,
}
rm.Broadcast(pb.MsgId_NtfColorOpenThreeDiceId, ntf)
}
func (rm *ColorRoom) notifySettle() {
ntf := &pb.NtfColorEndBetting{
// EndTime: rm.statusTime + rm.timingCfg.Start,
// Jackpot: 0,
}
rm.Broadcast(pb.MsgId_NtfColorOpenThreeDiceId, ntf)
}
// //
// import ( // import (
// "encoding/json" // "encoding/json"

View File

@ -0,0 +1,39 @@
package room
type TimerType int
const (
TtSecond TimerType = 5 // 每秒定时器
TtGameStart TimerType = 300
TtStartBetting TimerType = 305
TtEndBet TimerType = 310
TtOpenThreeDices TimerType = 315
TtSettle TimerType = 320
TtGameEnd TimerType = 325
)
func (t TimerType) Number() int32 {
return int32(t)
}
func (t TimerType) String() string {
switch t {
case TtSecond:
return "TtSecond"
case TtGameStart:
return "TtGameStart"
case TtStartBetting:
return "TtStartBetting"
case TtEndBet:
return "TtEndBet"
case TtOpenThreeDices:
return "TtOpenThreeDices"
case TtSettle:
return "TtSettle"
case TtGameEnd:
return "TtGameEnd"
}
return "unknown"
}