英雄接口优化

This commit is contained in:
meixiongfeng 2023-08-17 09:33:00 +08:00
parent 9fce1aa3f2
commit f595e78333
3 changed files with 5 additions and 4 deletions

View File

@ -91,7 +91,7 @@ type (
QueryHeroByConfId(uId string, heroCfgId string) (hero *pb.DBHero) QueryHeroByConfId(uId string, heroCfgId string) (hero *pb.DBHero)
// 批量创建英雄 // 批量创建英雄
CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData) CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (atno []*pb.UserAtno, errdata *pb.ErrorData)
// 获取英雄 // 获取英雄
// heroId 英雄ID // heroId 英雄ID
GetHeroByObjID(uid, heroId string) (hero *pb.DBHero, errdata *pb.ErrorData) GetHeroByObjID(uid, heroId string) (hero *pb.DBHero, errdata *pb.ErrorData)

View File

@ -273,11 +273,12 @@ func (this *Hero) EventUserOffline(uid, sessionid string) {
} }
// 批量创建多个英雄 // 批量创建多个英雄
func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, 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 changeList []*pb.DBHero
firstGet []string firstGet []string
bFirst bool bFirst bool
hero *pb.DBHero
) )
for heroCfgId, num := range heros { for heroCfgId, num := range heros {
if num == 0 { // 数量为0 不做处理 if num == 0 { // 数量为0 不做处理

View File

@ -486,7 +486,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
this.Debugf("发放道具资源: %v errdata: %v", items, errdata) this.Debugf("发放道具资源: %v errdata: %v", items, errdata)
} }
if len(heros) > 0 { //卡片资源 if len(heros) > 0 { //卡片资源
_, _, errdata = this.ModuleHero.CreateRepeatHeros(session, heros, bPush) _, errdata = this.ModuleHero.CreateRepeatHeros(session, heros, bPush)
this.Debugf("发放英雄资源: %v errdata: %v", heros, errdata) this.Debugf("发放英雄资源: %v errdata: %v", heros, errdata)
} }
if len(equips) > 0 { if len(equips) > 0 {
@ -718,7 +718,7 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea
this.Debugf("发放道具资源: %v errdata: %v", items, errdata) this.Debugf("发放道具资源: %v errdata: %v", items, errdata)
} }
if len(heros) > 0 { //卡片资源 if len(heros) > 0 { //卡片资源
if _, heroschange, errdata = this.ModuleHero.CreateRepeatHeros(session, heros, bPush); errdata != nil { if heroschange, errdata = this.ModuleHero.CreateRepeatHeros(session, heros, bPush); errdata != nil {
return return
} }
atno = append(atno, heroschange...) atno = append(atno, heroschange...)