创建特殊英雄时校验是否有重复英雄
This commit is contained in:
parent
949037c4b9
commit
eb7c3b7c60
@ -25,7 +25,7 @@ func (this *apiComp) GetSpecified(session comm.IUserSession, req *pb.HeroGetSpec
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
hero, err := this.module.modelHero.createOneHero(session.GetUserId(), req.HeroCoinfigID)
|
||||
hero, err := this.module.modelHero.createSpecialHero(session.GetUserId(), req.HeroCoinfigID)
|
||||
if err == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
}
|
||||
|
@ -96,7 +96,14 @@ func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData {
|
||||
}
|
||||
|
||||
//创建一个指定的英雄
|
||||
func (this *ModelHero) createOneHero(uid string, heroCfgId string) (hero *pb.DBHero, err error) {
|
||||
func (this *ModelHero) createSpecialHero(uid string, heroCfgId string) (hero *pb.DBHero, err error) {
|
||||
list := this.getHeroList(uid)
|
||||
for _, v := range list {
|
||||
if v.HeroID == heroCfgId {
|
||||
hero = v
|
||||
return
|
||||
}
|
||||
}
|
||||
hero = this.InitHero(uid, heroCfgId)
|
||||
if hero != nil {
|
||||
if err = this.AddList(uid, hero.Id, hero); err != nil {
|
||||
|
@ -234,7 +234,7 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string,
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
hero, err := this.modelHero.createOneHero(session.GetUserId(), heroConfId)
|
||||
hero, err := this.modelHero.createSpecialHero(session.GetUserId(), heroConfId)
|
||||
if err != nil {
|
||||
return pb.ErrorCode_HeroCreate
|
||||
}
|
||||
@ -683,7 +683,7 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
|
||||
}
|
||||
|
||||
// 开始创建英雄
|
||||
hero, err := this.modelHero.createOneHero(session.GetUserId(), v.Hid)
|
||||
hero, err := this.modelHero.createSpecialHero(session.GetUserId(), v.Hid)
|
||||
if err != nil {
|
||||
return pb.ErrorCode_HeroCreate
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package user
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
@ -17,21 +16,12 @@ func (this *apiComp) GetTujian(session comm.IUserSession, req *pb.UserGetTujianR
|
||||
return
|
||||
}
|
||||
|
||||
uid := session.GetUserId()
|
||||
rsp := &pb.UserGetTujianResp{}
|
||||
if result, err := this.module.modelExpand.GetUserExpand(uid); err != nil {
|
||||
this.module.Error("玩家扩展数据",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
return
|
||||
} else {
|
||||
for k, v := range result.Tujian {
|
||||
if v == 0 {
|
||||
rsp.Heroids = append(rsp.Heroids, k)
|
||||
}
|
||||
}
|
||||
list := this.module.ModuleHero.GetHeroList(session.GetUserId())
|
||||
for _, v := range list {
|
||||
rsp.Heroids = append(rsp.Heroids, v.HeroID)
|
||||
}
|
||||
|
||||
err := session.SendMsg(string(this.module.GetType()), UserGetTujianResp, rsp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
|
Loading…
Reference in New Issue
Block a user