From 5a52a1f59a586d591536d26bf0b75a87a9bbf21b Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Fri, 11 Aug 2023 21:07:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/warorder/api_completealltask.go | 166 +++++++++++++++++++ pb/warorder_msg.pb.go | 203 +++++++++++++++++++++--- 2 files changed, 346 insertions(+), 23 deletions(-) create mode 100644 modules/warorder/api_completealltask.go diff --git a/modules/warorder/api_completealltask.go b/modules/warorder/api_completealltask.go new file mode 100644 index 000000000..525061a97 --- /dev/null +++ b/modules/warorder/api_completealltask.go @@ -0,0 +1,166 @@ +package warorder + +import ( + "fmt" + "go_dreamfactory/comm" + "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" +) + +// 参数校验 +func (this *apiComp) CompleteAllTaskCheck(session comm.IUserSession, req *pb.WarorderCompleteAllTaskReq) (errdata *pb.ErrorData) { + + return +} + +// /获取系统公告 +func (this *apiComp) CompleteAllTask(session comm.IUserSession, req *pb.WarorderCompleteAllTaskReq) (errdata *pb.ErrorData) { + var ( + confs map[int32]*cfg.GamePassCheckTaskData + conf *cfg.GamePassCheckTaskData + expconf *cfg.GamePassCheckExpData + info *pb.DBWarorders + dwarorder *pb.DreamWarorder + condiIds []int32 + condis []*pb.ConIProgress + condisMap map[int32]*pb.ConIProgress + completetasks map[int32]bool + err error + ok bool + ) + if errdata = this.CompleteAllTaskCheck(session, req); errdata != nil { + return + } + if confs, err = this.module.configure.getGamePassCheckTask(); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: err.Error(), + } + return + } + if info, err = this.module.model.getUserWarorders(session.GetUserId()); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + + if _, ok = this.module.model.getopentime(req.Rtype); !ok { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_WarorderNoOpen, + Title: pb.ErrorCode_WarorderNoOpen.ToString(), + Message: fmt.Sprintf("Activity:%d no open", req.Rtype), + } + return + } + + if req.Rtype != 4 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + Message: "no rtype", + } + return + } + + if dwarorder, ok = info.Dreamwarorder[req.Rtype]; !ok { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + Message: "no activity", + } + } + condiIds = make([]int32, 0) + for _, v := range dwarorder.Daytasks { + condiIds = append(condiIds, confs[v].Parameter) + } + for _, v := range dwarorder.Weektasks { + condiIds = append(condiIds, confs[v].Parameter) + } + + for _, v := range confs { + if v.Page == 3 { + condiIds = append(condiIds, v.Parameter) + } + } + + if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), condiIds...); err != nil { + return + } + + condisMap = make(map[int32]*pb.ConIProgress) + for _, v := range condis { + condisMap[v.Conid] = v + } + + for _, v := range dwarorder.Completetasks { + completetasks[v] = true + } + + for _, v := range dwarorder.Daytasks { + if _, ok = completetasks[v]; !ok { //未完成 + conf = confs[v] + if condisMap[conf.Parameter].State == pb.BuriedItemFinishState_buried_finish { + dwarorder.Completetasks = append(dwarorder.Completetasks, conf.Id) + if dwarorder.Weekexp < this.module.ModuleTools.GetGlobalConf().Passcheck4WeekMaxExp { + dwarorder.Exp += conf.Score + dwarorder.Weekexp += conf.Score + } else { + dwarorder.Exp += this.module.ModuleTools.GetGlobalConf().Passcheck4WeekMaxExp - dwarorder.Weekexp + dwarorder.Weekexp = this.module.ModuleTools.GetGlobalConf().Passcheck4WeekMaxExp + } + } + } + } + for _, v := range dwarorder.Weektasks { + if _, ok = completetasks[v]; !ok { //未完成 + conf = confs[v] + if condisMap[conf.Parameter].State == pb.BuriedItemFinishState_buried_finish { + dwarorder.Completetasks = append(dwarorder.Completetasks, conf.Id) + if dwarorder.Weekexp < this.module.ModuleTools.GetGlobalConf().Passcheck4WeekMaxExp { + dwarorder.Exp += conf.Score + dwarorder.Weekexp += conf.Score + } else { + dwarorder.Exp += this.module.ModuleTools.GetGlobalConf().Passcheck4WeekMaxExp - dwarorder.Weekexp + dwarorder.Weekexp = this.module.ModuleTools.GetGlobalConf().Passcheck4WeekMaxExp + } + } + } + } + + for _, v := range confs { + if v.Page == 3 { + if _, ok = completetasks[v.Id]; !ok { //未完成 + if condisMap[v.Parameter].State == pb.BuriedItemFinishState_buried_finish { + + conf = confs[v.Id] + dwarorder.Exp += conf.Score + dwarorder.Weekexp += conf.Score + dwarorder.Completetasks = append(dwarorder.Completetasks, conf.Id) + } + } + } + } + if expconf, err = this.module.configure.getWarorderLvByExp(dwarorder.Exp, req.Rtype); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: err.Error(), + } + return + } + dwarorder.Lv = expconf.Id + if err = this.module.model.updateUserWarorders(session.GetUserId(), info); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + session.SendMsg(string(this.module.GetType()), "completealltask", &pb.WarorderCompleteAllTaskResp{Rtype: req.Rtype, Completetasks: dwarorder.Completetasks, Exp: dwarorder.Exp, Lv: dwarorder.Lv}) + return +} diff --git a/pb/warorder_msg.pb.go b/pb/warorder_msg.pb.go index 4547bd25c..98c60e0ac 100644 --- a/pb/warorder_msg.pb.go +++ b/pb/warorder_msg.pb.go @@ -506,6 +506,126 @@ func (x *WarorderCompleteTaskResp) GetLv() int32 { return 0 } +//如梦战令 完成任务 +type WarorderCompleteAllTaskReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rtype int32 `protobuf:"varint,1,opt,name=rtype,proto3" json:"rtype"` +} + +func (x *WarorderCompleteAllTaskReq) Reset() { + *x = WarorderCompleteAllTaskReq{} + if protoimpl.UnsafeEnabled { + mi := &file_warorder_warorder_msg_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WarorderCompleteAllTaskReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WarorderCompleteAllTaskReq) ProtoMessage() {} + +func (x *WarorderCompleteAllTaskReq) ProtoReflect() protoreflect.Message { + mi := &file_warorder_warorder_msg_proto_msgTypes[8] + 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 WarorderCompleteAllTaskReq.ProtoReflect.Descriptor instead. +func (*WarorderCompleteAllTaskReq) Descriptor() ([]byte, []int) { + return file_warorder_warorder_msg_proto_rawDescGZIP(), []int{8} +} + +func (x *WarorderCompleteAllTaskReq) GetRtype() int32 { + if x != nil { + return x.Rtype + } + return 0 +} + +//如梦战令 完成任务 回应 +type WarorderCompleteAllTaskResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rtype int32 `protobuf:"varint,1,opt,name=rtype,proto3" json:"rtype"` + Exp int32 `protobuf:"varint,2,opt,name=exp,proto3" json:"exp"` + Lv int32 `protobuf:"varint,3,opt,name=lv,proto3" json:"lv"` + Completetasks []int32 `protobuf:"varint,4,rep,packed,name=completetasks,proto3" json:"completetasks"` +} + +func (x *WarorderCompleteAllTaskResp) Reset() { + *x = WarorderCompleteAllTaskResp{} + if protoimpl.UnsafeEnabled { + mi := &file_warorder_warorder_msg_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WarorderCompleteAllTaskResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WarorderCompleteAllTaskResp) ProtoMessage() {} + +func (x *WarorderCompleteAllTaskResp) ProtoReflect() protoreflect.Message { + mi := &file_warorder_warorder_msg_proto_msgTypes[9] + 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 WarorderCompleteAllTaskResp.ProtoReflect.Descriptor instead. +func (*WarorderCompleteAllTaskResp) Descriptor() ([]byte, []int) { + return file_warorder_warorder_msg_proto_rawDescGZIP(), []int{9} +} + +func (x *WarorderCompleteAllTaskResp) GetRtype() int32 { + if x != nil { + return x.Rtype + } + return 0 +} + +func (x *WarorderCompleteAllTaskResp) GetExp() int32 { + if x != nil { + return x.Exp + } + return 0 +} + +func (x *WarorderCompleteAllTaskResp) GetLv() int32 { + if x != nil { + return x.Lv + } + return 0 +} + +func (x *WarorderCompleteAllTaskResp) GetCompletetasks() []int32 { + if x != nil { + return x.Completetasks + } + return nil +} + var File_warorder_warorder_msg_proto protoreflect.FileDescriptor var file_warorder_warorder_msg_proto_rawDesc = []byte{ @@ -561,8 +681,19 @@ var file_warorder_warorder_msg_proto_rawDesc = []byte{ 0x03, 0x74, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, - 0x76, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x76, 0x22, 0x32, 0x0a, 0x1a, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x6c, 0x6c, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x12, + 0x14, 0x0a, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x72, 0x74, 0x79, 0x70, 0x65, 0x22, 0x7b, 0x0a, 0x1b, 0x57, 0x61, 0x72, 0x6f, 0x72, 0x64, 0x65, + 0x72, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x6c, 0x6c, 0x54, 0x61, 0x73, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x78, + 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, 0x12, 0x0e, 0x0a, 0x02, + 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x24, 0x0a, 0x0d, + 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x05, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x74, 0x61, 0x73, + 0x6b, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -577,29 +708,31 @@ func file_warorder_warorder_msg_proto_rawDescGZIP() []byte { return file_warorder_warorder_msg_proto_rawDescData } -var file_warorder_warorder_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_warorder_warorder_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_warorder_warorder_msg_proto_goTypes = []interface{}{ - (*WarorderInfoReq)(nil), // 0: WarorderInfoReq - (*WarorderInfoResp)(nil), // 1: WarorderInfoResp - (*WarorderReceiveReq)(nil), // 2: WarorderReceiveReq - (*WarorderReceiveResp)(nil), // 3: WarorderReceiveResp - (*WarorderBuyLvReq)(nil), // 4: WarorderBuyLvReq - (*WarorderBuyLvResp)(nil), // 5: WarorderBuyLvResp - (*WarorderCompleteTaskReq)(nil), // 6: WarorderCompleteTaskReq - (*WarorderCompleteTaskResp)(nil), // 7: WarorderCompleteTaskResp - (*Warorder)(nil), // 8: Warorder - (*DreamWarorder)(nil), // 9: DreamWarorder - (*ConIProgress)(nil), // 10: ConIProgress - (*UserAssets)(nil), // 11: UserAssets + (*WarorderInfoReq)(nil), // 0: WarorderInfoReq + (*WarorderInfoResp)(nil), // 1: WarorderInfoResp + (*WarorderReceiveReq)(nil), // 2: WarorderReceiveReq + (*WarorderReceiveResp)(nil), // 3: WarorderReceiveResp + (*WarorderBuyLvReq)(nil), // 4: WarorderBuyLvReq + (*WarorderBuyLvResp)(nil), // 5: WarorderBuyLvResp + (*WarorderCompleteTaskReq)(nil), // 6: WarorderCompleteTaskReq + (*WarorderCompleteTaskResp)(nil), // 7: WarorderCompleteTaskResp + (*WarorderCompleteAllTaskReq)(nil), // 8: WarorderCompleteAllTaskReq + (*WarorderCompleteAllTaskResp)(nil), // 9: WarorderCompleteAllTaskResp + (*Warorder)(nil), // 10: Warorder + (*DreamWarorder)(nil), // 11: DreamWarorder + (*ConIProgress)(nil), // 12: ConIProgress + (*UserAssets)(nil), // 13: UserAssets } var file_warorder_warorder_msg_proto_depIdxs = []int32{ - 8, // 0: WarorderInfoResp.warorder:type_name -> Warorder - 9, // 1: WarorderInfoResp.dwarorder:type_name -> DreamWarorder - 10, // 2: WarorderInfoResp.conlds:type_name -> ConIProgress - 8, // 3: WarorderReceiveResp.warorder:type_name -> Warorder - 9, // 4: WarorderReceiveResp.dwarorder:type_name -> DreamWarorder - 11, // 5: WarorderReceiveResp.award:type_name -> UserAssets - 9, // 6: WarorderBuyLvResp.info:type_name -> DreamWarorder + 10, // 0: WarorderInfoResp.warorder:type_name -> Warorder + 11, // 1: WarorderInfoResp.dwarorder:type_name -> DreamWarorder + 12, // 2: WarorderInfoResp.conlds:type_name -> ConIProgress + 10, // 3: WarorderReceiveResp.warorder:type_name -> Warorder + 11, // 4: WarorderReceiveResp.dwarorder:type_name -> DreamWarorder + 13, // 5: WarorderReceiveResp.award:type_name -> UserAssets + 11, // 6: WarorderBuyLvResp.info:type_name -> DreamWarorder 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name @@ -712,6 +845,30 @@ func file_warorder_warorder_msg_proto_init() { return nil } } + file_warorder_warorder_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WarorderCompleteAllTaskReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_warorder_warorder_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WarorderCompleteAllTaskResp); 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{ @@ -719,7 +876,7 @@ func file_warorder_warorder_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_warorder_warorder_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 10, NumExtensions: 0, NumServices: 0, },