From b7e83a63711b3b27d7f20827721e168f0f6ba5b2 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 24 Jun 2022 10:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=8B=B1=E9=9B=84=E8=A3=85?= =?UTF-8?q?=E5=A4=87=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/equipment/api_equip.go | 35 +++++++++++-- modules/equipment/configure_comp.go | 17 ++++++ pb/errorcode.pb.go | 80 ++++++++++++++++------------- 3 files changed, 92 insertions(+), 40 deletions(-) diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 650b7b007..3d1e6775f 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -4,6 +4,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 @@ -11,6 +12,7 @@ func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_E var ( err error errorCode pb.ErrorCode + conf *cfg.Game_equipmentData equipment *pb.DB_Equipment hero *pb.DB_HeroData ) @@ -24,7 +26,13 @@ func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_E code.Code = errorCode return } + if conf, err = this.module.configure_comp.GetEquipmentConfigureById(equipment.CId); err != nil { + log.Errorf("Equip_Check err:%v", err) + code.Code = pb.ErrorCode_EquipmentOnFoundEquipment + return + } result = map[string]interface{}{ + "conf": conf, "equipment": equipment, "hero": hero, } @@ -34,16 +42,37 @@ func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_E ///英雄挂在装备 func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) { var ( - equipment *pb.DB_Equipment - hero *pb.DB_HeroData + err error + conf *cfg.Game_equipmentData + equipment *pb.DB_Equipment + equipments []*pb.DB_Equipment + hero *pb.DB_HeroData ) defer func() { if code == pb.ErrorCode_Success { session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_Equip_Resp{}) } }() + conf = agrs["conf"].(*cfg.Game_equipmentData) equipment = agrs["equipment"].(*pb.DB_Equipment) hero = agrs["hero"].(*pb.DB_HeroData) - + if int(conf.Station) < len(hero.EquipID) { + equipments = make([]*pb.DB_Equipment, len(hero.EquipID)) + for i, v := range hero.EquipID { + if v != "" { + if equipments[i], err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPackById(session.GetUserId(), v); err != nil { + log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err) + code = pb.ErrorCode_SystemError + return + } + } + } + hero.EquipID[conf.Station] = equipment.Id + equipments[conf.Station] = equipment + code = this.module.hero.UpdateEquipment(hero, equipments) + } else { + log.Errorf("Equip conf:%v Station Incorrect range!", conf) + code = pb.ErrorCode_SystemError + } return } diff --git a/modules/equipment/configure_comp.go b/modules/equipment/configure_comp.go index 00121e7b0..dc56d920c 100644 --- a/modules/equipment/configure_comp.go +++ b/modules/equipment/configure_comp.go @@ -40,3 +40,20 @@ func (this *Configure_Comp) GetEquipmentConfigure() (configure *cfg.Game_equipme } return } + +//获取装备配置数据 +func (this *Configure_Comp) GetEquipmentConfigureById(equipmentId int32) (configure *cfg.Game_equipmentData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_equipment); err != nil { + return + } else { + if configure, ok = v.(*cfg.Game_equipment).GetDataMap()[equipmentId]; !ok { + err = fmt.Errorf("EquipmentConfigure not found:%d ", equipmentId) + return + } + } + return +} diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 39c34877e..5c355c705 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -63,6 +63,8 @@ const ( ErrorCode_PackGirdAmountUpper ErrorCode = 1203 //背包格子容量已达上限 // hero ErrorCode_HeroNoExist ErrorCode = 1300 //英雄不存在 + //equipment + ErrorCode_EquipmentOnFoundEquipment ErrorCode = 1400 // 未找到武器 ) // Enum value maps for ErrorCode. @@ -104,44 +106,46 @@ var ( 1202: "PackGridNumUpper", 1203: "PackGirdAmountUpper", 1300: "HeroNoExist", + 1400: "EquipmentOnFoundEquipment", } ErrorCode_value = map[string]int32{ - "Success": 0, - "NoFindService": 10, - "NoFindServiceHandleFunc": 11, - "RpcFuncExecutionError": 12, - "CacheReadError": 13, - "SqlExecutionError": 14, - "ReqParameterError": 15, - "SignError": 16, - "InsufficientPermissions": 17, - "NoLogin": 18, - "UserSessionNobeing": 19, - "StateInvalid": 20, - "DBError": 21, - "SystemError": 22, - "Exception": 100, - "Unknown": 101, - "SecKeyInvalid": 1000, - "SecKey": 1001, - "BindUser": 1002, - "FriendNotSelf": 1100, - "FriendSelfMax": 1101, - "FriendTargetMax": 1102, - "FriendSelfNoData": 1103, - "FriendTargetNoData": 1104, - "FriendYet": 1105, - "FriendApplyYet": 1106, - "FriendSelfBlackYet": 1107, - "FriendTargetBlackYet": 1108, - "FriendApplyError": 1109, - "FriendBlackMax": 1110, - "FriendSearchNameEmpty": 1111, - "PackNoEnough": 1200, - "PackNoFoundGird": 1201, - "PackGridNumUpper": 1202, - "PackGirdAmountUpper": 1203, - "HeroNoExist": 1300, + "Success": 0, + "NoFindService": 10, + "NoFindServiceHandleFunc": 11, + "RpcFuncExecutionError": 12, + "CacheReadError": 13, + "SqlExecutionError": 14, + "ReqParameterError": 15, + "SignError": 16, + "InsufficientPermissions": 17, + "NoLogin": 18, + "UserSessionNobeing": 19, + "StateInvalid": 20, + "DBError": 21, + "SystemError": 22, + "Exception": 100, + "Unknown": 101, + "SecKeyInvalid": 1000, + "SecKey": 1001, + "BindUser": 1002, + "FriendNotSelf": 1100, + "FriendSelfMax": 1101, + "FriendTargetMax": 1102, + "FriendSelfNoData": 1103, + "FriendTargetNoData": 1104, + "FriendYet": 1105, + "FriendApplyYet": 1106, + "FriendSelfBlackYet": 1107, + "FriendTargetBlackYet": 1108, + "FriendApplyError": 1109, + "FriendBlackMax": 1110, + "FriendSearchNameEmpty": 1111, + "PackNoEnough": 1200, + "PackNoFoundGird": 1201, + "PackGridNumUpper": 1202, + "PackGirdAmountUpper": 1203, + "HeroNoExist": 1300, + "EquipmentOnFoundEquipment": 1400, } ) @@ -176,7 +180,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, 0xed, 0x05, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0x8d, 0x06, 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, @@ -223,6 +227,8 @@ var file_errorcode_proto_rawDesc = []byte{ 0x65, 0x72, 0x10, 0xb2, 0x09, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x61, 0x63, 0x6b, 0x47, 0x69, 0x72, 0x64, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x70, 0x70, 0x65, 0x72, 0x10, 0xb3, 0x09, 0x12, 0x10, 0x0a, 0x0b, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0x94, + 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, }