上传共鸣水晶代码

This commit is contained in:
liwei 2023-07-10 17:24:57 +08:00
parent a142ccc9ec
commit c9d12bb33f
4 changed files with 20 additions and 8 deletions

View File

@ -540,6 +540,6 @@ type (
//练功房
IPasson interface {
//英雄升级
HeroUpLv(session IUserSession, heroid string, lv int32)
HeroUpLv(uid string, heroid string, lv int32)
}
)

View File

@ -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

View File

@ -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
}

View File

@ -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
}