上传铭刻代码
This commit is contained in:
parent
d6b7440331
commit
285fa0d391
@ -1,6 +1,7 @@
|
||||
package equipment
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
@ -25,6 +26,7 @@ func (this *apiComp) Inscribe(session comm.IUserSession, req *pb.EquipmentInscri
|
||||
hero *pb.DBHero
|
||||
conf *cfg.GameEquipData
|
||||
heroconf *cfg.GameHeroData
|
||||
equipments []*pb.DB_Equipment
|
||||
err error
|
||||
)
|
||||
|
||||
@ -85,6 +87,29 @@ func (this *apiComp) Inscribe(session comm.IUserSession, req *pb.EquipmentInscri
|
||||
equip.Inscribe = req.Heroid
|
||||
equip.Inscribevalue = int32(math.Floor(float64(equip.MainEntry.Value) * float64(conf.EngravingBonus) / float64(1000.0)))
|
||||
|
||||
if equip.HeroId == hero.Id {
|
||||
equipments = make([]*pb.DB_Equipment, 8)
|
||||
for i, v := range hero.EquipID {
|
||||
if v != "" {
|
||||
if v != equip.Id {
|
||||
if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_EquipmentOnFoundEquipment,
|
||||
Title: pb.ErrorCode_EquipmentOnFoundEquipment.ToString(),
|
||||
Message: fmt.Sprintf("装备唯一 id:%s", v),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
equipments[i] = equip
|
||||
}
|
||||
}
|
||||
}
|
||||
if errdata = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equip.Id, map[string]interface{}{
|
||||
"inscribe": equip.Inscribe,
|
||||
"inscribevalue": equip.Inscribevalue,
|
||||
|
108
modules/equipment/api_uninscribe.go
Normal file
108
modules/equipment/api_uninscribe.go
Normal file
@ -0,0 +1,108 @@
|
||||
package equipment
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
// 参数校验
|
||||
func (this *apiComp) UnInscribeCheck(session comm.IUserSession, req *pb.EquipmentUnInscribeReq) (errdata *pb.ErrorData) {
|
||||
if req.Eid == "" || req.Heroid == "" {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Message: "ReqParameter is null",
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 铭刻
|
||||
func (this *apiComp) UnInscribe(session comm.IUserSession, req *pb.EquipmentUnInscribeReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
equip *pb.DB_Equipment
|
||||
hero *pb.DBHero
|
||||
conf *cfg.GameEquipData
|
||||
equipments []*pb.DB_Equipment
|
||||
err error
|
||||
)
|
||||
|
||||
if errdata = this.UnInscribeCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if equip, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.Eid); err != nil {
|
||||
this.module.Errorf("Equip_Check err:%v", err)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_EquipmentOnFoundEquipment,
|
||||
Title: pb.ErrorCode_EquipmentOnFoundEquipment.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if equip.Inscribe == "" {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Message: "equie Inscribe no activation!",
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if conf, err = this.module.configure.GetEquipmentConfigureById(equip.CId); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//消耗
|
||||
if errdata = this.module.ConsumeRes(session, conf.ResetNeed, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
targethero := equip.Inscribe
|
||||
equip.Inscribe = ""
|
||||
equip.Inscribevalue = 0
|
||||
if targethero == equip.HeroId {
|
||||
equipments = make([]*pb.DB_Equipment, 8)
|
||||
if hero, errdata = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), equip.HeroId); errdata != nil {
|
||||
return
|
||||
}
|
||||
for i, v := range hero.EquipID {
|
||||
if v != "" {
|
||||
if v != equip.Id {
|
||||
if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_EquipmentOnFoundEquipment,
|
||||
Title: pb.ErrorCode_EquipmentOnFoundEquipment.ToString(),
|
||||
Message: fmt.Sprintf("装备唯一 id:%s", v),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
equipments[i] = equip
|
||||
}
|
||||
}
|
||||
}
|
||||
if errdata = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equip.Id, map[string]interface{}{
|
||||
"inscribe": equip.Inscribe,
|
||||
"inscribevalue": equip.Inscribevalue,
|
||||
}); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "uninscribe", &pb.EquipmentUnInscribeResp{})
|
||||
return
|
||||
}
|
@ -399,6 +399,9 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
|
||||
}
|
||||
hero.EquipID[i] = v.Id
|
||||
addProperty[v.MainEntry.AttrName] += v.MainEntry.Value //主属性
|
||||
if v.Inscribe == hero.Id { //铭刻生效
|
||||
addProperty[v.MainEntry.AttrName] += v.Inscribevalue
|
||||
}
|
||||
for _, v := range v.AdverbEntry {
|
||||
addProperty[v.AttrName] += v.Value + v.EnchValue //附加属性
|
||||
}
|
||||
@ -469,6 +472,8 @@ func (this *ModelHero) mergeAddProperty(uid string, hero *pb.DBHero, data map[in
|
||||
"addProperty": data,
|
||||
"equipSkill": skills,
|
||||
"fightvalue": hero.Fightvalue,
|
||||
"suits": hero.Suits,
|
||||
"equipID": hero.EquipID,
|
||||
}); err != nil {
|
||||
this.module.Errorf("mergeAddProperty err %v", err)
|
||||
}
|
||||
|
@ -156,17 +156,17 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq
|
||||
}
|
||||
|
||||
list := make([]*pb.DBHero, 0)
|
||||
if newHero, err := this.modelHero.setEquipment(session.GetUserId(), hero); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroEquipUpdate,
|
||||
Title: pb.ErrorCode_HeroEquipUpdate.ToString(),
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if newHero != nil {
|
||||
list = append(list, newHero)
|
||||
}
|
||||
}
|
||||
// if newHero, err := this.modelHero.setEquipment(session.GetUserId(), hero); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
// Code: pb.ErrorCode_HeroEquipUpdate,
|
||||
// Title: pb.ErrorCode_HeroEquipUpdate.ToString(),
|
||||
// }
|
||||
// return
|
||||
// } else {
|
||||
// if newHero != nil {
|
||||
// list = append(list, newHero)
|
||||
// }
|
||||
// }
|
||||
list = append(list, hero)
|
||||
|
||||
this.modelHero.setEquipProperty(hero, equip)
|
||||
|
@ -1169,6 +1169,101 @@ func (*EquipmentInscribeResp) Descriptor() ([]byte, []int) {
|
||||
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{20}
|
||||
}
|
||||
|
||||
//装备铭刻 请求
|
||||
type EquipmentUnInscribeReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Eid string `protobuf:"bytes,1,opt,name=eid,proto3" json:"eid"`
|
||||
Heroid string `protobuf:"bytes,2,opt,name=heroid,proto3" json:"heroid"`
|
||||
}
|
||||
|
||||
func (x *EquipmentUnInscribeReq) Reset() {
|
||||
*x = EquipmentUnInscribeReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_equipment_equipment_msg_proto_msgTypes[21]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *EquipmentUnInscribeReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*EquipmentUnInscribeReq) ProtoMessage() {}
|
||||
|
||||
func (x *EquipmentUnInscribeReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_equipment_equipment_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 EquipmentUnInscribeReq.ProtoReflect.Descriptor instead.
|
||||
func (*EquipmentUnInscribeReq) Descriptor() ([]byte, []int) {
|
||||
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{21}
|
||||
}
|
||||
|
||||
func (x *EquipmentUnInscribeReq) GetEid() string {
|
||||
if x != nil {
|
||||
return x.Eid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *EquipmentUnInscribeReq) GetHeroid() string {
|
||||
if x != nil {
|
||||
return x.Heroid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
//装备铭刻 请求回应
|
||||
type EquipmentUnInscribeResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *EquipmentUnInscribeResp) Reset() {
|
||||
*x = EquipmentUnInscribeResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_equipment_equipment_msg_proto_msgTypes[22]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *EquipmentUnInscribeResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*EquipmentUnInscribeResp) ProtoMessage() {}
|
||||
|
||||
func (x *EquipmentUnInscribeResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_equipment_equipment_msg_proto_msgTypes[22]
|
||||
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 EquipmentUnInscribeResp.ProtoReflect.Descriptor instead.
|
||||
func (*EquipmentUnInscribeResp) Descriptor() ([]byte, []int) {
|
||||
return file_equipment_equipment_msg_proto_rawDescGZIP(), []int{22}
|
||||
}
|
||||
|
||||
var File_equipment_equipment_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_equipment_equipment_msg_proto_rawDesc = []byte{
|
||||
@ -1278,8 +1373,14 @@ var file_equipment_equipment_msg_proto_rawDesc = []byte{
|
||||
0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f,
|
||||
0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64,
|
||||
0x22, 0x17, 0x0a, 0x15, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x73,
|
||||
0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x42, 0x0a, 0x16, 0x45, 0x71, 0x75,
|
||||
0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x49, 0x6e, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65,
|
||||
0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x03, 0x65, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x22, 0x19, 0x0a,
|
||||
0x17, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x49, 0x6e, 0x73, 0x63,
|
||||
0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -1294,7 +1395,7 @@ func file_equipment_equipment_msg_proto_rawDescGZIP() []byte {
|
||||
return file_equipment_equipment_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_equipment_equipment_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 21)
|
||||
var file_equipment_equipment_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 23)
|
||||
var file_equipment_equipment_msg_proto_goTypes = []interface{}{
|
||||
(*EquipmentGetListReq)(nil), // 0: EquipmentGetListReq
|
||||
(*EquipmentGetListResp)(nil), // 1: EquipmentGetListResp
|
||||
@ -1317,23 +1418,25 @@ var file_equipment_equipment_msg_proto_goTypes = []interface{}{
|
||||
(*EquipmentEnchResp)(nil), // 18: EquipmentEnchResp
|
||||
(*EquipmentInscribeReq)(nil), // 19: EquipmentInscribeReq
|
||||
(*EquipmentInscribeResp)(nil), // 20: EquipmentInscribeResp
|
||||
(*DB_Equipment)(nil), // 21: DB_Equipment
|
||||
(*DB_EquipmentSuit)(nil), // 22: DB_EquipmentSuit
|
||||
(*UserAtno)(nil), // 23: UserAtno
|
||||
(*EquipmentAttributeEntry)(nil), // 24: EquipmentAttributeEntry
|
||||
(*EquipmentSkillEntry)(nil), // 25: EquipmentSkillEntry
|
||||
(*EquipmentUnInscribeReq)(nil), // 21: EquipmentUnInscribeReq
|
||||
(*EquipmentUnInscribeResp)(nil), // 22: EquipmentUnInscribeResp
|
||||
(*DB_Equipment)(nil), // 23: DB_Equipment
|
||||
(*DB_EquipmentSuit)(nil), // 24: DB_EquipmentSuit
|
||||
(*UserAtno)(nil), // 25: UserAtno
|
||||
(*EquipmentAttributeEntry)(nil), // 26: EquipmentAttributeEntry
|
||||
(*EquipmentSkillEntry)(nil), // 27: EquipmentSkillEntry
|
||||
}
|
||||
var file_equipment_equipment_msg_proto_depIdxs = []int32{
|
||||
21, // 0: EquipmentGetListResp.Equipments:type_name -> DB_Equipment
|
||||
21, // 1: EquipmentChangePush.Equipments:type_name -> DB_Equipment
|
||||
21, // 2: EquipmentEquipResp.Equipments:type_name -> DB_Equipment
|
||||
22, // 3: EquipmentEquipResp.Suits:type_name -> DB_EquipmentSuit
|
||||
21, // 4: EquipmentUpgradeResp.Equipment:type_name -> DB_Equipment
|
||||
22, // 5: EquipmentUpgradeResp.Suits:type_name -> DB_EquipmentSuit
|
||||
23, // 6: EquipmentSellResp.reward:type_name -> UserAtno
|
||||
23, // 7: EquipmentForgResp.reward:type_name -> UserAtno
|
||||
24, // 8: EquipmentWashResp.adverbEntry:type_name -> EquipmentAttributeEntry
|
||||
25, // 9: EquipmentWashResp.adverbSkill:type_name -> EquipmentSkillEntry
|
||||
23, // 0: EquipmentGetListResp.Equipments:type_name -> DB_Equipment
|
||||
23, // 1: EquipmentChangePush.Equipments:type_name -> DB_Equipment
|
||||
23, // 2: EquipmentEquipResp.Equipments:type_name -> DB_Equipment
|
||||
24, // 3: EquipmentEquipResp.Suits:type_name -> DB_EquipmentSuit
|
||||
23, // 4: EquipmentUpgradeResp.Equipment:type_name -> DB_Equipment
|
||||
24, // 5: EquipmentUpgradeResp.Suits:type_name -> DB_EquipmentSuit
|
||||
25, // 6: EquipmentSellResp.reward:type_name -> UserAtno
|
||||
25, // 7: EquipmentForgResp.reward:type_name -> UserAtno
|
||||
26, // 8: EquipmentWashResp.adverbEntry:type_name -> EquipmentAttributeEntry
|
||||
27, // 9: EquipmentWashResp.adverbSkill:type_name -> EquipmentSkillEntry
|
||||
10, // [10:10] is the sub-list for method output_type
|
||||
10, // [10:10] is the sub-list for method input_type
|
||||
10, // [10:10] is the sub-list for extension type_name
|
||||
@ -1601,6 +1704,30 @@ func file_equipment_equipment_msg_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_equipment_equipment_msg_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*EquipmentUnInscribeReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_equipment_equipment_msg_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*EquipmentUnInscribeResp); 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{
|
||||
@ -1608,7 +1735,7 @@ func file_equipment_equipment_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_equipment_equipment_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 21,
|
||||
NumMessages: 23,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
1068
pb/errorcode.pb.go
1068
pb/errorcode.pb.go
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user