From 08b16d62e7f1f820023970e87c819ad03766fc15 Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Thu, 10 Aug 2023 15:22:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=94=A8=E6=88=B7=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=9F=8B=E7=82=B9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 5 ++--- modules/modulebase.go | 15 -------------- modules/user/module.go | 47 ++++++++++++++++++++++++++++++------------ 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/comm/const.go b/comm/const.go index 51303339f..c3d4ffff2 100644 --- a/comm/const.go +++ b/comm/const.go @@ -741,11 +741,9 @@ const ( Rtype101 TaskType = 101 //获得X星职业武器N件(历史)(从创号开始记录,每获得1件X星职业武器则进度+1) Rtype102 TaskType = 102 //阵营饰品强化成功N次(历史)(从创号开始记录,强化成功进度+1) Rtype103 TaskType = 103 //获得X星阵营饰品N件(历史)(从创号开始记录,每获得1件X星阵营饰品则进度+1) - //消费N个钻石(历史)(从创号开始记录,每次消耗钻石增加消耗额的进度) - Rtype104 TaskType = 104 + Rtype104 TaskType = 104 //消费N个钻石(历史)(从创号开始记录,每次消耗钻石增加消耗额的进度) Rtype105 TaskType = 105 //商店刷新N次(从接到任务开始,每次刷新商店进度+1) Rtype106 TaskType = 106 //跨服聊天发言N次(从接到任务开始,每次跨服发言成功进度+1) - Rtype108 TaskType = 108 //助战英雄被使用X次(从接到任务开始,每被使用1次则进度+1) Rtype109 TaskType = 109 //加入公会(打开任务时,检查是否加入了公会,加入则完成) Rtype110 TaskType = 110 //激活X个英雄图鉴(打开任务时,检查英雄图鉴激活数量并计入进度,达到了任务所需个数则完成任务。) @@ -842,6 +840,7 @@ const ( Rtype211 TaskType = 211 // 向指定X城市,贩卖价值X虚拟币以上的对应城市急需货物 Rtype212 TaskType = 212 // 接取任务后,商队抵达指定城市 Rtype213 TaskType = 213 // 消耗X体力 + Rtype214 TaskType = 214 // 获得x充值积分 ) const ( MailLineEasy int32 = 1 // 简单 diff --git a/modules/modulebase.go b/modules/modulebase.go index b1367d20e..049a0679b 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -394,17 +394,6 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn this.Warn("资源不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v}) return } - // 统计今天消耗的体力 - if k == "ps" && v < 0 { - if userexpand, err := this.ModuleUser.GetUserExpand(session.GetUserId()); err == nil { - userexpand.ConsumPs += (-v) - this.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{ - "consumPs": userexpand.ConsumPs, - }) - - go this.ModuleUiGame.HDPSTodayConsum(session.GetUserId(), userexpand.ConsumPs) // - } - } } for k, v := range items { amount := this.ModuleItems.QueryItemAmount(session.GetUserId(), k) @@ -426,10 +415,6 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn return } this.Debug("消耗玩家资源", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "attrs", Value: attrs}) - if count, ok := attrs[comm.ResDiamond]; ok { - // this.ModuleBuried.SendToRtask(session, comm.Rtype104, -count) - go this.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype104, -count)) - } } if len(items) > 0 { _, errdata = this.ModuleItems.AddItems(session, items, bPush) diff --git a/modules/user/module.go b/modules/user/module.go index 8d7a5644a..0660b99ce 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -441,7 +441,6 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha } return } - this.ModuleBuried.TriggerBuried(session.Clone(), comm.GetBuriedParam(comm.Rtype68, -(add))) } change.Gold += int64(add) case comm.ResExp: @@ -546,6 +545,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha return } change.Ps += add + userEx.ConsumPs += -add } else { if change.Ps+add > ggd.PsUl { change.Ps = ggd.PsUl @@ -652,6 +652,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha comm.ResFriend: change.Friend, comm.SociatyCoin: change.Guildcoin, comm.ArenaCoin: change.Arenacoin, + "consumPs": userEx.ConsumPs, } if err := this.modelUser.updateUserAttr(uid, update); err != nil { @@ -696,27 +697,47 @@ func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add // 用户资源 func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData) { + var ( + expChange bool + vipExpChange bool + tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) + _change *pb.UserResChangedPush + ) for key, add := range attrs { - var _change *pb.UserResChangedPush _change, errdata = this.change(session, key, add) if errdata != nil { return } - - if _change == nil { - continue - } - - if bPush { //推送玩家账号信息变化消息 - session.SendMsg(string(this.GetType()), "reschanged", _change) - } if key == comm.ResExp { - this.ModuleUser.EventUserChanged(session) + expChange = true } else if key == comm.VipExp { - this.ModuleUser.EventUserVipChanged(session) + vipExpChange = true + } + if key == comm.ResPs && add < 0 { //消耗体力 + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype213, -add)) + } + if key == comm.ResGold && add < 0 { //消耗体力 + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype68, -add)) + } + if key == comm.ResDiamond && add < 0 { //消耗钻石 + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype104, -add)) + } + if key == comm.Integral && add > 0 { //积分获取 + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype214, add)) } } - + if bPush { //推送玩家账号信息变化消息 + session.SendMsg(string(this.GetType()), "reschanged", _change) + } + if expChange { + this.ModuleUser.EventUserChanged(session) + } + if vipExpChange { + this.ModuleUser.EventUserVipChanged(session) + } + if len(tasks) > 0 { + go this.ModuleBuried.TriggerBuried(session.Clone(), tasks...) + } return }