修复卡叠加逻辑

This commit is contained in:
zhaocy 2022-06-29 17:15:05 +08:00
parent 6d03d7b59c
commit dea561817f
10 changed files with 252 additions and 66 deletions

View File

@ -21,8 +21,14 @@ var (
req: &pb.HeroInfoReq{
HeroId: "62baac19aa7c09b3679be57c",
},
rsp: &pb.HeroInfoRsp{},
enabled: true,
rsp: &pb.HeroInfoRsp{},
// enabled: true,
}, {
mainType: string(comm.ModuleHero),
subType: hero.HeroSubTypeChouka,
req: &pb.HeroChoukaReq{},
rsp: &pb.HeroChoukaResp{},
enabled: true,
},
}
)

View File

@ -13,7 +13,7 @@ var user_builders = []*builder{
mainType: string(comm.ModuleUser),
subType: user.UserSubTypeCreate,
req: &pb.UserCreateReq{ //设置请求参数
NickName: "乐谷6281",
NickName: "乐谷62911",
},
rsp: &pb.UserCreateRsp{},
// enabled: true,

View File

@ -14,9 +14,10 @@ type apiComp struct {
}
const ( //消息回复的头名称
StrengthenUplv = "strengthenherolv"
HeroSubTypeInfo = "info" //英雄卡片信息
HeroSubTypeList = "list" //英雄列表
StrengthenUplv = "strengthenherolv"
HeroSubTypeInfo = "info" //英雄卡片信息
HeroSubTypeList = "list" //英雄列表
HeroSubTypeChouka = "chouka" //抽卡
)
//组件初始化接口

View File

@ -2,13 +2,41 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
)
func (this *apiComp) ChoukaCheck() (result map[string]interface{}, code comm.ErrorCode) {
func (this *apiComp) ChoukaCheck(session comm.IUserSession, req *pb.HeroChoukaReq) (result map[string]interface{}, code comm.ErrorCode) {
result = make(map[string]interface{})
return
}
func (this *apiComp) Chouka(session comm.IUserSession, result map[string]interface{}, req *pb.HeroInfoReq) {
//抽卡
func (this *apiComp) Chouka(session comm.IUserSession, result map[string]interface{}, req *pb.HeroChoukaReq) (code pb.ErrorCode) {
rsp := &pb.HeroChoukaResp{}
defer func() {
err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeChouka, rsp)
if err != nil {
code = pb.ErrorCode_SystemError
return
}
utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeChouka, req, rsp)
}()
heroCfgIds := []int32{15001, 25001}
if err := this.moduleHero.modelHero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil {
code = pb.ErrorCode_HeroCreate
return
}
heroes, err := this.moduleHero.modelHero.getHeroList(session.GetUserId())
if err != nil {
log.Errorf("%v", err)
code = pb.ErrorCode_DBError
return
}
rsp.Heroes = heroes
return
}

View File

