修改英雄叠加逻辑
This commit is contained in:
parent
cba8bb0ec4
commit
d49aae3ab7
@ -96,23 +96,31 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (hero *pb.DBHe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//叠加英雄 count叠加数量
|
//初始化可叠加的英雄
|
||||||
func (this *ModelHero) createHeroOverlying(uid string, heroCfgId, count int32) (hero *pb.DBHero, err error) {
|
func (this *ModelHero) initHeroOverlying(uid string, heroCfgId, count int32) (hero *pb.DBHero, err error) {
|
||||||
heroes := this.moduleHero.modelHero.getHeroList(uid)
|
|
||||||
if len(heroes) == 0 {
|
|
||||||
hero = this.initHero(uid, heroCfgId)
|
hero = this.initHero(uid, heroCfgId)
|
||||||
if hero != nil {
|
if hero != nil {
|
||||||
hero.SameCount = count
|
hero.SameCount += count
|
||||||
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
|
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
|
||||||
this.moduleHero.Errorf("%v", err)
|
this.moduleHero.Errorf("%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//叠加英雄 count叠加数量
|
||||||
|
func (this *ModelHero) createHeroOverlying(uid string, heroCfgId, count int32) (hero *pb.DBHero, err error) {
|
||||||
|
heroes := this.moduleHero.modelHero.getHeroList(uid)
|
||||||
|
if len(heroes) == 0 {
|
||||||
|
return this.initHeroOverlying(uid, heroCfgId, count)
|
||||||
} else {
|
} else {
|
||||||
|
var isExist bool
|
||||||
for _, h := range heroes {
|
for _, h := range heroes {
|
||||||
if h.HeroID == heroCfgId &&
|
if h.HeroID == heroCfgId &&
|
||||||
h.IsOverlying {
|
h.IsOverlying {
|
||||||
h.SameCount++
|
isExist = true
|
||||||
|
h.SameCount += count
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"sameCount": h.SameCount, //叠加数
|
"sameCount": h.SameCount, //叠加数
|
||||||
}
|
}
|
||||||
@ -121,8 +129,10 @@ func (this *ModelHero) createHeroOverlying(uid string, heroCfgId, count int32) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !isExist {
|
||||||
|
return this.initHeroOverlying(uid, heroCfgId, count)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user