From 6b55cd679ad2ac67eeb50a1af14443a40c2a06b0 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 29 Dec 2023 17:09:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=B8=80=E4=B8=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/api_challengereward.go | 4 +- modules/capturesheep/api_changemts.go | 5 +- modules/equipment/api_equip.go | 14 ++++- modules/parkour/module.go | 8 +-- modules/user/model_user.go | 43 +++++++------- modules/user/module.go | 81 +-------------------------- 6 files changed, 41 insertions(+), 114 deletions(-) diff --git a/modules/arena/api_challengereward.go b/modules/arena/api_challengereward.go index 2f0d264e7..51e0b6ef8 100644 --- a/modules/arena/api_challengereward.go +++ b/modules/arena/api_challengereward.go @@ -283,8 +283,8 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha } } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype130, 1)) - tasks = append(tasks, comm.GetBuriedParam(comm.Rtype128, red.Integral)) - tasks = append(tasks, comm.GetBuriedParam(comm.Rtype129, red.Dan)) + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype128, info.Integral)) + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype129, info.Dan)) session.SendMsg(string(this.module.GetType()), "challengereward", &pb.ArenaChallengeRewardResp{Issucc: true, Integral: info.Integral, Dan: info.Dan}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { diff --git a/modules/capturesheep/api_changemts.go b/modules/capturesheep/api_changemts.go index e5db16878..64c3dc513 100644 --- a/modules/capturesheep/api_changemts.go +++ b/modules/capturesheep/api_changemts.go @@ -49,8 +49,7 @@ func (this *apiComp) ChangeMts(session comm.IUserSession, req *pb.CapturesheepCh } session.SendMsg(string(this.module.GetType()), "changemts", &pb.CapturesheepChangeMtsResp{Mid: req.Mid}) - go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { - this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype234, 1)) - }) + // go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { + // }) return } diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 36a79a1d5..cf12f57a9 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -33,6 +33,7 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) equipNum int32 minstar, minlv int32 = int32(99999), int32(99999) hero *pb.DBHero + lvnum map[int32]int32 = make(map[int32]int32) tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) ) @@ -101,6 +102,13 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) } } + lvnum[equipments[i].Lv]++ + for k, _ := range lvnum { + if k > equipments[i].Lv { + lvnum[k]++ + } + } + if suit == nil { suit = &pb.DB_EquipmentSuit{ Suitid: confs[i].Suittype, @@ -113,7 +121,6 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) suit.Effect = true tasks = append(tasks, comm.GetBuriedParam(comm.Rtype93, 1, suit.Suitid, suit.Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype46, 1, suit.Str, suit.Suitid)) - tasks = append(tasks, comm.GetBuriedParam(comm.Rtype98, 1, suit.Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype169, 1, suit.Suitid)) } suits = append(suits, suit) @@ -129,7 +136,6 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) suit.Effect = true tasks = append(tasks, comm.GetBuriedParam(comm.Rtype93, 1, suit.Suitid, suit.Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype46, 1, suit.Str, suit.Suitid)) - tasks = append(tasks, comm.GetBuriedParam(comm.Rtype98, 1, suit.Lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype169, 1, suit.Suitid)) } } @@ -139,6 +145,10 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) } } + for k, v := range lvnum { + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype98, v, k)) + } + //读取英雄原装备 for i, v := range hero.EquipID { if v != "" { diff --git a/modules/parkour/module.go b/modules/parkour/module.go index fb79c4cc9..17f067cf9 100644 --- a/modules/parkour/module.go +++ b/modules/parkour/module.go @@ -587,7 +587,8 @@ func (this *Parkour) overtimer(task *timewheel.Task, args ...interface{}) { }, Award: award[v.GetUserId()], }) - go this.AsynHandleSession(v, func(session comm.IUserSession) { + go this.AsynHandleSession(v.Clone(), func(session comm.IUserSession) { + this.ModuleBuried.TriggerBuried(v, comm.GetBuriedParam(comm.Rtype234, 1)) this.WriteUserLog(session.GetUserId(), "", 0, "ParkourRaceOverPush", award[v.GetUserId()]) }) sessions = append(sessions, v) @@ -632,11 +633,6 @@ func (this *Parkour) overtimer(task *timewheel.Task, args ...interface{}) { } } } - for _, v := range sessions { - this.ModuleBuried.TriggerBuried(v, comm.GetBuriedParam(comm.Rtype234, 1)) - v.Push() - this.PutUserSession(v) - } } } diff --git a/modules/user/model_user.go b/modules/user/model_user.go index e53313387..2d94c0d80 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -288,31 +288,32 @@ func (this *ModelUser) computeLevel(change *pb.UserResChangedPush) (lvchange boo } func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64, name string, rewards []*cfg.Gameatn) { - var ( - atno []*pb.UserAtno - errdata *pb.ErrorData - ) - defer this.module.PutUserSession(session) - if err := session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush, - &pb.UserLvChangedPush{Uid: session.GetUserId(), Exp: exp, Lv: lv}); err != nil { - this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败", - log.Field{Key: "uid", Value: session.GetUserId()}, - log.Field{Key: "exp", Value: exp}, - log.Field{Key: "lv", Value: lv}, - ) - } - if errdata, atno = this.module.DispenseAtno(session, rewards, true); errdata != nil { - this.module.Error("资源发放", - log.Field{Key: "uid", Value: session.GetUserId()}, - log.Field{Key: "rewards", Value: rewards}, - ) - } - this.module.chat.SendSysChatToUser(session, comm.ChatSystem12, lv, 0, name) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { + var ( + atno []*pb.UserAtno + errdata *pb.ErrorData + tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) + ) + if err := session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush, + &pb.UserLvChangedPush{Uid: session.GetUserId(), Exp: exp, Lv: lv}); err != nil { + this.module.Error("玩家等级变化 UserSubTypeLvChangedPush推送失败", + log.Field{Key: "uid", Value: session.GetUserId()}, + log.Field{Key: "exp", Value: exp}, + log.Field{Key: "lv", Value: lv}, + ) + } + if errdata, atno = this.module.DispenseAtno(session, rewards, true); errdata != nil { + this.module.Error("资源发放", + log.Field{Key: "uid", Value: session.GetUserId()}, + log.Field{Key: "rewards", Value: rewards}, + ) + } + this.module.chat.SendSysChatToUser(session, comm.ChatSystem12, lv, 0, name) this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypePlatlv, lv) + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype20, lv)) + this.module.ModuleBuried.TriggerBuried(session, tasks...) this.module.WriteUserLog(session.GetUserId(), fmt.Sprintf(" lv :%d, exp %d, name %s", lv, exp, name), comm.GMResAddType, "changelv", atno) }) - session.Push() } diff --git a/modules/user/module.go b/modules/user/module.go index bd8c56032..2a37ac696 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -572,7 +572,7 @@ func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atn } change.Exp += int64(add) if lvchange, loseexp, rewards = this.modelUser.computeLevel(change); lvchange { - go this.modelUser.changelv(session.Clone(), change.Lv, change.Exp, user.Name, rewards) + this.modelUser.changelv(session, change.Lv, change.Exp, user.Name, rewards) } temp.N = temp.N - loseexp case comm.VipExp: @@ -879,25 +879,6 @@ func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atn return } -// // 用户资源 -// func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add int32, bPush bool) (errdata *pb.ErrorData) { -// var _change *pb.UserResChangedPush - -// _change, errdata = this.change(session, attr, add) -// if errdata != nil { -// return -// } - -// if _change == nil { -// return -// } - -// if bPush { //推送玩家账号信息变化消息 -// session.SendMsg(string(this.GetType()), "reschanged", _change) -// } -// return -// } - // 用户资源 func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (atno []*pb.UserAtno, errdata *pb.ErrorData) { var ( @@ -1104,66 +1085,6 @@ func (this *User) BingoSetUserLv(session comm.IUserSession, lv int32) error { return nil } -// // 玩家体力恢复 -// func (this *User) RecoverUserPsStart(session comm.IUserSession) (recoverTime int64) { -// var ( -// yu int32 -// add int32 -// changed int32 -// ) -// // 推送红点信息 -// re := this.ModuleTools.GetGlobalConf().PsRecovery -// if re <= 0 { -// return -// } -// u, err := this.GetUser(session.GetUserId()) -// if err != nil { -// return -// } -// if u.LastRecoverPsSec == 0 { -// u.LastRecoverPsSec = configure.Now().Unix() -// } -// diff := configure.Now().Unix() - u.LastRecoverPsSec -// yu = int32(diff / int64(re)) -// if yu > 0 { -// pconf := this.configure.GetPlayerlvConf(u.Lv) -// if pconf == nil { -// return -// } -// if u.Ps < pconf.PsCeiling { -// total := u.Ps + yu -// if total > pconf.PsCeiling { -// add = pconf.PsCeiling - u.Ps -// changed = pconf.PsCeiling -// } else { -// add = yu -// changed = total -// u.LastRecoverPsSec += int64(yu * re) -// } -// } else { -// add = 0 -// } -// //u.LastRecoverPsSec = time.Now().Unix() -// update := map[string]interface{}{} -// if add > 0 { -// u.Ps += add -// update["ps"] = u.Ps -// update["lastRecoverPsSec"] = u.LastRecoverPsSec -// } -// if err := this.modelUser.Change(u.Uid, update); err == nil { -// if changed > 0 { -// this.reddot.PushReddot(session, &pb.ReddotItem{ -// Rid: int32(comm.Reddot30100), -// Nextchanagetime: u.LastRecoverPsSec + int64(re), -// }) -// session.Push() -// } -// } -// } -// recoverTime = u.LastRecoverPsSec + int64(re) -// return recoverTime -// } - // 玩家体力恢复 func (this *User) recoverUserPs(user *pb.DBUser) (change bool, total int32, nexttime int64) { var (