@ -42,8 +42,10 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero {
NormalSkill: []*pb.SkillData{}, //初始技能
IsOverlying: true, //是否允许叠加,
Block: false, //未锁定
CardType: heroCfg.Type, //卡片类型
Skins: []int32{},
EquipID: make([]string, 6), //初始装备
SameCount: 1, //默认叠加数量
AddProperty: make(map[int32]int32),
Energy: make(map[int32]int32),
Property: make(map[int32]int32),
@ -52,24 +54,12 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero {
}
//创建一个指定的英雄
func (this *ModelHero) createOneHero(uid string, heroCfgId int32) error {
heroes, err := this.getHeroList(uid)
if err != nil {
log.Errorf("%v", err)
return err
}
for _, v := range heroes {
if v.HeroID == heroCfgId {
v.SameCount++
data := map[string]interface{}{
"sameCount": v.SameCount, //叠加数
}
return this.moduleHero.modelHero.Change(uid, data)
} else {
hero := this.initHero(uid, heroCfgId)
if hero != nil {
return this.moduleHero.modelHero.AddList(uid, hero.Id, hero)
}
func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) {
hero := this.initHero(uid, heroCfgId)
if hero != nil {
if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil {
log.Errorf("%v", err)
return
}
}
return nil
@ -77,11 +67,44 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) error {
//创建多个指定的英雄 heroCfgIds可填入多个英雄ID
func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error {
for _, v := range heroCfgIds {
if err := this.createOneHero(uid, v); err != nil {
return err
heroes, err := this.moduleHero.modelHero.getHeroList(uid)
if err != nil {
return err
}
if len(heroes) == 0 {
for _, v := range heroCfgIds {
if err := this.createOneHero(uid, v); err != nil {
return err
}
}
} else {
findHero := func(heroId int32) (*pb.DBHero, bool) {
for _, h := range heroes {
if h.HeroID == heroId {
return h, true
}
}
return nil, false
}
for _, v := range heroCfgIds {
if h, ok := findHero(v); ok {
h.SameCount++
data := map[string]interface{}{
"sameCount": h.SameCount, //叠加数
}
if err := this.modifyHero(uid, h.Id, data); err != nil {
return err
}
} else {
if err := this.createOneHero(uid, v); err != nil {
return err
}
}
}
}
return nil
}

View File

@ -56,7 +56,7 @@ func (this *Mail) CreateNewMail(uId string) {
log.Error("create mail failed")
}
// 通知玩家
var _cache = &pb.Cache_UserData{}
var _cache = &pb.CacheUser{}
err = this.modelMail.MCompModel.Get(uId, _cache)
if err == nil {
return

View File

@ -73,6 +73,7 @@ const (
ErrorCode_HeroMaxLv ErrorCode = 1302 //英雄达到最大等级
ErrorCode_HeroInitCreat ErrorCode = 1303 //初始化英雄
ErrorCode_HeroColorErr ErrorCode = 1304 // 品质不匹配
ErrorCode_HeroCreate ErrorCode = 1305 // 创建卡失败
// equipment
ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器
ErrorCode_EquipmentLvlimitReached ErrorCode = 1401 // 武器等级已达上限
@ -127,6 +128,7 @@ var (
1302: "HeroMaxLv",
1303: "HeroInitCreat",
1304: "HeroColorErr",
1305: "HeroCreate",
1400: "EquipmentOnFoundEquipment",
1401: "EquipmentLvlimitReached",
}
@ -177,6 +179,7 @@ var (
"HeroMaxLv": 1302,
"HeroInitCreat": 1303,
"HeroColorErr": 1304,
"HeroCreate": 1305,
"EquipmentOnFoundEquipment": 1400,
"EquipmentLvlimitReached": 1401,
}
@ -213,7 +216,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xf4, 0x07, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0x85, 0x08, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@ -272,12 +275,13 @@ var file_errorcode_proto_rawDesc = []byte{
0x10, 0x95, 0x0a, 0x12, 0x0e, 0x0a, 0x09, 0x48, 0x65, 0x72, 0x6f, 0x4d, 0x61, 0x78, 0x4c, 0x76,
0x10, 0x96, 0x0a, 0x12, 0x12, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x69, 0x74, 0x43,
0x72, 0x65, 0x61, 0x74, 0x10, 0x97, 0x0a, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x43,
0x6f, 0x6c, 0x6f, 0x72, 0x45, 0x72, 0x72, 0x10, 0x98, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45, 0x71,
0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x71,
0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45, 0x71,
0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65,
0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6f, 0x6c, 0x6f, 0x72, 0x45, 0x72, 0x72, 0x10, 0x98, 0x0a, 0x12, 0x0f, 0x0a, 0x0a, 0x48, 0x65,
0x72, 0x6f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x10, 0x99, 0x0a, 0x12, 0x1e, 0x0a, 0x19, 0x45,
0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45,
0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0xf8, 0x0a, 0x12, 0x1c, 0x0a, 0x17, 0x45,
0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x76, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x52,
0x65, 0x61, 0x63, 0x68, 0x65, 0x64, 0x10, 0xf9, 0x0a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -1076,6 +1076,92 @@ func (x *HeroJuexingResp) GetHero() *DBHero {
return nil
}
//抽卡
type HeroChoukaReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *HeroChoukaReq) Reset() {
*x = HeroChoukaReq{}
if protoimpl.UnsafeEnabled {
mi := &file_hero_hero_msg_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HeroChoukaReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HeroChoukaReq) ProtoMessage() {}
func (x *HeroChoukaReq) ProtoReflect() protoreflect.Message {
mi := &file_hero_hero_msg_proto_msgTypes[20]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HeroChoukaReq.ProtoReflect.Descriptor instead.
func (*HeroChoukaReq) Descriptor() ([]byte, []int) {
return file_hero_hero_msg_proto_rawDescGZIP(), []int{20}
}
type HeroChoukaResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Heroes []*DBHero `protobuf:"bytes,1,rep,name=heroes,proto3" json:"heroes"`
}
func (x *HeroChoukaResp) Reset() {
*x = HeroChoukaResp{}
if protoimpl.UnsafeEnabled {
mi := &file_hero_hero_msg_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *HeroChoukaResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HeroChoukaResp) ProtoMessage() {}
func (x *HeroChoukaResp) ProtoReflect() protoreflect.Message {
mi := &file_hero_hero_msg_proto_msgTypes[21]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HeroChoukaResp.ProtoReflect.Descriptor instead.
func (*HeroChoukaResp) Descriptor() ([]byte, []int) {
return file_hero_hero_msg_proto_rawDescGZIP(), []int{21}
}
func (x *HeroChoukaResp) GetHeroes() []*DBHero {
if x != nil {
return x.Heroes
}
return nil
}
var File_hero_hero_msg_proto protoreflect.FileDescriptor
var file_hero_hero_msg_proto_rawDesc = []byte{
@ -1172,8 +1258,13 @@ var file_hero_hero_msg_proto_rawDesc = []byte{
0x09, 0x63, 0x6f, 0x73, 0x74, 0x49, 0x74, 0x6d, 0x65, 0x73, 0x22, 0x31, 0x0a, 0x0f, 0x48, 0x65,
0x72, 0x6f, 0x4a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a,
0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62,
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,
0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x0f, 0x0a,
0x0d, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x22, 0x34,
0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70,
0x12, 0x22, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65,
0x72, 0x6f, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1188,7 +1279,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte {
return file_hero_hero_msg_proto_rawDescData
}
var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 20)
var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
var file_hero_hero_msg_proto_goTypes = []interface{}{
(*HeroInfoReq)(nil), // 0: pb.HeroInfoReq
(*HeroInfoRsp)(nil), // 1: pb.HeroInfoRsp
@ -1210,27 +1301,30 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{
(*HeroGongmingUseEnergyResp)(nil), // 17: pb.HeroGongmingUseEnergyResp
(*HeroJuexingReq)(nil), // 18: pb.HeroJuexingReq
(*HeroJuexingResp)(nil), // 19: pb.HeroJuexingResp
(*DBHero)(nil), // 20: pb.DBHero
(*HeroChoukaReq)(nil), // 20: pb.HeroChoukaReq
(*HeroChoukaResp)(nil), // 21: pb.HeroChoukaResp
(*DBHero)(nil), // 22: pb.DBHero
}
var file_hero_hero_msg_proto_depIdxs = []int32{
20, // 0: pb.HeroInfoRsp.base:type_name -> pb.DBHero
20, // 1: pb.HeroListRsp.list:type_name -> pb.DBHero
20, // 2: pb.HeroStrengthenUplvResp.hero:type_name -> pb.DBHero
22, // 0: pb.HeroInfoRsp.base:type_name -> pb.DBHero
22, // 1: pb.HeroListRsp.list:type_name -> pb.DBHero
22, // 2: pb.HeroStrengthenUplvResp.hero:type_name -> pb.DBHero
7, // 3: pb.HeroStrengthenUpStarReq.hero:type_name -> pb.CostCardData
7, // 4: pb.HeroStrengthenUpStarReq.heroRace:type_name -> pb.CostCardData
20, // 5: pb.HeroStrengthenUpStarResp.hero:type_name -> pb.DBHero
20, // 6: pb.HeroStrengthenUpSkillResp.hero:type_name -> pb.DBHero
20, // 7: pb.HeroGongmingResp.hero:type_name -> pb.DBHero
20, // 8: pb.HeroGongmingResp.upStarCard:type_name -> pb.DBHero
20, // 9: pb.HeroGongmingResetResp.hero:type_name -> pb.DBHero
20, // 10: pb.HeroGongmingUseEnergyResp.hero:type_name -> pb.DBHero
22, // 5: pb.HeroStrengthenUpStarResp.hero:type_name -> pb.DBHero
22, // 6: pb.HeroStrengthenUpSkillResp.hero:type_name -> pb.DBHero
22, // 7: pb.HeroGongmingResp.hero:type_name -> pb.DBHero
22, // 8: pb.HeroGongmingResp.upStarCard:type_name -> pb.DBHero
22, // 9: pb.HeroGongmingResetResp.hero:type_name -> pb.DBHero
22, // 10: pb.HeroGongmingUseEnergyResp.hero:type_name -> pb.DBHero
4, // 11: pb.HeroJuexingReq.costItmes:type_name -> pb.ItemData
20, // 12: pb.HeroJuexingResp.hero:type_name -> pb.DBHero
13, // [13:13] is the sub-list for method output_type
13, // [13:13] is the sub-list for method input_type
13, // [13:13] is the sub-list for extension type_name
13, // [13:13] is the sub-list for extension extendee
0, // [0:13] is the sub-list for field type_name
22, // 12: pb.HeroJuexingResp.hero:type_name -> pb.DBHero
22, // 13: pb.HeroChoukaResp.heroes:type_name -> pb.DBHero
14, // [14:14] is the sub-list for method output_type
14, // [14:14] is the sub-list for method input_type
14, // [14:14] is the sub-list for extension type_name
14, // [14:14] is the sub-list for extension extendee
0, // [0:14] is the sub-list for field type_name
}
func init() { file_hero_hero_msg_proto_init() }
@ -1480,6 +1574,30 @@ func file_hero_hero_msg_proto_init() {
return nil
}
}
file_hero_hero_msg_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HeroChoukaReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_hero_hero_msg_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*HeroChoukaResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -1487,7 +1605,7 @@ func file_hero_hero_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_hero_hero_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 20,
NumMessages: 22,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -56,6 +56,7 @@ enum ErrorCode {
HeroMaxLv = 1302; //
HeroInitCreat = 1303; //
HeroColorErr = 1304; //
HeroCreate = 1305; //
// equipment
EquipmentOnFoundEquipment = 1400; //
EquipmentLvlimitReached = 1401; //

View File

@ -25,9 +25,9 @@ message ItemData {
//
message HeroStrengthenUplvReq {
string heroObjID = 1; // ID
string expCardID = 2; // ID
int32 amount = 3; // }
string heroObjID = 1; // ID
string expCardID = 2; // ID
int32 amount = 3; // }
}
//
@ -41,8 +41,8 @@ message CostCardData {
}
//
message HeroStrengthenUpStarReq {
string heroObjID = 1; // ID
repeated CostCardData hero = 2; // ID
string heroObjID = 1; // ID
repeated CostCardData hero = 2; // ID
repeated CostCardData heroRace = 3; // ID
}
@ -70,7 +70,7 @@ message HeroGongmingReq {
message HeroGongmingResp {
DBHero hero = 1; //
int32 energy = 2; //
int32 energy = 2; //
DBHero upStarCard = 3; //
}
@ -80,8 +80,8 @@ message HeroGongmingResetReq {
}
message HeroGongmingResetResp {
DBHero hero = 1; //
int32 energy = 2; //
DBHero hero = 1; //
int32 energy = 2; //
}
// 使
@ -104,4 +104,9 @@ message HeroJuexingReq {
//
message HeroJuexingResp {
DBHero hero = 1; //
}
}
//
message HeroChoukaReq {}
message HeroChoukaResp { repeated DBHero heroes = 1; }