From 3619ec697a0c72791f514623b9c16c4f5e27b299 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 18 Aug 2023 15:35:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 3 +- modules/hero/module.go | 38 ------------------------- modules/hunting/api_challengeover.go | 17 ++++++----- modules/mainline/api_challengeover.go | 14 +++++---- modules/mline/api_challengeover.go | 14 +++++---- modules/pagoda/api_challengeover.go | 14 +++++---- modules/pagoda/api_racechallengeover.go | 14 +++++---- modules/viking/api_challengeover.go | 23 ++++++++------- 8 files changed, 56 insertions(+), 81 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 38ea3f1f6..1c3847eeb 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -105,8 +105,7 @@ type ( CleanData(uid string) // 获取指定星级等级的英雄 GetSpecifiedHero(session IUserSession, heroConfId string, star, lv int32) (errdata *pb.ErrorData) - // 英雄加经验 - //AddHeroExp(session IUserSession, heroObjID string, exp int32) (curAddExp int32, errdata *pb.ErrorData) + // 英雄加经验 AddHerosExp(session IUserSession, heroObjs []string, exp int32) (curAddExp []int32, errdata *pb.ErrorData) // 英雄练功 diff --git a/modules/hero/module.go b/modules/hero/module.go index 4dcda422f..aa06eef7a 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -312,44 +312,6 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string] return } -// func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp int32) (curAddExp int32, errdata *pb.ErrorData) { -// var ( -// _hero *pb.DBHero -// _changeHero []*pb.DBHero // 变化的英雄 -// ) - -// if heroObjID == "" { -// return -// } -// if this.IsCross() { -// _hero = &pb.DBHero{} -// if model, err := this.GetDBModelByUid(session.GetUserId(), this.modelHero.TableName); err == nil { -// if err := model.GetListObj(session.GetUserId(), heroObjID, _hero); err != nil { -// this.Errorf("err:%v", err) -// return -// } -// curAddExp, errdata = this.modelHero.AddCardExp(session, _hero, exp, model) -// if errdata != nil { -// return -// } -// } -// } else { -// _hero, errdata = this.GetHeroByObjID(session.GetUserId(), heroObjID) -// if errdata != nil { -// return -// } - -// curAddExp, errdata = this.modelHero.AddCardExp(session, _hero, exp, nil) -// if errdata != nil { -// return -// } -// } -// _changeHero = append(_changeHero, _hero) // 升级后的英雄 hero id 不变 - -// session.SendMsg(string(this.GetType()), "change", &pb.HeroChangePush{List: _changeHero}) -// return -// } - // 英雄练功 func (this *Hero) KungFuHero(session comm.IUserSession, heroObjID string, bKongfu bool, kongfuUid string) (errdata *pb.ErrorData) { var ( diff --git a/modules/hunting/api_challengeover.go b/modules/hunting/api_challengeover.go index 2a87ff89c..eebc552e3 100644 --- a/modules/hunting/api_challengeover.go +++ b/modules/hunting/api_challengeover.go @@ -148,16 +148,19 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha return } // 加经验 - var heroObjs []string - if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { - for _, v := range req.Report.Info.Redflist[0].Team { - if cfgHunting.Heroexp > 0 && !v.Ishelp { // 助战英雄不加经验 - heroObjs = append(heroObjs, v.Oid) - changExp[v.Oid] = cfgHunting.Heroexp + if cfgHunting.Heroexp > 0 { + var heroObjs []string + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if !v.Ishelp { // 助战英雄不加经验 + heroObjs = append(heroObjs, v.Oid) + changExp[v.Oid] = cfgHunting.Heroexp + } } } + this.module.ModuleHero.AddHerosExp(session, heroObjs, cfgHunting.Heroexp) } - this.module.ModuleHero.AddHerosExp(session, heroObjs, cfgHunting.Heroexp) + errdata = this.module.ModifyHuntingData(session.GetUserId(), mapData) userExp, _ = this.module.ModuleUser.ConsumePsAddExp(session, consumPs) session.SendMsg(string(this.module.GetType()), HuntingChallengeOverResp, &pb.HuntingChallengeOverResp{ diff --git a/modules/mainline/api_challengeover.go b/modules/mainline/api_challengeover.go index 7225145d5..0f78429a5 100644 --- a/modules/mainline/api_challengeover.go +++ b/modules/mainline/api_challengeover.go @@ -148,15 +148,17 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh } // 加英雄经验 - var heroObjs []string - if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { - for _, v := range req.Report.Info.Redflist[0].Team { - if conf.HeroExp > 0 && !v.Ishelp { // 助战英雄不加经验 - heroObjs = append(heroObjs, v.Oid) + if conf.HeroExp > 0 { + var heroObjs []string + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if !v.Ishelp { // 助战英雄不加经验 + heroObjs = append(heroObjs, v.Oid) + } } } + this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.HeroExp) } - this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.HeroExp) consumPs = info.Ps[req.Level] if userExp, errdata = this.module.ModuleUser.ConsumePsAddExp(session, consumPs); errdata != nil { diff --git a/modules/mline/api_challengeover.go b/modules/mline/api_challengeover.go index 718d61d69..6970d9437 100644 --- a/modules/mline/api_challengeover.go +++ b/modules/mline/api_challengeover.go @@ -198,15 +198,17 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall } } // 加英雄经验 - var heroObjs []string - if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { - for _, v := range req.Report.Info.Redflist[0].Team { - if stageConf.HeroExp > 0 && !v.Ishelp { // 助战英雄不加经验 - heroObjs = append(heroObjs, v.Oid) + if stageConf.HeroExp > 0 { + var heroObjs []string + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if !v.Ishelp { // 助战英雄不加经验 + heroObjs = append(heroObjs, v.Oid) + } } } + this.module.ModuleHero.AddHerosExp(session, heroObjs, stageConf.HeroExp) } - this.module.ModuleHero.AddHerosExp(session, heroObjs, stageConf.HeroExp) rsp.HeroExp = stageConf.HeroExp rsp.UserExp, _ = this.module.ModuleUser.ConsumePsAddExp(session, consumPs) diff --git a/modules/pagoda/api_challengeover.go b/modules/pagoda/api_challengeover.go index 510c266cd..3495e3e7f 100644 --- a/modules/pagoda/api_challengeover.go +++ b/modules/pagoda/api_challengeover.go @@ -95,15 +95,17 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal return } // 加经验 - var heroObjs []string - if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { - for _, v := range req.Report.Info.Redflist[0].Team { - if conf.Exp > 0 && !v.Ishelp { // 助战英雄不加经验 - heroObjs = append(heroObjs, v.Oid) + if conf.Exp > 0 { + var heroObjs []string + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if !v.Ishelp { // 助战英雄不加经验 + heroObjs = append(heroObjs, v.Oid) + } } } + this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.Exp) } - this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.Exp) pagoda.Data[conf.Tab] += 1 pagoda.PagodaId = conf.Key diff --git a/modules/pagoda/api_racechallengeover.go b/modules/pagoda/api_racechallengeover.go index bf9d7113f..ca094e83d 100644 --- a/modules/pagoda/api_racechallengeover.go +++ b/modules/pagoda/api_racechallengeover.go @@ -94,15 +94,17 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda } return } - var heroObjs []string - if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { - for _, v := range req.Report.Info.Redflist[0].Team { - if conf.Exp > 0 && !v.Ishelp { // 助战英雄不加经验 - heroObjs = append(heroObjs, v.Oid) + if conf.Exp > 0 { + var heroObjs []string + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if !v.Ishelp { // 助战英雄不加经验 + heroObjs = append(heroObjs, v.Oid) + } } } + this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.Exp) } - this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.Exp) race.Race[conf.Restriction].Curfloor += 1 race.Race[conf.Restriction].Defeat += 1 diff --git a/modules/viking/api_challengeover.go b/modules/viking/api_challengeover.go index 8b00d16ab..fa8ced036 100644 --- a/modules/viking/api_challengeover.go +++ b/modules/viking/api_challengeover.go @@ -177,21 +177,24 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal return } - errdata = this.module.ModifyVikingData(session.GetUserId(), mapData) + if errdata = this.module.ModifyVikingData(session.GetUserId(), mapData); errdata != nil { + return + } // 加经验 - var heroObjs []string - if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { - for _, v := range req.Report.Info.Redflist[0].Team { - if vikingCfg.Heroexp > 0 && !v.Ishelp { // 助战英雄不加经验 - heroObjs = append(heroObjs, v.Oid) - } - if v.Ishelp { - bHelp = true + if vikingCfg.Heroexp > 0 { + var heroObjs []string + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + for _, v := range req.Report.Info.Redflist[0].Team { + if !v.Ishelp { // 助战英雄不加经验 + heroObjs = append(heroObjs, v.Oid) + } else { + bHelp = true + } } } + this.module.ModuleHero.AddHerosExp(session, heroObjs, vikingCfg.Heroexp) } - this.module.ModuleHero.AddHerosExp(session, heroObjs, vikingCfg.Heroexp) userExp, _ = this.module.ModuleUser.ConsumePsAddExp(session, consumPs) session.SendMsg(string(this.module.GetType()), VikingChallengeOverResp, &pb.VikingChallengeOverResp{