diff --git a/common/constant.go b/common/constant.go index 569461c..190f48f 100644 --- a/common/constant.go +++ b/common/constant.go @@ -314,6 +314,7 @@ const ( GainWayRoomCost = 106 //房费消耗 GainWayRoomGain = 107 //房卡场获得 GainWayItemShop = 108 // 交易市场道具交易 + GainWayClawdoorCostItem = 109 // 娃娃机上分扣道具 ) // 后台选择 金币变化类型 的充值 类型id号起始 diff --git a/gamesrv/clawdoll/action_clawdoll.go b/gamesrv/clawdoll/action_clawdoll.go index d1f2194..a86dc73 100644 --- a/gamesrv/clawdoll/action_clawdoll.go +++ b/gamesrv/clawdoll/action_clawdoll.go @@ -76,8 +76,11 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data case 1: if msg.Result == 1 { logger.Logger.Tracef("上分成功!!!!!!!!!!!!snid = ", msg.Snid) + + sceneEx.playingSnid = p.SnId + //发送向前移动指令 - //sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), rule.ButtonFront) + sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), rule.ButtonFront) s.ChangeSceneState(rule.ClawDollSceneStateStart) sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateStart)) diff --git a/gamesrv/clawdoll/player_clawdoll.go b/gamesrv/clawdoll/player_clawdoll.go index 4d2611e..d857ff5 100644 --- a/gamesrv/clawdoll/player_clawdoll.go +++ b/gamesrv/clawdoll/player_clawdoll.go @@ -1,8 +1,10 @@ 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/model" "mongo.games.com/game/srvdata" "mongo.games.com/goserver/core/logger" ) @@ -62,6 +64,41 @@ func (this *PlayerEx) CanPayCoin() bool { // 投币消耗 func (this *PlayerEx) CostPlayCoin(count int32) bool { + if !this.CanPayCoin() { + return false + } + + var items []*model.Item + + itemData := srvdata.GameItemMgr.Get(this.Platform, rule.ClawDoorItemID) + if itemData != nil { + items = append(items, &model.Item{ + ItemId: rule.ClawDoorItemID, + ItemNum: -1, + }) + } + + s := this.GetScene() + if s == nil { + logger.Logger.Warn("CostPlayCoin p.scene == nil") + return false + } + + sceneEx, ok := s.ExtraData.(*SceneEx) + if !ok { + return false + } + + this.AddItems(&model.AddItemParam{ + P: this.PlayerData, + Change: items, + GainWay: common.GainWayClawdoorCostItem, + Operator: "system", + Remark: "娃娃机上分扣除道具", + GameId: int64(sceneEx.GameId), + GameFreeId: int64(sceneEx.GetGameFreeId()), + }) + return true } diff --git a/gamesrv/clawdoll/scene_clawdoll.go b/gamesrv/clawdoll/scene_clawdoll.go index fd0fbd7..2e2c226 100644 --- a/gamesrv/clawdoll/scene_clawdoll.go +++ b/gamesrv/clawdoll/scene_clawdoll.go @@ -296,8 +296,8 @@ func (this *SceneEx) IsHasPlaying() bool { // 等待下一个玩家 func (this *SceneEx) ReStartGame() { + logger.Logger.Trace("(*SceneEx) ReStartGame, playingSnid = ", this.playingSnid) this.playingSnid = 0 - } func (this *SceneEx) BackupPlayer(p *PlayerEx, isBilled bool) { diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index 949d72a..c735c89 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -526,13 +526,11 @@ func (this *StateWait) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, par return false } - // 1-前 2-后 3-左 4-右 5-投币 - sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), rule.ButtonPayCoin) - if sceneEx.CanStart() { - sceneEx.playingSnid = playerEx.SnId + // 1-前 2-后 3-左 4-右 5-投币 + sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), rule.ButtonPayCoin) - sceneEx.OnPlayerSCOp(p, opcode, clawdoll.OpResultCode_OPRC_Success, params) + //sceneEx.OnPlayerSCOp(p, opcode, clawdoll.OpResultCode_OPRC_Success, params) } } @@ -735,26 +733,6 @@ func (this *StateBilled) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, p func (this *StateBilled) OnEnter(s *base.Scene) { logger.Logger.Trace("(this *StateBilled) OnEnter, sceneid=", s.GetSceneId()) this.BaseState.OnEnter(s) - - sceneEx, ok := s.ExtraData.(*SceneEx) - if !ok { - return - } - - playerEx := sceneEx.GetPlayingEx() - if playerEx != nil { - pack := &clawdoll.SCCLAWDOLLRoundGameBilled{ - RoundId: proto.Int32(int32(sceneEx.RoundId)), - ClowResult: proto.Int32(0), - Award: proto.Int64(playerEx.gainCoin), - Balance: proto.Int64(playerEx.Coin), - } - - // logger.Logger.Trace("SCSmallRocketRoundGameBilled is pack: ", pack) - proto.SetDefaults(pack) - - playerEx.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_GAMEBILLED), pack) - } } func (this *StateBilled) OnLeave(s *base.Scene) { @@ -842,12 +820,6 @@ func (this *StateWaitPayCoin) OnPlayerOp(s *base.Scene, p *base.Player, opcode i playerEx.ReStartGame() - s.ChangeSceneState(rule.ClawDollSceneStateStart) - sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateStart)) - - ClawdollBroadcastRoomState(s) - ClawdollSendPlayerInfo(s) - sceneEx.OnPlayerSCOp(p, opcode, clawdoll.OpResultCode_OPRC_Success, params) case rule.ClawDollPlayerCancelPayCoin: @@ -894,7 +866,7 @@ func (this *StateWaitPayCoin) OnEnter(s *base.Scene) { Balance: proto.Int64(playerEx.Coin), } - // logger.Logger.Trace("SCSmallRocketRoundGameBilled is pack: ", pack) + logger.Logger.Trace("Clawdoor -StateWaitPayCoin is pack: ", pack) proto.SetDefaults(pack) playerEx.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_GAMEBILLED), pack)