From 81b529d13b81f4fcbbd0cf0ccb57ce1d874909d3 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 20 Sep 2024 17:58:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=AF=8F=E5=B1=80=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamerule/clawdoll/constants.go | 6 -- gamesrv/clawdoll/action_clawdoll.go | 7 +- gamesrv/clawdoll/player_clawdoll.go | 84 ++++++++++++++++-------- gamesrv/clawdoll/scenepolicy_clawdoll.go | 65 ++++++++++++++++++ model/gamelogtype.go | 10 +++ worldsrv/action_player.go | 19 ++++++ 6 files changed, 153 insertions(+), 38 deletions(-) diff --git a/gamerule/clawdoll/constants.go b/gamerule/clawdoll/constants.go index 2e4bd08..0d7e9e9 100644 --- a/gamerule/clawdoll/constants.go +++ b/gamerule/clawdoll/constants.go @@ -73,9 +73,3 @@ const ( Zego_ForbidRTCStream = iota + 1 Zego_ResumeRTCStream = iota + 1 ) - -const ( - ClawDollItemID = 40003 - ClawDollGiveItemID = 74004 - ClawDollCostItemCount = 2 -) diff --git a/gamesrv/clawdoll/action_clawdoll.go b/gamesrv/clawdoll/action_clawdoll.go index 58e3ca0..20be80a 100644 --- a/gamesrv/clawdoll/action_clawdoll.go +++ b/gamesrv/clawdoll/action_clawdoll.go @@ -84,7 +84,7 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data if msg.Result == 1 { logger.Logger.Tracef("上分成功!!!!!!!!!!!!snid = %v", msg.Snid) - playerEx.CostPlayCoin(2) + playerEx.CostPlayCoin() sceneEx.playingSnid = p.SnId @@ -107,11 +107,12 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data if msg.Result == 1 { // 获得娃娃卡 - playerEx.CatchCardClawdoll(1) - + playerEx.CatchCardClawdoll() + playerEx.IsWin = true logger.Logger.Tracef("下抓成功!!!!!!!!!!!!snid = %v", msg.Snid) } else { logger.Logger.Tracef("下抓失败!!!!!!!!!!!!snid = %v", msg.Snid) + playerEx.IsWin = false } logger.Logger.Tracef("ClawDoll StatePlayGame OnPlayerOp Grab response, SnId= %v", msg.Snid) diff --git a/gamesrv/clawdoll/player_clawdoll.go b/gamesrv/clawdoll/player_clawdoll.go index e3665e3..45f75fd 100644 --- a/gamesrv/clawdoll/player_clawdoll.go +++ b/gamesrv/clawdoll/player_clawdoll.go @@ -2,7 +2,6 @@ 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" @@ -15,6 +14,8 @@ type PlayerEx struct { clawDollState int32 // 抓娃娃状态 dollCardsCnt int32 // 娃娃卡数量 + IsWin bool // 是否抓到娃娃 + winDollCardType int32 // 本局赢取娃娃的类型 gainCoin int64 // 本局赢的金币 taxCoin int64 // 本局税收 @@ -29,6 +30,7 @@ func (this *PlayerEx) Clear(baseScore int32) { this.gainCoin = 0 this.taxCoin = 0 this.odds = 0 + this.IsWin = false } func (this *PlayerEx) CanOp(sceneEx *SceneEx) bool { @@ -42,19 +44,31 @@ func (this *PlayerEx) CanOp(sceneEx *SceneEx) bool { // 能否投币 func (this *PlayerEx) CanPayCoin() bool { - itemID := int32(rule.ClawDollItemID) - itemCount := this.GetItemCount(itemID) - if itemCount < rule.ClawDollCostItemCount { - return false - } - + itemID := int32(common.ItemIDClawdoll) itemData := srvdata.GameItemMgr.Get(this.Platform, itemID) if itemData == nil { return false } + s := this.GetScene() + if s == nil { + logger.Logger.Warn("CostPlayCoin p.scene == nil") + return false + } + + machineId := s.GetDBGameFree().GetId() % 6080000 + machineInfo := s.GetMachineServerInfo(machineId, this.Platform) + if machineInfo == nil { + return false + } + + itemCount := this.GetItemCount(itemID) + if itemCount < int64(machineInfo.CostItemNum) { + return false + } + num, ok := this.Items[itemID] - if !ok || num < 1 { + if !ok || num < int64(machineInfo.CostItemNum) { return false } @@ -62,22 +76,12 @@ func (this *PlayerEx) CanPayCoin() bool { } // 投币消耗 -func (this *PlayerEx) CostPlayCoin(count int32) bool { +func (this *PlayerEx) CostPlayCoin() bool { if !this.CanPayCoin() { return false } - var items []*model.Item - - itemData := srvdata.GameItemMgr.Get(this.Platform, rule.ClawDollItemID) - if itemData != nil { - items = append(items, &model.Item{ - ItemId: rule.ClawDollItemID, - ItemNum: int64(count), - }) - } - s := this.GetScene() if s == nil { logger.Logger.Warn("CostPlayCoin p.scene == nil") @@ -89,6 +93,21 @@ func (this *PlayerEx) CostPlayCoin(count int32) bool { return false } + machineId := s.GetDBGameFree().GetId() % 6080000 + machineInfo := s.GetMachineServerInfo(machineId, this.Platform) + if machineInfo == nil { + return false + } + + var items []*model.Item + itemData := srvdata.GameItemMgr.Get(this.Platform, common.ItemIDClawdoll) + if itemData != nil { + items = append(items, &model.Item{ + ItemId: common.ItemIDClawdoll, + ItemNum: int64(-machineInfo.CostItemNum), + }) + } + this.AddItems(&model.AddItemParam{ P: this.PlayerData, Change: items, @@ -103,16 +122,7 @@ func (this *PlayerEx) CostPlayCoin(count int32) bool { } // 抓取到娃娃获得娃娃 -func (this *PlayerEx) CatchCardClawdoll(count int32) bool { - var items []*model.Item - - itemData := srvdata.GameItemMgr.Get(this.Platform, rule.ClawDollGiveItemID) - if itemData != nil { - items = append(items, &model.Item{ - ItemId: rule.ClawDollGiveItemID, - ItemNum: int64(count), - }) - } +func (this *PlayerEx) CatchCardClawdoll() bool { s := this.GetScene() if s == nil { @@ -120,11 +130,26 @@ func (this *PlayerEx) CatchCardClawdoll(count int32) bool { return false } + machineId := s.GetDBGameFree().GetId() % 6080000 + machineInfo := s.GetMachineServerInfo(machineId, this.Platform) + if machineInfo == nil { + return false + } + sceneEx, ok := s.ExtraData.(*SceneEx) if !ok { return false } + var items []*model.Item + itemData := srvdata.GameItemMgr.Get(this.Platform, machineInfo.ItemId) + if itemData != nil { + items = append(items, &model.Item{ + ItemId: machineInfo.ItemId, + ItemNum: int64(machineInfo.ItemNum), + }) + } + this.AddItems(&model.AddItemParam{ P: this.PlayerData, Change: items, @@ -175,6 +200,7 @@ func (this *PlayerEx) ReStartGame() { this.gainCoin = 0 this.taxCoin = 0 this.odds = 0 + this.IsWin = false } // 初始化 diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index ce10404..e3d78a0 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -3,6 +3,7 @@ package clawdoll import ( "github.com/zegoim/zego_server_assistant/token/go/src/token04" "mongo.games.com/game/gamesrv/action" + "mongo.games.com/game/model" "mongo.games.com/game/protocol/clawdoll" "strconv" "time" @@ -739,6 +740,70 @@ 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 { + logger.Logger.Trace("ClawdollSaveLog Save Snid : ", playerEx.SnId) + + machineId := s.GetDBGameFree().GetId() % 6080000 + machineInfo := s.GetMachineServerInfo(machineId, playerEx.Platform) + if machineInfo == nil { + return + } + + curClawdollItemNum, ok := playerEx.Items[int32(common.ItemIDClawdoll)] + if !ok { + return + } + + LogBaseResult := model.ClawdollResultType{} + LogBaseResult.RoomId = int32(sceneEx.GetSceneId()) + LogBaseResult.PlayerSnid = playerEx.SnId + LogBaseResult.BeforeClawdollItemNum = curClawdollItemNum + int64(machineInfo.CostItemNum) + LogBaseResult.AfterClawdollItemNum = curClawdollItemNum + LogBaseResult.IsWin = playerEx.IsWin + + if !playerEx.IsRob { + sceneEx.logid, _ = model.AutoIncGameLogId() + info, err := model.MarshalGameNoteByHUNDRED(LogBaseResult) + if err == nil { + sceneEx.SaveGameDetailedLog(sceneEx.logid, info, &base.GameDetailedParam{}) + } + + TotalBetValue := 0 + totalin := int64(TotalBetValue) + totalout := playerEx.gainCoin + validFlow := totalin + totalout + validBet := common.AbsI64(totalin - totalout) + logParam := &base.SaveGamePlayerListLogParam{ + Platform: playerEx.Platform, + Channel: playerEx.Channel, + Promoter: playerEx.BeUnderAgentCode, + PackageTag: playerEx.PackageID, + InviterId: playerEx.InviterId, + LogId: sceneEx.logid, + TotalIn: totalin, + TotalOut: totalout, + TaxCoin: playerEx.taxCoin, + BetAmount: int64(TotalBetValue), + WinAmountNoAnyTax: playerEx.gainCoin, + ValidBet: validBet, + ValidFlow: validFlow, + IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player), + IsFree: false, + WinSmallGame: 0, + WinTotal: 0, + } + sceneEx.SaveGamePlayerListLog(playerEx.SnId, logParam) + } + + playerEx.ReStartGame() + } } func (this *StateBilled) OnLeave(s *base.Scene) { diff --git a/model/gamelogtype.go b/model/gamelogtype.go index d24b8cc..7593fd2 100644 --- a/model/gamelogtype.go +++ b/model/gamelogtype.go @@ -1679,3 +1679,13 @@ type SamLocPerson struct { CardInfoEnd []int32 //结算时的牌型 IsTianHu bool //是否天胡 } + +// 娃娃机 每局记录 +type ClawdollResultType struct { + //all + RoomId int32 //房间Id + PlayerSnid int32 //玩家id + BeforeClawdollItemNum int64 //变化前娃娃币 + AfterClawdollItemNum int64 //变化后娃娃币 + IsWin bool //是否成功 +} diff --git a/worldsrv/action_player.go b/worldsrv/action_player.go index f9d1bcf..4fb7c3d 100644 --- a/worldsrv/action_player.go +++ b/worldsrv/action_player.go @@ -3169,6 +3169,25 @@ func CSClawdollItemLog(s *netlib.Session, packetId int, data interface{}, sid in if p == nil { return nil } + + var change []*model.Item + change = append(change, &model.Item{ + ItemId: common.ItemIDClawdoll, + ItemNum: 3, + }) + + BagMgrSingleton.AddItemsV2(&model.AddItemParam{ + P: p.PlayerData, + Change: change, + Add: 0, + GainWay: common.GainWayItemShopChangeDoll, + Operator: "system", + Remark: "商城兑换娃娃", + GameId: 0, + GameFreeId: 0, + NoLog: false, + }) + msg, ok := data.(*player_proto.CSClawdollItemLog) if !ok { return nil