From a4b4a0b2a0abd019563b026d6dfd1c904579aee6 Mon Sep 17 00:00:00 2001 From: kxdd <88655@163.com> Date: Wed, 14 Aug 2024 16:23:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E7=A7=BB=E5=8A=A8=E6=8A=95?= =?UTF-8?q?=E5=B8=81=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/clawdoll/player_clawdoll.go | 13 ++++++++ gamesrv/clawdoll/scene_clawdoll.go | 25 +++++++++++++++ gamesrv/clawdoll/scenepolicy_clawdoll.go | 39 ++++++------------------ 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/gamesrv/clawdoll/player_clawdoll.go b/gamesrv/clawdoll/player_clawdoll.go index f69670f..1ec2c43 100644 --- a/gamesrv/clawdoll/player_clawdoll.go +++ b/gamesrv/clawdoll/player_clawdoll.go @@ -31,11 +31,24 @@ func (this *PlayerEx) CanOp(sceneEx *SceneEx) bool { return true } +// 能否投币 func (this *PlayerEx) CanPayCoin() bool { return true } +// 能否移动 +func (this *PlayerEx) CanMove() bool { + + return true +} + +// 能否下抓 +func (this *PlayerEx) CanGrab() bool { + + return true +} + // 游戏新一局 设置数据 func (this *PlayerEx) ReStartGame() { this.ReDataStartGame() diff --git a/gamesrv/clawdoll/scene_clawdoll.go b/gamesrv/clawdoll/scene_clawdoll.go index 994eb68..df6e0c7 100644 --- a/gamesrv/clawdoll/scene_clawdoll.go +++ b/gamesrv/clawdoll/scene_clawdoll.go @@ -6,6 +6,7 @@ import ( "mongo.games.com/game/gamesrv/base" "mongo.games.com/game/proto" "mongo.games.com/game/protocol/clawdoll" + "mongo.games.com/game/protocol/machine" "mongo.games.com/goserver/core/logger" "mongo.games.com/goserver/core/netlib" "mongo.games.com/goserver/srvlib" @@ -208,6 +209,30 @@ func (this *SceneEx) BackupPlayer(p *PlayerEx, isBilled bool) { } } +// OnPlayerSMGrabOp 下抓 //1-弱力抓 2 -强力抓 3-必出抓 +func (this *SceneEx) OnPlayerSMGrabOp(SnId, Id, GrabType int32) { + + pack := &machine.SMDollMachineGrab{ + Snid: proto.Int32(SnId), + Id: proto.Int32(Id), + TypeId: proto.Int32(GrabType), + } + + this.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMDollMachineGrab), pack) +} + +// OnPlayerSCOp 发送玩家操作情况 1-前 2-后 3-左 4-右 5-投币 +func (this *SceneEx) OnPlayerSMPerateOp(SnId, Id, Perate int32) { + + pack := &machine.SMDollMachineoPerate{ + Snid: proto.Int32(SnId), + Id: proto.Int32(Id), + Perate: proto.Int32(Perate), + } + + this.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMDollMachinePerate), pack) +} + // 向娃娃机主机发送消息 func (this *SceneEx) SendToMachine(pid int, msg interface{}) { if this.machineConn == nil { diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index 146a682..14db059 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -3,7 +3,6 @@ package clawdoll import ( "mongo.games.com/game/gamesrv/action" "mongo.games.com/game/protocol/clawdoll" - "mongo.games.com/game/protocol/machine" "time" "mongo.games.com/goserver/core" @@ -461,13 +460,7 @@ func (this *StateStart) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, pa } // 1-前 2-后 3-左 4-右 5-投币 - pack := &machine.SMDollMachineoPerate{ - Snid: proto.Int32(p.SnId), - Id: proto.Int32(int32(sceneEx.machineId)), - Perate: proto.Int32(int32(5)), - } - - sceneEx.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMDollMachinePerate), pack) + sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), int32(5)) } return false @@ -546,34 +539,22 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para } // 1-前 2-后 3-左 4-右 5-投币 - pack := &machine.SMDollMachineoPerate{ - Snid: proto.Int32(p.SnId), - Id: proto.Int32(int32(sceneEx.machineId)), - Perate: proto.Int32(int32(5)), - } - - sceneEx.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMDollMachinePerate), pack) - + sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), int32(5)) //sceneEx.OnPlayerSCOp(p, opcode, clawdoll.OpResultCode_OPRC_Success, params) case rule.ClawDollPlayerOpGo: - - pack := &machine.SMDollMachineGrab{ - Snid: proto.Int32(p.SnId), - Id: proto.Int32(int32(sceneEx.machineId)), - TypeId: proto.Int32(int32(2)), + if !playerEx.CanGrab() { + return false } - sceneEx.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMDollMachineGrab), pack) + //1-弱力抓 2 -强力抓 + sceneEx.OnPlayerSMGrabOp(p.SnId, int32(sceneEx.machineId), int32(2)) case rule.ClawDollPlayerOpMove: + if !playerEx.CanMove() { + return false + } // 1-前 2-后 3-左 4-右 5-投币 - pack := &machine.SMDollMachineoPerate{ - Snid: proto.Int32(p.SnId), - Id: proto.Int32(int32(sceneEx.machineId)), - Perate: proto.Int32(int32(params[0])), - } - - sceneEx.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMDollMachinePerate), pack) + sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), int32(params[0])) } return false