英雄整理
This commit is contained in:
parent
d56c26255d
commit
5066b59911
@ -152,7 +152,7 @@ type (
|
|||||||
// 检查圣桃树奖励是否发放
|
// 检查圣桃树奖励是否发放
|
||||||
CheckPeachReward(session IUserSession, ctime int64)
|
CheckPeachReward(session IUserSession, ctime int64)
|
||||||
|
|
||||||
CreateOneHero(session IUserSession, heroCfgId string, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData)
|
CreateOneHero(session IUserSession, heroCfgId string) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData)
|
||||||
}
|
}
|
||||||
|
|
||||||
//玩家
|
//玩家
|
||||||
|
@ -104,7 +104,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
|||||||
var hero *pb.DBHero
|
var hero *pb.DBHero
|
||||||
firstGet[heroRecord.WishHero] = false
|
firstGet[heroRecord.WishHero] = false
|
||||||
|
|
||||||
if hero, atno, errdata = this.module.ModuleHero.CreateOneHero(session, heroRecord.WishHero, true); errdata == nil {
|
if hero, atno, errdata = this.module.ModuleHero.CreateOneHero(session, heroRecord.WishHero); errdata == nil {
|
||||||
for _, v := range atno {
|
for _, v := range atno {
|
||||||
if v.A == "hero" && v.T == heroRecord.WishHero && v.N == 1 {
|
if v.A == "hero" && v.T == heroRecord.WishHero && v.N == 1 {
|
||||||
firstGet[heroRecord.WishHero] = true
|
firstGet[heroRecord.WishHero] = true
|
||||||
@ -347,7 +347,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
|||||||
|
|
||||||
firstGet[heroId] = false
|
firstGet[heroId] = false
|
||||||
var atno []*pb.UserAtno
|
var atno []*pb.UserAtno
|
||||||
if hero, atno, errdata = this.module.ModuleHero.CreateOneHero(session, heroId, true); errdata == nil {
|
if hero, atno, errdata = this.module.ModuleHero.CreateOneHero(session, heroId); errdata == nil {
|
||||||
for _, v := range atno {
|
for _, v := range atno {
|
||||||
if v.A == "hero" && v.T == heroId && v.N == 1 {
|
if v.A == "hero" && v.T == heroId && v.N == 1 {
|
||||||
firstGet[heroId] = true
|
firstGet[heroId] = true
|
||||||
|
@ -721,15 +721,14 @@ func (this *ModelHero) resetTalentProperty(hero *pb.DBHero) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建一条英雄信息,如果有这个英雄 则转换成对应的碎片
|
// 创建一条英雄信息,如果有这个英雄 则转换成对应的碎片
|
||||||
func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, count int32) (hero *pb.DBHero, bFirst bool, atno []*pb.UserAtno, err error) {
|
func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, count int32) (hero *pb.DBHero, atno []*pb.UserAtno, err error) {
|
||||||
heros := make([]*pb.DBHero, 0)
|
heros := make([]*pb.DBHero, 0)
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
heroCfg, _ := this.module.configure.GetHeroConfig(heroCfgId)
|
heroCfg, _ := this.module.configure.GetHeroConfig(heroCfgId)
|
||||||
|
bFirst := true
|
||||||
if heroCfg == nil {
|
if heroCfg == nil {
|
||||||
err = errors.New("not found hero configID")
|
err = errors.New("not found hero configID")
|
||||||
this.module.Errorf("not found hero configID:%s", heroCfgId)
|
this.module.Errorf("not found hero configID:%s", heroCfgId)
|
||||||
@ -750,7 +749,7 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
|||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bFirst = true
|
|
||||||
for _, obj := range heros {
|
for _, obj := range heros {
|
||||||
if obj.HeroID == heroCfgId {
|
if obj.HeroID == heroCfgId {
|
||||||
hero = obj
|
hero = obj
|
||||||
@ -764,6 +763,7 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if bFirst { // 没有当前英雄
|
if bFirst { // 没有当前英雄
|
||||||
count -= 1
|
count -= 1
|
||||||
hero, err = this.initHeroOverlying(uid, heroCfgId, 1)
|
hero, err = this.initHeroOverlying(uid, heroCfgId, 1)
|
||||||
@ -805,7 +805,6 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if bAdd {
|
if bAdd {
|
||||||
|
|
||||||
res = append(res, heroCfg.Herofrag...)
|
res = append(res, heroCfg.Herofrag...)
|
||||||
for _, v := range heroCfg.Herofrag {
|
for _, v := range heroCfg.Herofrag {
|
||||||
atno = append(atno, &pb.UserAtno{
|
atno = append(atno, &pb.UserAtno{
|
||||||
@ -858,9 +857,7 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c
|
|||||||
N: v.N,
|
N: v.N,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if bChange {
|
if bChange {
|
||||||
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
||||||
|
@ -94,7 +94,7 @@ func (this *Hero) Start() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建单个叠加英雄
|
// 创建单个叠加英雄
|
||||||
func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, bFirst bool, atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
tasks []*pb.BuriedParam
|
tasks []*pb.BuriedParam
|
||||||
@ -107,11 +107,14 @@ func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string,
|
|||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hero, bFirst, atno, err = this.modelHero.createHero(session, heroCfgId, num)
|
hero, atno, err = this.modelHero.createHero(session, heroCfgId, num)
|
||||||
if err == nil && bFirst {
|
if err == nil {
|
||||||
|
for _, v := range atno {
|
||||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype228, cfg.Star))
|
if v.A == "hero" && v.N == 1 {
|
||||||
return
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype228, cfg.Star))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
@ -212,24 +215,24 @@ func (this *Hero) EventUserOffline(uid, sessionid string) {
|
|||||||
// 批量创建多个英雄
|
// 批量创建多个英雄
|
||||||
func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
changeList []*pb.DBHero
|
|
||||||
firstGet []string
|
|
||||||
bFirst bool
|
|
||||||
hero *pb.DBHero
|
|
||||||
szAddHero []string
|
szAddHero []string
|
||||||
|
changeList []*pb.DBHero
|
||||||
|
hero *pb.DBHero
|
||||||
)
|
)
|
||||||
for heroCfgId, num := range heros {
|
for heroCfgId, num := range heros {
|
||||||
if num == 0 { // 数量为0 不做处理
|
if num == 0 { // 数量为0 不做处理
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if hero, bFirst, atno, errdata = this.createRepeatHero(session, heroCfgId, num); errdata != nil {
|
if hero, atno, errdata = this.createRepeatHero(session, heroCfgId, num); errdata != nil {
|
||||||
this.Errorf("create hero %s failed", heroCfgId)
|
this.Errorf("create hero %s failed", heroCfgId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
szAddHero = append(szAddHero, heroCfgId)
|
szAddHero = append(szAddHero, heroCfgId)
|
||||||
if bFirst {
|
for _, v := range atno {
|
||||||
firstGet = append(firstGet, heroCfgId)
|
if v.A == "hero" && v.N == 1 {
|
||||||
changeList = append(changeList, hero)
|
changeList = append(changeList, hero)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if db.IsCross() {
|
if db.IsCross() {
|
||||||
@ -237,19 +240,9 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]
|
|||||||
} else {
|
} else {
|
||||||
go this.moduleFetter.AddHerosFetterData(session.GetUserId(), szAddHero)
|
go this.moduleFetter.AddHerosFetterData(session.GetUserId(), szAddHero)
|
||||||
}
|
}
|
||||||
if bPush { //推送
|
if len(changeList) > 0 {
|
||||||
if len(changeList) > 0 {
|
session.SendMsg("hero", "change", &pb.HeroChangePush{List: changeList})
|
||||||
session.SendMsg("hero", "change", &pb.HeroChangePush{List: changeList})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 首次获得英雄 则推送
|
|
||||||
if len(firstGet) > 0 {
|
|
||||||
session.SendMsg("hero", "firstget", &pb.HeroFirstGetPush{
|
|
||||||
HeroId: firstGet,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1016,36 +1009,31 @@ func (this *Hero) AddHerosExp(session comm.IUserSession, heroObjs []string, exp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获得一个英雄
|
// 获得一个英雄
|
||||||
func (this *Hero) CreateOneHero(session comm.IUserSession, heroCfgId string, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
func (this *Hero) CreateOneHero(session comm.IUserSession, heroCfgId string) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
//hero *pb.DBHero
|
szAddHero []string
|
||||||
firstGet []string
|
changeList []*pb.DBHero
|
||||||
bFirst bool
|
|
||||||
szAddHero []string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if hero, bFirst, atno, errdata = this.createRepeatHero(session, heroCfgId, 1); errdata != nil {
|
if hero, atno, errdata = this.createRepeatHero(session, heroCfgId, 1); errdata != nil {
|
||||||
this.Errorf("create hero %s failed", heroCfgId)
|
this.Errorf("create hero %s failed", heroCfgId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
szAddHero = append(szAddHero, heroCfgId)
|
szAddHero = append(szAddHero, heroCfgId)
|
||||||
if bFirst {
|
|
||||||
firstGet = append(firstGet, heroCfgId)
|
|
||||||
}
|
|
||||||
if db.IsCross() {
|
if db.IsCross() {
|
||||||
go this.moduleFetter.SendRpcAddHero(session.GetUserId(), szAddHero, session.GetServiecTag())
|
go this.moduleFetter.SendRpcAddHero(session.GetUserId(), szAddHero, session.GetServiecTag())
|
||||||
} else {
|
} else {
|
||||||
go this.moduleFetter.AddHerosFetterData(session.GetUserId(), szAddHero) // 异步调用
|
go this.moduleFetter.AddHerosFetterData(session.GetUserId(), szAddHero) // 异步调用
|
||||||
}
|
}
|
||||||
if bPush { //推送
|
for _, v := range atno {
|
||||||
session.SendMsg("hero", "change", &pb.HeroChangePush{List: []*pb.DBHero{hero}})
|
if v.A == "hero" && v.N == 1 {
|
||||||
// 首次获得英雄 则推送
|
changeList = append(changeList, hero)
|
||||||
if len(firstGet) > 0 {
|
break
|
||||||
session.SendMsg("hero", "firstget", &pb.HeroFirstGetPush{
|
|
||||||
HeroId: firstGet,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(changeList) > 0 {
|
||||||
|
session.SendMsg("hero", "change", &pb.HeroChangePush{List: changeList})
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user