娃娃机下抓添加防卡死状态保护
This commit is contained in:
parent
418b16d2e9
commit
9d584a8647
|
@ -30,6 +30,8 @@ const (
|
||||||
ClawDollSceneBilledTimeout = time.Second * 2 //结算
|
ClawDollSceneBilledTimeout = time.Second * 2 //结算
|
||||||
ClawDollSceneWaitPayCoinimeout = time.Second * 10 //等待下一局投币
|
ClawDollSceneWaitPayCoinimeout = time.Second * 10 //等待下一局投币
|
||||||
|
|
||||||
|
ClawDollSceneGrapTimeOut = time.Second * 5 //下抓防卡死强制变状态倒计时
|
||||||
|
ClawDollScenePayCoinTimeOut = time.Second * 2 //投币防卡死强制变状态倒计时
|
||||||
)
|
)
|
||||||
|
|
||||||
// 玩家操作
|
// 玩家操作
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"mongo.games.com/game/protocol/machine"
|
"mongo.games.com/game/protocol/machine"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
"mongo.games.com/goserver/core/timer"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,8 +75,9 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data
|
||||||
|
|
||||||
switch msg.TypeId {
|
switch msg.TypeId {
|
||||||
case 1:
|
case 1:
|
||||||
|
logger.Logger.Tracef("ClawDoll OnPlayerOp payCoin response, SnId= %v", p.SnId)
|
||||||
if msg.Result == 1 {
|
if msg.Result == 1 {
|
||||||
logger.Logger.Tracef("上分成功!!!!!!!!!!!!snid = ", msg.Snid)
|
logger.Logger.Tracef("上分成功!!!!!!!!!!!!snid = %v", msg.Snid)
|
||||||
|
|
||||||
sceneEx.playingSnid = p.SnId
|
sceneEx.playingSnid = p.SnId
|
||||||
|
|
||||||
|
@ -91,22 +93,29 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data
|
||||||
ClawdollBroadcastPlayingInfo(s)
|
ClawdollBroadcastPlayingInfo(s)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Tracef("上分失败!!!!!!!!!!!!snid = ", msg.Snid)
|
logger.Logger.Tracef("上分失败!!!!!!!!!!!!snid = %v", msg.Snid)
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if msg.Result == 1 {
|
if msg.Result == 1 {
|
||||||
// 获得娃娃卡
|
// 获得娃娃卡
|
||||||
logger.Logger.Tracef("下抓成功!!!!!!!!!!!!snid = ", msg.Snid)
|
logger.Logger.Tracef("下抓成功!!!!!!!!!!!!snid = %v", msg.Snid)
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Tracef("下抓失败!!!!!!!!!!!!snid = ", msg.Snid)
|
logger.Logger.Tracef("下抓失败!!!!!!!!!!!!snid = %v", msg.Snid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Logger.Tracef("ClawDoll StatePlayGame OnPlayerOp Grab response, SnId= %v", msg.Snid)
|
||||||
|
|
||||||
s.ChangeSceneState(rule.ClawDollSceneStateBilled)
|
s.ChangeSceneState(rule.ClawDollSceneStateBilled)
|
||||||
sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled))
|
sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled))
|
||||||
|
|
||||||
ClawdollBroadcastRoomState(s)
|
ClawdollBroadcastRoomState(s)
|
||||||
ClawdollSendPlayerInfo(s)
|
ClawdollSendPlayerInfo(s)
|
||||||
|
|
||||||
|
if sceneEx.grabTimerHandle != timer.TimerHandle(0) {
|
||||||
|
timer.StopTimer(sceneEx.grabTimerHandle)
|
||||||
|
sceneEx.grabTimerHandle = timer.TimerHandle(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -66,6 +66,9 @@ type SceneEx struct {
|
||||||
machineId int //娃娃机ID
|
machineId int //娃娃机ID
|
||||||
machineConn *netlib.Session //娃娃机链接
|
machineConn *netlib.Session //娃娃机链接
|
||||||
machineStatus int32 //娃娃机链接状态 0:离线 1:在线
|
machineStatus int32 //娃娃机链接状态 0:离线 1:在线
|
||||||
|
|
||||||
|
payCoinTimeHandle timer.TimerHandle //上分投币托管handle
|
||||||
|
grabTimerHandle timer.TimerHandle //下抓托管handle
|
||||||
}
|
}
|
||||||
|
|
||||||
// 游戏是否能开始
|
// 游戏是否能开始
|
||||||
|
@ -392,6 +395,7 @@ func (this *SceneEx) TimeOutPlayGrab() bool {
|
||||||
if playerEx != nil {
|
if playerEx != nil {
|
||||||
grapType := this.GetPlayGrabType(playerEx)
|
grapType := this.GetPlayGrabType(playerEx)
|
||||||
this.OnPlayerSMGrabOp(this.playingSnid, int32(this.machineId), grapType)
|
this.OnPlayerSMGrabOp(this.playingSnid, int32(this.machineId), grapType)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -431,6 +435,34 @@ func (this *SceneEx) SendToMachine(pid int, msg interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 下抓托管handle
|
||||||
|
func (this *SceneEx) GrabTimerHandle() {
|
||||||
|
if this.grabTimerHandle != timer.TimerHandle(0) {
|
||||||
|
timer.StopTimer(this.grabTimerHandle)
|
||||||
|
this.grabTimerHandle = timer.TimerHandle(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.grabTimerHandle, _ = timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
||||||
|
|
||||||
|
logger.Logger.Tracef("ClawDoll SceneEx GrabTimerHandle: TimeOut: %v", rule.ClawDollSceneGrapTimeOut)
|
||||||
|
this.TimeOutPlayGrab()
|
||||||
|
return true
|
||||||
|
}), nil, rule.ClawDollSceneGrapTimeOut, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上分投币托管handle
|
||||||
|
func (this *SceneEx) PayCoinTimeHandle() {
|
||||||
|
if this.payCoinTimeHandle != timer.TimerHandle(0) {
|
||||||
|
timer.StopTimer(this.payCoinTimeHandle)
|
||||||
|
this.payCoinTimeHandle = timer.TimerHandle(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.payCoinTimeHandle, _ = timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
||||||
|
logger.Logger.Tracef("ClawDoll SceneEx PayCoinTimeHandle: TimeOut: %v", rule.ClawDollScenePayCoinTimeOut)
|
||||||
|
return true
|
||||||
|
}), nil, rule.ClawDollScenePayCoinTimeOut, 1)
|
||||||
|
}
|
||||||
|
|
||||||
// actionType : 1 禁止推流 ForbidRTCStream
|
// actionType : 1 禁止推流 ForbidRTCStream
|
||||||
// actionType : 2 恢复推流 ResumeRTCStream
|
// actionType : 2 恢复推流 ResumeRTCStream
|
||||||
func operateTask(sceneEx *SceneEx, times int, actionType int, platform string) {
|
func operateTask(sceneEx *SceneEx, times int, actionType int, platform string) {
|
||||||
|
|
|
@ -530,6 +530,8 @@ func (this *StateWait) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, par
|
||||||
// 1-前 2-后 3-左 4-右 5-投币
|
// 1-前 2-后 3-左 4-右 5-投币
|
||||||
sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), rule.ButtonPayCoin)
|
sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), rule.ButtonPayCoin)
|
||||||
|
|
||||||
|
logger.Logger.Trace("(ClawDoll this *StateWait) OnPlayerOp payCoin, sceneId=", s.GetSceneId(), " player=", p.SnId, " machineId=", sceneEx.machineId)
|
||||||
|
|
||||||
//sceneEx.OnPlayerSCOp(p, opcode, clawdoll.OpResultCode_OPRC_Success, params)
|
//sceneEx.OnPlayerSCOp(p, opcode, clawdoll.OpResultCode_OPRC_Success, params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,6 +577,8 @@ func (this *StateStart) OnTick(s *base.Scene) {
|
||||||
this.BaseState.OnTick(s)
|
this.BaseState.OnTick(s)
|
||||||
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
||||||
if time.Now().Sub(sceneEx.StateStartTime) > rule.ClawDollSceneStartTimeout {
|
if time.Now().Sub(sceneEx.StateStartTime) > rule.ClawDollSceneStartTimeout {
|
||||||
|
|
||||||
|
logger.Logger.Trace("ClawDoll StateStart OnTick ChangeSceneState:", rule.ClawDollSceneStatePlayGame)
|
||||||
//切换到等待操作状态
|
//切换到等待操作状态
|
||||||
s.ChangeSceneState(rule.ClawDollSceneStatePlayGame)
|
s.ChangeSceneState(rule.ClawDollSceneStatePlayGame)
|
||||||
sceneEx.SetPlayingState(int32(rule.ClawDollSceneStatePlayGame))
|
sceneEx.SetPlayingState(int32(rule.ClawDollSceneStatePlayGame))
|
||||||
|
@ -636,7 +640,7 @@ func (this *PlayGame) OnEnter(s *base.Scene) {
|
||||||
|
|
||||||
func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
||||||
|
|
||||||
logger.Logger.Trace("StatePlayGame OnPlayerOp-----SnId:", p.SnId, " opcode: ", opcode, " params:", params)
|
logger.Logger.Trace("ClawDoll StatePlayGame OnPlayerOp-----SnId:", p.SnId, " opcode: ", opcode, " params:", params)
|
||||||
|
|
||||||
if this.BaseState.OnPlayerOp(s, p, opcode, params) {
|
if this.BaseState.OnPlayerOp(s, p, opcode, params) {
|
||||||
return true
|
return true
|
||||||
|
@ -664,7 +668,7 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para
|
||||||
|
|
||||||
grapType := sceneEx.GetPlayGrabType(playerEx)
|
grapType := sceneEx.GetPlayGrabType(playerEx)
|
||||||
|
|
||||||
logger.Logger.Trace("StatePlayGame OnPlayerOp-----SnId:", p.SnId, " grapType: ", grapType)
|
logger.Logger.Trace("ClawDoll StatePlayGame OnPlayerOp Grab-----SnId:", p.SnId, " grapType: ", grapType)
|
||||||
//1-弱力抓 2 -强力抓
|
//1-弱力抓 2 -强力抓
|
||||||
sceneEx.OnPlayerSMGrabOp(p.SnId, int32(sceneEx.machineId), grapType)
|
sceneEx.OnPlayerSMGrabOp(p.SnId, int32(sceneEx.machineId), grapType)
|
||||||
|
|
||||||
|
@ -681,7 +685,7 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para
|
||||||
}
|
}
|
||||||
|
|
||||||
if params[0] < rule.ButtonFront || params[0] > rule.ButtonRight {
|
if params[0] < rule.ButtonFront || params[0] > rule.ButtonRight {
|
||||||
logger.Logger.Trace("StatePlayGame OnPlayerOp-----SnId:", p.SnId, " opcode: ", opcode, " params:", params)
|
logger.Logger.Trace("ClawDoll StatePlayGame OnPlayerOp-----SnId:", p.SnId, " opcode: ", opcode, " params:", params)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 1-前 2-后 3-左 4-右 5-投币
|
// 1-前 2-后 3-左 4-右 5-投币
|
||||||
|
@ -696,9 +700,11 @@ func (this *PlayGame) OnTick(s *base.Scene) {
|
||||||
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
||||||
if time.Now().Sub(sceneEx.StateStartTime) > rule.ClawDollScenePlayTimeout {
|
if time.Now().Sub(sceneEx.StateStartTime) > rule.ClawDollScenePlayTimeout {
|
||||||
|
|
||||||
if sceneEx.TimeOutPlayGrab() {
|
if sceneEx.Gaming && sceneEx.TimeOutPlayGrab() {
|
||||||
sceneEx.Gaming = false
|
sceneEx.Gaming = false
|
||||||
logger.Logger.Trace("PlayGame OnTick TimeOutPlayGrab SnId", sceneEx.playingSnid, " machineId:", sceneEx.machineId)
|
logger.Logger.Trace("PlayGame OnTick TimeOutPlayGrab SnId: ", sceneEx.playingSnid, " machineId:", sceneEx.machineId)
|
||||||
|
|
||||||
|
sceneEx.GrabTimerHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue