英雄模块优化
This commit is contained in:
parent
829bd9c6fb
commit
591b39ea39
@ -535,6 +535,12 @@ const (
|
|||||||
Rtype138 TaskType = 138 //在线N分钟(从接到任务开始,记录玩家在线时间并记入进度)
|
Rtype138 TaskType = 138 //在线N分钟(从接到任务开始,记录玩家在线时间并记入进度)
|
||||||
Rtype139 TaskType = 139 //通过融合获得指定英雄(从接到任务开始记录,通过融合获得指定英雄则任务完成)
|
Rtype139 TaskType = 139 //通过融合获得指定英雄(从接到任务开始记录,通过融合获得指定英雄则任务完成)
|
||||||
Rtype140 TaskType = 140 //关卡编辑器完成条件
|
Rtype140 TaskType = 140 //关卡编辑器完成条件
|
||||||
|
Rtype141 TaskType = 141 //成长任务接取抽卡
|
||||||
|
Rtype142 TaskType = 142 //成长任务阵营接取抽卡
|
||||||
|
Rtype143 TaskType = 143 //日常任务接取抽卡
|
||||||
|
Rtype144 TaskType = 144 //日常任务阵营接取抽卡
|
||||||
|
Rtype145 TaskType = 145 //周长任务接取抽卡
|
||||||
|
Rtype146 TaskType = 146 //周长任务阵营接取抽卡
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -45,7 +45,7 @@ type (
|
|||||||
QueryHeroAmount(uId string, heroCfgId string) (amount uint32)
|
QueryHeroAmount(uId string, heroCfgId string) (amount uint32)
|
||||||
|
|
||||||
//创建指定数量
|
//创建指定数量
|
||||||
CreateRepeatHero(session IUserSession, heroCfgId string, num int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode)
|
CreateRepeatHero(session IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode)
|
||||||
// 批量创建英雄
|
// 批量创建英雄
|
||||||
CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode)
|
CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode)
|
||||||
// 获取英雄
|
// 获取英雄
|
||||||
|
@ -74,10 +74,11 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获得新卡
|
// 获得新卡
|
||||||
if newHero, err := this.module.CreateRepeatHero(session, conf.Hero, 1, false); err == pb.ErrorCode_Success {
|
var new map[string]int32
|
||||||
ChangeList = append(ChangeList, newHero)
|
new = make(map[string]int32)
|
||||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: ChangeList})
|
new[conf.Hero] = 1
|
||||||
} else {
|
if _, err := this.module.CreateRepeatHeros(session, new, false); err != pb.ErrorCode_Success {
|
||||||
|
|
||||||
this.module.Errorf("err:%v,create hero:%s,uid,%ss", err, conf.Hero, session.GetUserId())
|
this.module.Errorf("err:%v,create hero:%s,uid,%ss", err, conf.Hero, session.GetUserId())
|
||||||
code = pb.ErrorCode_HeroCreate // 创建新英雄失败
|
code = pb.ErrorCode_HeroCreate // 创建新英雄失败
|
||||||
}
|
}
|
||||||
|
@ -836,9 +836,5 @@ func (this *ModelHero) resetTalentProperty(hero *pb.DBHero) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// _heroMap := make(map[string]interface{}, 0)
|
|
||||||
// _heroMap["talentProperty"] = hero.TalentProperty
|
|
||||||
// if err := this.ChangeList(hero.Uid, hero.Id, _heroMap); err != nil {
|
|
||||||
// this.moduleHero.Errorf("mergeenegryProperty err %v", err)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func (this *Hero) Start() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//创建单个叠加英雄
|
//创建单个叠加英雄
|
||||||
func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) {
|
func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) {
|
||||||
var err error
|
var err error
|
||||||
hero, err = this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num)
|
hero, err = this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -81,33 +81,6 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string,
|
|||||||
} else {
|
} else {
|
||||||
this.moduleFetter.AddHeroFetterData(session.GetUserId(), heroCfgId)
|
this.moduleFetter.AddHeroFetterData(session.GetUserId(), heroCfgId)
|
||||||
}
|
}
|
||||||
heroConf := this.modelHero.moduleHero.configure.GetHeroConfig(heroCfgId)
|
|
||||||
if heroConf == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if result, err1 := this.ModuleUser.GetUserExpand(session.GetUserId()); err1 == nil {
|
|
||||||
initUpdate := map[string]interface{}{}
|
|
||||||
sz := result.GetTujian()
|
|
||||||
if len(sz) == 0 {
|
|
||||||
sz = make(map[string]int32, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := result.GetTujian()[heroCfgId]; !ok {
|
|
||||||
if heroConf.Handbook == -1 {
|
|
||||||
sz[heroCfgId] = 0
|
|
||||||
} else {
|
|
||||||
sz[heroCfgId] = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
initUpdate["tujian"] = sz
|
|
||||||
this.ModuleUser.ChangeUserExpand(session.GetUserId(), initUpdate)
|
|
||||||
// 首次获得英雄 则推送
|
|
||||||
session.SendMsg("hero", "firstget", &pb.HeroFirstGetPush{
|
|
||||||
HeroId: heroCfgId,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//}(session.GetUserId(), heroCfgId)
|
//}(session.GetUserId(), heroCfgId)
|
||||||
// 统计任务
|
// 统计任务
|
||||||
this.ModuleRtask.SendToRtask(session, comm.Rtype1, utils.ToInt32(heroCfgId))
|
this.ModuleRtask.SendToRtask(session, comm.Rtype1, utils.ToInt32(heroCfgId))
|
||||||
@ -119,9 +92,6 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string,
|
|||||||
this.ModuleRtask.SendToRtask(session, comm.Rtype31, 1, cfg.Color)
|
this.ModuleRtask.SendToRtask(session, comm.Rtype31, 1, cfg.Color)
|
||||||
}
|
}
|
||||||
|
|
||||||
if bPush { //推送
|
|
||||||
session.SendMsg("hero", "change", &pb.HeroChangePush{List: []*pb.DBHero{hero}})
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
code = pb.ErrorCode_HeroCreate
|
code = pb.ErrorCode_HeroCreate
|
||||||
@ -289,14 +259,52 @@ func (this *Hero) EventUserOffline(session comm.IUserSession) {
|
|||||||
|
|
||||||
// 批量创建多个英雄
|
// 批量创建多个英雄
|
||||||
func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) {
|
func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) {
|
||||||
|
var (
|
||||||
|
changeList []*pb.DBHero
|
||||||
|
firstGet []string
|
||||||
|
)
|
||||||
for heroCfgId, num := range heros {
|
for heroCfgId, num := range heros {
|
||||||
if num == 0 { // 数量为0 不做处理
|
if num == 0 { // 数量为0 不做处理
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if hero, code = this.CreateRepeatHero(session, heroCfgId, num, bPush); code != pb.ErrorCode_Success {
|
if hero, code = this.CreateRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success {
|
||||||
this.Errorf("create hero %s failed", heroCfgId)
|
this.Errorf("create hero %s failed", heroCfgId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if result, err1 := this.ModuleUser.GetUserExpand(session.GetUserId()); err1 == nil {
|
||||||
|
initUpdate := map[string]interface{}{}
|
||||||
|
sz := result.GetTujian()
|
||||||
|
if len(sz) == 0 {
|
||||||
|
sz = make(map[string]int32, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := result.GetTujian()[heroCfgId]; !ok {
|
||||||
|
heroConf := this.modelHero.moduleHero.configure.GetHeroConfig(heroCfgId)
|
||||||
|
if heroConf != nil {
|
||||||
|
if heroConf.Handbook == -1 {
|
||||||
|
sz[heroCfgId] = 0
|
||||||
|
} else {
|
||||||
|
sz[heroCfgId] = 1
|
||||||
|
}
|
||||||
|
initUpdate["tujian"] = sz
|
||||||
|
this.ModuleUser.ChangeUserExpand(session.GetUserId(), initUpdate)
|
||||||
|
firstGet = append(firstGet, heroCfgId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
changeList = append(changeList, hero)
|
||||||
|
}
|
||||||
|
|
||||||
|
if bPush && len(changeList) > 0 { //推送
|
||||||
|
session.SendMsg("hero", "change", &pb.HeroChangePush{List: changeList})
|
||||||
|
}
|
||||||
|
// 首次获得英雄 则推送
|
||||||
|
if len(firstGet) > 0 {
|
||||||
|
session.SendMsg("hero", "firstget", &pb.HeroFirstGetPush{
|
||||||
|
HeroId: firstGet,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2190,7 +2190,7 @@ type HeroFirstGetPush struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
HeroId string `protobuf:"bytes,1,opt,name=heroId,proto3" json:"heroId"` //英雄id
|
HeroId []string `protobuf:"bytes,1,rep,name=heroId,proto3" json:"heroId"` //英雄id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *HeroFirstGetPush) Reset() {
|
func (x *HeroFirstGetPush) Reset() {
|
||||||
@ -2225,11 +2225,11 @@ func (*HeroFirstGetPush) Descriptor() ([]byte, []int) {
|
|||||||
return file_hero_hero_msg_proto_rawDescGZIP(), []int{41}
|
return file_hero_hero_msg_proto_rawDescGZIP(), []int{41}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *HeroFirstGetPush) GetHeroId() string {
|
func (x *HeroFirstGetPush) GetHeroId() []string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.HeroId
|
return x.HeroId
|
||||||
}
|
}
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_hero_hero_msg_proto protoreflect.FileDescriptor
|
var File_hero_hero_msg_proto protoreflect.FileDescriptor
|
||||||
@ -2430,7 +2430,7 @@ var file_hero_hero_msg_proto_rawDesc = []byte{
|
|||||||
0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x65, 0x6e, 0x62, 0x75, 0x79, 0x22,
|
0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x65, 0x6e, 0x62, 0x75, 0x79, 0x22,
|
||||||
0x2a, 0x0a, 0x10, 0x48, 0x65, 0x72, 0x6f, 0x46, 0x69, 0x72, 0x73, 0x74, 0x47, 0x65, 0x74, 0x50,
|
0x2a, 0x0a, 0x10, 0x48, 0x65, 0x72, 0x6f, 0x46, 0x69, 0x72, 0x73, 0x74, 0x47, 0x65, 0x74, 0x50,
|
||||||
0x75, 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20,
|
0x75, 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
0x03, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user