From c9d12bb33ffa47728b613237c2e2b18ca793d45a Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Mon, 10 Jul 2023 17:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=85=B1=E9=B8=A3=E6=B0=B4?= =?UTF-8?q?=E6=99=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 +- modules/hero/model_hero.go | 3 ++- modules/hero/module.go | 7 ++++++- modules/passon/module.go | 16 +++++++++++----- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index fefe6f33c..f3e6f6fd4 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -540,6 +540,6 @@ type ( //练功房 IPasson interface { //英雄升级 - HeroUpLv(session IUserSession, heroid string, lv int32) + HeroUpLv(uid string, heroid string, lv int32) } ) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 038868632..9c785c895 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -598,8 +598,9 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex szTask = append(szTask, comm.GetBuriedParam(comm.Rtype113, hero.Lv)) szTask = append(szTask, comm.GetBuriedParam(comm.Rtype33, 1, 1, hero.Lv)) szTask = append(szTask, comm.GetBuriedParam(comm.Rtype118, hero.Lv, hero.JuexingLv)) - + go this.module.passon.HeroUpLv(session.GetUserId(), hero.HeroID, curLv) go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), szTask...) + } } return diff --git a/modules/hero/module.go b/modules/hero/module.go index 3cfcb89ea..3bd79346a 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -33,6 +33,7 @@ type Hero struct { service core.IService moduleHoroscope comm.IHoroscope chat comm.IChat + passon comm.IPasson } // 模块名 @@ -57,6 +58,7 @@ func (this *Hero) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } func (this *Hero) Start() (err error) { + err = this.ModuleBase.Start() var module core.IModule if module, err = this.service.GetModule(comm.ModuleLibrary); err != nil { return @@ -72,7 +74,10 @@ func (this *Hero) Start() (err error) { return } this.chat = module.(comm.IChat) - err = this.ModuleBase.Start() + if module, err = this.service.GetModule(comm.ModulePasson); err != nil { + return + } + this.passon = module.(comm.IPasson) event.RegisterGO(comm.EventUserOffline, this.EventUserOffline) return } diff --git a/modules/passon/module.go b/modules/passon/module.go index de269a598..978d3df7b 100644 --- a/modules/passon/module.go +++ b/modules/passon/module.go @@ -54,7 +54,7 @@ func (this *Passon) Start() (err error) { } // 英雄升级 -func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) { +func (this *Passon) HeroUpLv(uid string, heroid string, lv int32) { var ( passon *pb.DBPasson heros []*pb.DBHero @@ -62,7 +62,7 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) errdata *pb.ErrorData err error ) - if passon, err = this.modelPasson.getUserPasson(session.GetUserId()); err != nil { + if passon, err = this.modelPasson.getUserPasson(uid); err != nil { this.Error("getUserPasson err", log.Field{Key: "err", Value: err.Error()}) return } @@ -76,7 +76,7 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) } } - heros = this.ModuleHero.GetHeroList(session.GetUserId()) + heros = this.ModuleHero.GetHeroList(uid) // 使用sort.Slice进行排序 sort.Slice(heros, func(i, j int) bool { return heros[i].Lv < heros[j].Lv @@ -86,7 +86,7 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) for i, v := range heros { passon.Teacher[i] = v.Id } - if err = this.modelPasson.updateUserPasson(session.GetUserId(), passon); err != nil { + if err = this.modelPasson.updateUserPasson(uid, passon); err != nil { this.Errorln(err) return } @@ -106,6 +106,12 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) passon.Teacher[i] = heros[i].Id } + session, _ := this.GetUserSession(uid) + defer func() { + session.Push() + this.PutUserSession(session) + }() + if len(change) > 0 { if errdata = this.ModuleHero.PassonHero(session, change); errdata != nil { return @@ -120,7 +126,7 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32) session.SendMsg(string(this.GetType()), "lvchange", &pb.PassonLvChangePush{Lv: passon.Passonlv}) } - if err = this.modelPasson.updateUserPasson(session.GetUserId(), passon); err != nil { + if err = this.modelPasson.updateUserPasson(uid, passon); err != nil { this.Errorln(err) return }