This commit is contained in:
liwei1dao 2022-10-25 17:52:46 +08:00
commit c21fd71eb1
3 changed files with 57 additions and 27 deletions

View File

@ -9,6 +9,9 @@ import (
//参数校验
func (this *apiComp) TalentResetCheck(session comm.IUserSession, req *pb.HeroTalentResetReq) (code pb.ErrorCode) {
if req.ObjId == "" {
code = pb.ErrorCode_ReqParameterError
}
return
}
@ -17,9 +20,21 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
heroList []*pb.DBHero
chanegCard []*pb.DBHero // 推送属性变化
)
if code = this.TalentResetCheck(session, req); code != pb.ErrorCode_Success {
return
}
_talent, err1 := this.module.modelTalent.GetHerotalentByObjId(session.GetUserId(), req.ObjId) //根据对象id 获取数据
if err1 != nil {
code = pb.ErrorCode_TalentErrData
return
}
if len(_talent.Talent) == 0 { // 已经是重置状态
code = pb.ErrorCode_TalentResetState
return
}
chanegCard = make([]*pb.DBHero, 0)
heroList = this.module.GetHeroList(session.GetUserId())
rsp := &pb.HeroTalentResetResp{}
globalCnf := this.module.configure.GetGlobalAtnConf("talent_reset") // 获取重置消耗
if globalCnf == nil {
@ -34,22 +49,24 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
if code = this.module.ConsumeRes(session, globalCnf.Var, true); code != pb.ErrorCode_Success {
return
}
list, _ := this.module.modelTalent.GetHerotalent(session.GetUserId())
for _, v := range list {
if len(v.Talent) > 0 {
update := make(map[string]interface{}, 0)
szTalent := map[int32]int32{}
update["talent"] = szTalent
this.module.modelTalent.ChangeHeroTalent(v, update)
for _, hero := range heroList {
if hero.HeroID == v.HeroId {
this.module.modelHero.cleanTalentProperty(hero)
chanegCard = append(chanegCard, hero) // 添加推送属性变化信息
}
if len(_talent.Talent) > 0 {
update := make(map[string]interface{}, 0)
szTalent := map[int32]int32{}
update["talent"] = szTalent
this.module.modelTalent.ChangeHeroTalent(_talent, update)
heroList = this.module.GetHeroList(session.GetUserId())
for _, hero := range heroList {
if hero.HeroID == _talent.HeroId {
this.module.modelHero.cleanTalentProperty(hero)
chanegCard = append(chanegCard, hero) // 添加推送属性变化信息
}
}
}
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard})
session.SendMsg(string(this.module.GetType()), HeroTalentResetResp, rsp)
session.SendMsg(string(this.module.GetType()), HeroTalentResetResp, &pb.HeroTalentResetResp{
Telnet: _talent,
})
return
}

View File

@ -201,12 +201,15 @@ const (
ErrorCode_SociatyAdded ErrorCode = 3001 //已在公会里
ErrorCode_SociatyDiamondNoEnough ErrorCode = 3002 //钻石不足
ErrorCode_SociatyApply ErrorCode = 3003 //申请失败
ErrorCode_SociatyNoRight ErrorCode = 3004 //无权限
ErrorCode_SociatyNoAdded ErrorCode = 3005 //未加入公会
// arena
ErrorCode_ArenaTicketBuyUp ErrorCode = 3101 //票据上限
// talent
ErrorCode_TalentRepeatLearn ErrorCode = 3201 // 天赋已学习
ErrorCode_TalentErrData ErrorCode = 3202 /// 天赋不存在
ErrorCode_TalentUnLockerBefore ErrorCode = 3203 //先解锁前置天赋
ErrorCode_TalentResetState ErrorCode = 3204 //当前天赋已经是重置状态
)
// Enum value maps for ErrorCode.
@ -371,10 +374,13 @@ var (
3001: "SociatyAdded",
3002: "SociatyDiamondNoEnough",
3003: "SociatyApply",
3004: "SociatyNoRight",
3005: "SociatyNoAdded",
3101: "ArenaTicketBuyUp",
3201: "TalentRepeatLearn",
3202: "TalentErrData",
3203: "TalentUnLockerBefore",
3204: "TalentResetState",
}
ErrorCode_value = map[string]int32{
"Success": 0,
@ -536,10 +542,13 @@ var (
"SociatyAdded": 3001,
"SociatyDiamondNoEnough": 3002,
"SociatyApply": 3003,
"SociatyNoRight": 3004,
"SociatyNoAdded": 3005,
"ArenaTicketBuyUp": 3101,
"TalentRepeatLearn": 3201,
"TalentErrData": 3202,
"TalentUnLockerBefore": 3203,
"TalentResetState": 3204,
}
)
@ -574,7 +583,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, 0xb7, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xf8, 0x1c, 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,
@ -795,14 +804,18 @@ var file_errorcode_proto_rawDesc = []byte{
0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x64, 0x64, 0x65, 0x64, 0x10, 0xb9, 0x17, 0x12, 0x1b, 0x0a,
0x16, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x44, 0x69, 0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x4e,
0x6f, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xba, 0x17, 0x12, 0x11, 0x0a, 0x0c, 0x53, 0x6f,
0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x10, 0xbb, 0x17, 0x12, 0x15, 0x0a,
0x10, 0x41, 0x72, 0x65, 0x6e, 0x61, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x75, 0x79, 0x55,
0x70, 0x10, 0x9d, 0x18, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65,
0x70, 0x65, 0x61, 0x74, 0x4c, 0x65, 0x61, 0x72, 0x6e, 0x10, 0x81, 0x19, 0x12, 0x12, 0x0a, 0x0d,
0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x45, 0x72, 0x72, 0x44, 0x61, 0x74, 0x61, 0x10, 0x82, 0x19,
0x12, 0x19, 0x0a, 0x14, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b,
0x65, 0x72, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x10, 0x83, 0x19, 0x42, 0x06, 0x5a, 0x04, 0x2e,
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x63, 0x69, 0x61, 0x74, 0x79, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x10, 0xbb, 0x17, 0x12, 0x13, 0x0a,
0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, 0x52, 0x69, 0x67, 0x68, 0x74, 0x10,
0xbc, 0x17, 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x6f, 0x41,
0x64, 0x64, 0x65, 0x64, 0x10, 0xbd, 0x17, 0x12, 0x15, 0x0a, 0x10, 0x41, 0x72, 0x65, 0x6e, 0x61,
0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x75, 0x79, 0x55, 0x70, 0x10, 0x9d, 0x18, 0x12, 0x16,
0x0a, 0x11, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x4c, 0x65,
0x61, 0x72, 0x6e, 0x10, 0x81, 0x19, 0x12, 0x12, 0x0a, 0x0d, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74,
0x45, 0x72, 0x72, 0x44, 0x61, 0x74, 0x61, 0x10, 0x82, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x54, 0x61,
0x6c, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x42, 0x65, 0x66, 0x6f,
0x72, 0x65, 0x10, 0x83, 0x19, 0x12, 0x15, 0x0a, 0x10, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x73, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x10, 0x84, 0x19, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -2063,7 +2063,7 @@ type HeroTalentResetResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Telnet []*DBHeroTalent `protobuf:"bytes,1,rep,name=telnet,proto3" json:"telnet"`
Telnet *DBHeroTalent `protobuf:"bytes,1,opt,name=telnet,proto3" json:"telnet"`
}
func (x *HeroTalentResetResp) Reset() {
@ -2098,7 +2098,7 @@ func (*HeroTalentResetResp) Descriptor() ([]byte, []int) {
return file_hero_hero_msg_proto_rawDescGZIP(), []int{39}
}
func (x *HeroTalentResetResp) GetTelnet() []*DBHeroTalent {
func (x *HeroTalentResetResp) GetTelnet() *DBHeroTalent {
if x != nil {
return x.Telnet
}
@ -2290,7 +2290,7 @@ var file_hero_hero_msg_proto_rawDesc = []byte{
0x6f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x62, 0x6a,
0x49, 0x64, 0x22, 0x3c, 0x0a, 0x13, 0x48, 0x65, 0x72, 0x6f, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74,
0x52, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x65, 0x6c,
0x6e, 0x65, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x48, 0x65,
0x6e, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x48, 0x65,
0x72, 0x6f, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x74, 0x65, 0x6c, 0x6e, 0x65, 0x74,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}