From 52e08a5c7aa80d9c76fea1511827611de881cb9a Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 20 Apr 2023 18:42:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E8=B5=8B=E6=A0=91=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/reputation/api_reset.go | 40 +++++++++++++++++++++++++++++++++ pb/reputation_msg.pb.go | 21 ++++++++++++----- 2 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 modules/reputation/api_reset.go diff --git a/modules/reputation/api_reset.go b/modules/reputation/api_reset.go new file mode 100644 index 000000000..695ae2ba8 --- /dev/null +++ b/modules/reputation/api_reset.go @@ -0,0 +1,40 @@ +package reputation + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" +) + +func (this *apiComp) ResetCheck(session comm.IUserSession, req *pb.ReputationTalentresetReq) (code pb.ErrorCode) { + if req.RaceType < 1 && req.RaceType > 4 { + code = pb.ErrorCode_ReqParameterError + } + return +} + +func (this *apiComp) Reset(session comm.IUserSession, req *pb.ReputationTalentresetReq) (code pb.ErrorCode, data *pb.ErrorData) { + uid := session.GetUserId() + reputation := this.module.modelReputation.getDBReputation(uid) + if reputation == nil { + code = pb.ErrorCode_DataNotFound + return + } + + if v, ok := reputation.Camps[req.RaceType]; ok { + v.Nodes = []*pb.TalentNode{} + } + + update := map[string]interface{}{ + "camps": reputation.Camps, + } + + if err := this.module.modelReputation.Change(uid, update); err != nil { + code = pb.ErrorCode_DBError + return + } + + rsp := &pb.ReputationTalentresetResp{} + + session.SendMsg(string(this.module.GetType()), "reset", rsp) + return +} diff --git a/pb/reputation_msg.pb.go b/pb/reputation_msg.pb.go index 39fd18db4..91ecf57e0 100644 --- a/pb/reputation_msg.pb.go +++ b/pb/reputation_msg.pb.go @@ -294,11 +294,13 @@ func (x *ReputationTalentResp) GetCamp() *Camp { return nil } -// 天赋树重置 +// 阵营天赋树重置 type ReputationTalentresetReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + RaceType int32 `protobuf:"varint,1,opt,name=raceType,proto3" json:"raceType"` } func (x *ReputationTalentresetReq) Reset() { @@ -333,6 +335,13 @@ func (*ReputationTalentresetReq) Descriptor() ([]byte, []int) { return file_reputation_reputation_msg_proto_rawDescGZIP(), []int{6} } +func (x *ReputationTalentresetReq) GetRaceType() int32 { + if x != nil { + return x.RaceType + } + return 0 +} + type ReputationTalentresetResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -397,11 +406,13 @@ var file_reputation_reputation_msg_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x61, 0x6d, 0x70, 0x41, 0x74, 0x74, 0x72, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x19, 0x0a, 0x04, 0x63, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x05, 0x2e, 0x43, 0x61, 0x6d, 0x70, 0x52, 0x04, - 0x63, 0x61, 0x6d, 0x70, 0x22, 0x1a, 0x0a, 0x18, 0x72, 0x65, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, + 0x63, 0x61, 0x6d, 0x70, 0x22, 0x36, 0x0a, 0x18, 0x72, 0x65, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x72, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, - 0x22, 0x1b, 0x0a, 0x19, 0x72, 0x65, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, - 0x6c, 0x65, 0x6e, 0x74, 0x72, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x72, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x1b, 0x0a, 0x19, + 0x72, 0x65, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, + 0x72, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (