169 lines
5.4 KiB
Go
169 lines
5.4 KiB
Go
package room
|
|
|
|
import (
|
|
"game/common/proto/pb"
|
|
"time"
|
|
)
|
|
|
|
func (rm *ColorRoom) gameStart() {
|
|
rm.setStatus(pb.ColorGameStatus_CGS_Start)
|
|
rm.resetGameData()
|
|
rm.notifyGameStart()
|
|
rm.NewTimer(TtStartBetting, time.Duration(rm.timingCfg.Start)*time.Millisecond)
|
|
}
|
|
|
|
func (rm *ColorRoom) gameStartBetting() {
|
|
rm.setStatus(pb.ColorGameStatus_CGS_Betting)
|
|
rm.notifyBetting()
|
|
rm.NewTimer(TtEndBet, time.Duration(rm.timingCfg.Betting)*time.Millisecond)
|
|
rm.NewTimer(TtSecond, time.Second)
|
|
}
|
|
|
|
func (rm *ColorRoom) gameEndBetting() {
|
|
rm.setStatus(pb.ColorGameStatus_CGS_BetEnd)
|
|
rm.updateEndBetAreaMul()
|
|
rm.notifyEndBetting()
|
|
rm.NewTimer(TtOpenThreeDices, time.Duration(rm.timingCfg.EndBetting)*time.Millisecond)
|
|
}
|
|
|
|
func (rm *ColorRoom) gameOpenThreeDices() {
|
|
rm.setStatus(pb.ColorGameStatus_CGS_OpenThreeDice)
|
|
rm.openDices()
|
|
rm.notifyOpenThreeDice()
|
|
rm.NewTimer(TtSettle, time.Duration(rm.timingCfg.OpenThreeDice)*time.Millisecond)
|
|
}
|
|
|
|
func (rm *ColorRoom) gameSettle() {
|
|
rm.setStatus(pb.ColorGameStatus_CGS_Settle)
|
|
rm.settle()
|
|
rm.notifySettle()
|
|
rm.updateGameTrend()
|
|
rm.notifyTrend()
|
|
rm.NewTimer(TtGameStart, time.Duration(rm.timingCfg.Settle)*time.Millisecond)
|
|
}
|
|
|
|
// 每秒定时器干的活
|
|
func (rm *ColorRoom) onSecond() {
|
|
rm.notifyColorBetAreaInfo()
|
|
if rm.status < pb.ColorGameStatus_CGS_BetEnd {
|
|
rm.NewTimer(TtGameStart, time.Second)
|
|
}
|
|
}
|
|
|
|
//
|
|
// import (
|
|
// "encoding/json"
|
|
// "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()
|
|
// }
|