叠加英雄处理
This commit is contained in:
parent
76dfb1651f
commit
62703c4cde
@ -24,7 +24,7 @@ var (
|
||||
fmt.Printf("%d- %v\n", (i + 1), v)
|
||||
}
|
||||
},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
next: func(robot *Robot, rsp proto.Message) {
|
||||
tcs := []*TestCase{}
|
||||
if r, ok := rsp.(*pb.HeroListResp); ok {
|
||||
@ -118,8 +118,8 @@ var (
|
||||
req: &pb.HeroAwakenReq{
|
||||
HeroObjID: heroId,
|
||||
},
|
||||
rsp: &pb.HeroAwakenResp{},
|
||||
//enabled: true,
|
||||
rsp: &pb.HeroAwakenResp{},
|
||||
enabled: true,
|
||||
}
|
||||
tcs = append(tcs, tc3)
|
||||
}
|
||||
|
@ -35,16 +35,16 @@ var user_builders = []*TestCase{
|
||||
{
|
||||
desc: "添加资源",
|
||||
mainType: string(comm.ModuleUser),
|
||||
subType: "addres",
|
||||
subType: user.UserSubTypeAddRes,
|
||||
req: &pb.UserAddResReq{
|
||||
Res: &pb.UserAssets{
|
||||
A: "item",
|
||||
T: "10001",
|
||||
A: "hero",
|
||||
T: "25001",
|
||||
N: 1,
|
||||
},
|
||||
},
|
||||
rsp: &pb.UserAddResResp{},
|
||||
//enabled: true,
|
||||
rsp: &pb.UserAddResResp{},
|
||||
enabled: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,9 @@ type (
|
||||
//查询用户卡片数量
|
||||
QueryHeroAmount(uId string, heroCfgId int32) (amount uint32)
|
||||
//创建新英雄
|
||||
CreateHero(uid string, bPush bool, heroCfgId ...int32) error
|
||||
|
||||
CreateHeroes(uid string, heroCfgId ...int32) error
|
||||
//创建指定数量
|
||||
CreateRepeatHero(uid string, heroCfgId, num int32) (*pb.DBHero, error)
|
||||
// 获取英雄
|
||||
// heroId 英雄ID
|
||||
GetHero(uid, heroId string) (*pb.DBHero, pb.ErrorCode)
|
||||
|
@ -27,7 +27,7 @@ func (this *apiComp) Chouka(session comm.IUserSession, req *pb.HeroChoukaReq) (c
|
||||
}()
|
||||
|
||||
heroCfgIds := req.HeroIds
|
||||
if err := this.module.modelHero.createMultiHero(session.GetUserId(), false, heroCfgIds...); err != nil {
|
||||
if err := this.module.modelHero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil {
|
||||
code = pb.ErrorCode_HeroCreate
|
||||
return
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
return
|
||||
}
|
||||
for i := 0; i < int(v.N); i++ { // 有多少张加多少次
|
||||
this.module.modelHero.createOneHero(session.GetUserId(), int32(value), true)
|
||||
this.module.modelHero.createOneHero(session.GetUserId(), int32(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.createOneHeroObj(session.GetUserId(), req.HeroCoinfigID, false)
|
||||
hero, err := this.module.modelHero.createOneHero(session.GetUserId(), req.HeroCoinfigID)
|
||||
if err != nil {
|
||||
hero.Lv = req.Lv
|
||||
hero.Star = req.Star
|
||||
|
@ -85,26 +85,7 @@ func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData {
|
||||
}
|
||||
|
||||
//创建一个指定的英雄
|
||||
func (this *ModelHero) createOneHero(uid string, heroCfgId int32, bPush bool) (err error) {
|
||||
hero := this.initHero(uid, heroCfgId)
|
||||
if hero != nil {
|
||||
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
|
||||
this.moduleHero.Errorf("%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
// 创建英雄成功 向客户端推送数据
|
||||
if bPush {
|
||||
if session, ok := this.moduleHero.GetUserSession(uid); ok {
|
||||
session.SendMsg(string(this.moduleHero.GetType()), "addhero", &pb.AddNewHeroPush{Hero: hero})
|
||||
err = session.Push()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *ModelHero) createOneHeroObj(uid string, heroCfgId int32, bPush bool) (hero *pb.DBHero, err error) {
|
||||
func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (hero *pb.DBHero, err error) {
|
||||
hero = this.initHero(uid, heroCfgId)
|
||||
if hero != nil {
|
||||
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
|
||||
@ -112,11 +93,33 @@ func (this *ModelHero) createOneHeroObj(uid string, heroCfgId int32, bPush bool)
|
||||
return
|
||||
}
|
||||
}
|
||||
// 创建英雄成功 向客户端推送数据
|
||||
if bPush {
|
||||
if session, ok := this.moduleHero.GetUserSession(uid); ok {
|
||||
session.SendMsg(string(this.moduleHero.GetType()), "addhero", &pb.AddNewHeroPush{Hero: hero})
|
||||
err = session.Push()
|
||||
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 {
|
||||
hero = this.initHero(uid, heroCfgId)
|
||||
if hero != nil {
|
||||
hero.SameCount = count
|
||||
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
|
||||
this.moduleHero.Errorf("%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, h := range heroes {
|
||||
if h.HeroID == heroCfgId &&
|
||||
h.IsOverlying {
|
||||
h.SameCount++
|
||||
data := map[string]interface{}{
|
||||
"sameCount": h.SameCount, //叠加数
|
||||
}
|
||||
if err := this.modifyHeroData(uid, h.Id, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,12 +127,12 @@ func (this *ModelHero) createOneHeroObj(uid string, heroCfgId int32, bPush bool)
|
||||
}
|
||||
|
||||
//创建多个指定的英雄 heroCfgIds可填入多个英雄ID
|
||||
func (this *ModelHero) createMultiHero(uid string, bPush bool, heroCfgIds ...int32) error {
|
||||
func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error {
|
||||
heroes := this.moduleHero.modelHero.getHeroList(uid)
|
||||
|
||||
if len(heroes) == 0 {
|
||||
for _, v := range heroCfgIds {
|
||||
if err := this.createOneHero(uid, v, bPush); err != nil {
|
||||
if _, err := this.createOneHero(uid, v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -154,13 +157,13 @@ func (this *ModelHero) createMultiHero(uid string, bPush bool, heroCfgIds ...int
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := this.createOneHero(uid, v, bPush); err != nil {
|
||||
if _, err := this.createOneHero(uid, v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if err := this.createOneHero(uid, v, bPush); err != nil {
|
||||
if _, err := this.createOneHero(uid, v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,13 @@ func (this *Hero) OnInstallComp() {
|
||||
}
|
||||
|
||||
//创建新英雄
|
||||
func (this *Hero) CreateHero(uid string, bPush bool, heroCfgId ...int32) error {
|
||||
return this.modelHero.createMultiHero(uid, bPush, heroCfgId...)
|
||||
func (this *Hero) CreateHeroes(uid string, heroCfgId ...int32) error {
|
||||
return this.modelHero.createMultiHero(uid, heroCfgId...)
|
||||
}
|
||||
|
||||
//创建叠加英雄
|
||||
func (this *Hero) CreateRepeatHero(uid string, heroCfgId, num int32) (*pb.DBHero, error) {
|
||||
return this.modelHero.createHeroOverlying(uid, heroCfgId, num)
|
||||
}
|
||||
|
||||
//获取英雄
|
||||
|
@ -232,10 +232,19 @@ func (this *ModuleBase) DispenseRes(uid string, res []*cfg.Game_atn, bPush bool)
|
||||
code = this.ModuleItems.AddItem(source, uid, int32(resID), v.N, bPush)
|
||||
} else if v.A == comm.HeroType { //卡片资源
|
||||
resID, _ = strconv.Atoi(v.T)
|
||||
err := this.ModuleHero.CreateHero(uid, bPush, int32(resID))
|
||||
hero, err := this.ModuleHero.CreateRepeatHero(uid, int32(resID), v.N)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_HeroMaxCount
|
||||
}
|
||||
|
||||
// 创建英雄成功 向客户端推送数据
|
||||
if bPush {
|
||||
if session, ok := this.GetUserSession(uid); ok {
|
||||
session.SendMsg("push", "addhero", &pb.AddNewHeroPush{Hero: hero, Count: v.N})
|
||||
err = session.Push()
|
||||
}
|
||||
}
|
||||
|
||||
} else if v.A == comm.EquipmentType {
|
||||
resID, _ = strconv.Atoi(v.T)
|
||||
code = this.ModuleEquipment.AddNewEquipments(source, uid, map[int32]uint32{int32(resID): uint32(v.N)}, bPush)
|
||||
|
@ -69,7 +69,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
||||
//初始化英雄卡
|
||||
if val := this.module.configure.GetGlobalConf("init_hero"); val != "" {
|
||||
defaultHero := utils.TrInt32(val)
|
||||
err = this.hero.CreateHero(session.GetUserId(), true, defaultHero...)
|
||||
err = this.hero.CreateHeroes(session.GetUserId(), defaultHero...)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_HeroInitCreat
|
||||
return
|
||||
|
@ -1321,7 +1321,8 @@ type AddNewHeroPush struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Hero *DBHero `protobuf:"bytes,1,opt,name=hero,proto3" json:"hero"` // 英雄对象
|
||||
Hero *DBHero `protobuf:"bytes,1,opt,name=hero,proto3" json:"hero"` // 英雄对象
|
||||
Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count"` //数量
|
||||
}
|
||||
|
||||
func (x *AddNewHeroPush) Reset() {
|
||||
@ -1363,6 +1364,13 @@ func (x *AddNewHeroPush) GetHero() *DBHero {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *AddNewHeroPush) GetCount() int32 {
|
||||
if x != nil {
|
||||
return x.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// 测试用(获取指定星级等级的英雄)
|
||||
type HeroGetSpecifiedReq struct {
|
||||
state protoimpl.MessageState
|
||||
@ -1607,22 +1615,23 @@ var file_hero_hero_msg_proto_rawDesc = []byte{
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x22,
|
||||
0x2b, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12,
|
||||
0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e,
|
||||
0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x2d, 0x0a, 0x0e,
|
||||
0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x43, 0x0a, 0x0e,
|
||||
0x41, 0x64, 0x64, 0x4e, 0x65, 0x77, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1b,
|
||||
0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44,
|
||||
0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x77, 0x0a, 0x13, 0x48,
|
||||
0x65, 0x72, 0x6f, 0x47, 0x65, 0x74, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x52,
|
||||
0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x68, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x69, 0x6e, 0x66, 0x69,
|
||||
0x67, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x68, 0x65, 0x72, 0x6f, 0x43,
|
||||
0x6f, 0x69, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04,
|
||||
0x73, 0x74, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x02, 0x6c, 0x76, 0x22, 0x33, 0x0a, 0x14, 0x48, 0x65, 0x72, 0x6f, 0x47, 0x65, 0x74, 0x53,
|
||||
0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04,
|
||||
0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48,
|
||||
0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x22, 0x77, 0x0a, 0x13, 0x48, 0x65, 0x72, 0x6f, 0x47, 0x65, 0x74, 0x53, 0x70, 0x65, 0x63,
|
||||
0x69, 0x66, 0x69, 0x65, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x68, 0x65, 0x72, 0x6f,
|
||||
0x43, 0x6f, 0x69, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x0d, 0x68, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x69, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x44, 0x12, 0x16,
|
||||
0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06,
|
||||
0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x72, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0x33, 0x0a, 0x14, 0x48, 0x65,
|
||||
0x72, 0x6f, 0x47, 0x65, 0x74, 0x53, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x52, 0x65,
|
||||
0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x42,
|
||||
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -62,7 +62,7 @@ message HeroStrengthenUpSkillResp {
|
||||
|
||||
// 共鸣英雄
|
||||
message HeroResonanceReq {
|
||||
string heroObjID = 1; // 英雄对象ID
|
||||
string heroObjID = 1; // 英雄对象ID
|
||||
repeated string costObjID = 2; // 消耗对象
|
||||
}
|
||||
|
||||
@ -116,28 +116,27 @@ message HeroProperty {
|
||||
}
|
||||
|
||||
// 英雄锁定
|
||||
message HeroLockReq{
|
||||
string heroid = 1;
|
||||
}
|
||||
message HeroLockReq { string heroid = 1; }
|
||||
|
||||
// 英雄锁定返回
|
||||
message HeroLockResp{
|
||||
DBHero hero = 1; // 英雄对象
|
||||
message HeroLockResp {
|
||||
DBHero hero = 1; // 英雄对象
|
||||
}
|
||||
|
||||
// 增加新英雄推送
|
||||
message AddNewHeroPush{
|
||||
DBHero hero = 1; // 英雄对象
|
||||
message AddNewHeroPush {
|
||||
DBHero hero = 1; // 英雄对象
|
||||
int32 count = 2; //数量
|
||||
}
|
||||
|
||||
// 测试用(获取指定星级等级的英雄)
|
||||
message HeroGetSpecifiedReq{
|
||||
message HeroGetSpecifiedReq {
|
||||
int32 heroCoinfigID = 1; // 英雄配置ID
|
||||
int32 Amount = 2; // 数量
|
||||
int32 star = 3; // 星级
|
||||
int32 lv = 4; // 等级
|
||||
int32 Amount = 2; // 数量
|
||||
int32 star = 3; // 星级
|
||||
int32 lv = 4; // 等级
|
||||
}
|
||||
|
||||
message HeroGetSpecifiedResp{
|
||||
DBHero hero = 1; // 英雄对象
|
||||
message HeroGetSpecifiedResp {
|
||||
DBHero hero = 1; // 英雄对象
|
||||
}
|
Loading…
Reference in New Issue
Block a user