From 8f59f4d03acf37db5e2df8464a684f3c2205d016 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 09:41:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E6=8A=93?= =?UTF-8?q?=E5=8F=96=E5=90=8E=E7=BB=93=E6=9E=9C=E9=80=9A=E7=9F=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamerule/clawdoll/constants.go | 4 ++++ gamesrv/clawdoll/action_clawdoll.go | 24 +++++++++++++++++++++--- gamesrv/clawdoll/player_clawdoll.go | 24 +++++++++++++++++++++++- gamesrv/clawdoll/scenepolicy_clawdoll.go | 12 +----------- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/gamerule/clawdoll/constants.go b/gamerule/clawdoll/constants.go index e855368..8c0386f 100644 --- a/gamerule/clawdoll/constants.go +++ b/gamerule/clawdoll/constants.go @@ -71,3 +71,7 @@ const ( Zego_ForbidRTCStream = iota + 1 Zego_ResumeRTCStream = iota + 1 ) + +const ( + ClawDoorItemID = 40003 +) diff --git a/gamesrv/clawdoll/action_clawdoll.go b/gamesrv/clawdoll/action_clawdoll.go index bd83ddc..9affeb7 100644 --- a/gamesrv/clawdoll/action_clawdoll.go +++ b/gamesrv/clawdoll/action_clawdoll.go @@ -2,6 +2,7 @@ package clawdoll import ( "mongo.games.com/game/common" + rule "mongo.games.com/game/gamerule/clawdoll" "mongo.games.com/game/gamesrv/base" "mongo.games.com/game/protocol/clawdoll" "mongo.games.com/game/protocol/machine" @@ -52,10 +53,20 @@ func (h *CSPlayerOpHandler) Process(s *netlib.Session, packetid int, data interf func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data interface{}) error { logger.Logger.Tracef("收到返回上分结果!!!!!!!!!!") if msg, ok := data.(*machine.MSDollMachineoPerateResult); ok { - p := base.PlayerMgrSington.GetPlayerBySnId(msg.GetSnid()) if p == nil { - logger.Logger.Warn("CSGetTokenHandler p == nil") + logger.Logger.Warn("MSDollMachineoCoinResultHandler p == nil") + return nil + } + + s := p.GetScene() + if s == nil { + logger.Logger.Warn("MSDollMachineoCoinResultHandler p.scene == nil") + return nil + } + + sceneEx, ok := s.ExtraData.(*SceneEx) + if !ok { return nil } @@ -68,10 +79,17 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data } case 2: if msg.Result == 1 { - + // 获得娃娃卡 + logger.Logger.Tracef("下抓成功!!!!!!!!!!!!snid = ", msg.Snid) } else { logger.Logger.Tracef("下抓失败!!!!!!!!!!!!snid = ", msg.Snid) } + + s.ChangeSceneState(rule.ClawDollSceneStateBilled) + sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) + + ClawdollBroadcastRoomState(s) + ClawdollSendPlayerInfo(s) } } return nil diff --git a/gamesrv/clawdoll/player_clawdoll.go b/gamesrv/clawdoll/player_clawdoll.go index 2fb434e..3dd7af7 100644 --- a/gamesrv/clawdoll/player_clawdoll.go +++ b/gamesrv/clawdoll/player_clawdoll.go @@ -1,7 +1,9 @@ package clawdoll import ( + rule "mongo.games.com/game/gamerule/clawdoll" "mongo.games.com/game/gamesrv/base" + "mongo.games.com/game/srvdata" "mongo.games.com/goserver/core/logger" ) @@ -37,11 +39,18 @@ func (this *PlayerEx) CanOp(sceneEx *SceneEx) bool { // 能否投币 func (this *PlayerEx) CanPayCoin() bool { + + itemID := int32(rule.ClawDoorItemID) + itemData := srvdata.GameItemMgr.Get(this.Platform, itemID) + if itemData == nil { + return false + } + return true } // 投币消耗 -func (this *PlayerEx) CostPlayCoin() bool { +func (this *PlayerEx) CostPlayCoin(count int32) bool { return true } @@ -106,3 +115,16 @@ func (this *PlayerEx) GetClawState() int32 { func (this *PlayerEx) SetClawState(state int32) { this.clawDollState = state } + +func (this *PlayerEx) GetItemCount(itemID int32) int64 { + itemData := srvdata.GameItemMgr.Get(this.Platform, itemID) + if itemData != nil { + v, ok := this.Items[itemID] + if ok { + return v + } else { + return 0 + } + } + return 0 +} diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index f00ad1f..664e238 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -67,6 +67,7 @@ func (this *PolicyClawdoll) OnTick(s *base.Scene) { sceneEx, ok := s.ExtraData.(*SceneEx) if ok { if sceneEx.machineId == 0 { + //machineId := s.DBGameFree.GetId() % 6080000 sceneEx.machineId = action.GetFreeDollMachineId() } if sceneEx.machineId != 0 { @@ -666,12 +667,6 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para //1-弱力抓 2 -强力抓 sceneEx.OnPlayerSMGrabOp(p.SnId, int32(sceneEx.machineId), grapType) - s.ChangeSceneState(rule.ClawDollSceneStateBilled) - sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) - - ClawdollBroadcastRoomState(s) - ClawdollSendPlayerInfo(s) - case rule.ClawDollPlayerOpMove: if !sceneEx.CheckMoveOp(playerEx) { @@ -702,11 +697,6 @@ func (this *PlayGame) OnTick(s *base.Scene) { logger.Logger.Trace("PlayGame OnTick TimeOutPlayGrab SnId", sceneEx.playingSnid, " machineId:", sceneEx.machineId) } - s.ChangeSceneState(rule.ClawDollSceneStateBilled) - sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) - - ClawdollBroadcastRoomState(s) - ClawdollSendPlayerInfo(s) return } } From 9963ef130ae66f4707afa64c2156ca8c9497f599 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 09:43:14 +0800 Subject: [PATCH 2/3] public --- public | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public b/public index 06da9b3..00b9fce 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit 06da9b31abec96f3936877d7d73069e9852781ff +Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 From 979645567ef02272136d678fc1e30c0a75c8bae9 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 10:08:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/clawdoll/scenepolicy_clawdoll.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index f00ad1f..b9ad90d 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -67,7 +67,8 @@ func (this *PolicyClawdoll) OnTick(s *base.Scene) { sceneEx, ok := s.ExtraData.(*SceneEx) if ok { if sceneEx.machineId == 0 { - sceneEx.machineId = action.GetFreeDollMachineId() + machineId := s.DBGameFree.GetId() % 6080000 + sceneEx.machineId = action.GetFreeDollMachineId(machineId) } if sceneEx.machineId != 0 { machineStatus := action.GetDollMachineStatus(sceneEx.machineId)