From cbb23917c04d81b7adf6b22261eca9f838d4d0ea Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 27 Mar 2023 19:55:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=96=E7=95=8C=E4=BB=BB=E5=8A=A1=E5=A4=9A?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dispatch/model_dispatch.go | 3 +- modules/worldtask/api_chapteraward.go | 21 ++++ modules/worldtask/api_finish.go | 33 +++--- pb/worldtask_msg.pb.go | 162 +++++++++++++++++++++++--- 4 files changed, 182 insertions(+), 37 deletions(-) create mode 100644 modules/worldtask/api_chapteraward.go diff --git a/modules/dispatch/model_dispatch.go b/modules/dispatch/model_dispatch.go index a7688fffa..0c8bef5b5 100644 --- a/modules/dispatch/model_dispatch.go +++ b/modules/dispatch/model_dispatch.go @@ -446,10 +446,9 @@ func (this *modelDispatch) updateNotice(uid string, dispatch *pb.DBDispatch) err count := len(dispatch.Nb.Tasks) if count < 6 { randCount = 6 - count + dispatch.Nb.Tasks = append(dispatch.Nb.Tasks, this.addRandomTask(uid, dispatch, randCount)...) } - dispatch.Nb.Tasks = this.addRandomTask(uid, dispatch, randCount) - //判断是否有下一等级 nextConf, err := this.module.configure.getDispatchLvConf(dispatch.Nb.Lv + 1) if nextConf != nil { diff --git a/modules/worldtask/api_chapteraward.go b/modules/worldtask/api_chapteraward.go new file mode 100644 index 000000000..3ba31d186 --- /dev/null +++ b/modules/worldtask/api_chapteraward.go @@ -0,0 +1,21 @@ +package worldtask + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "github.com/golang/protobuf/proto" +) + +// 章节奖励领取 + +func (this *apiComp) ChapterawardCheck(session comm.IUserSession, req *pb.WorldtaskChapterawardReq) (code pb.ErrorCode) { + if req.GroupId <= 0 { + code = pb.ErrorCode_ReqParameterError + } + return +} + +func (this *apiComp) Chapteraward(session comm.IUserSession, req *pb.WorldtaskChapterawardReq) (code pb.ErrorCode, data proto.Message) { + return +} diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 680ff202e..91b830a01 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -90,15 +90,13 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe userTask.CurrentTask = make(map[int32]*pb.Worldtask) } - if req.GroupId != nextTaskId { - userTask.CurrentTask[nextTaskConf.Group] = &pb.Worldtask{ - TaskId: nextTaskId, - } - return userTask - } - if len(nextTaskConf.Completetask) == 1 && nextTaskConf.Completetask[0] == 0 { - userTask.CurrentTask[nextTaskConf.Group].CondiIds = []int32{} + wt := &pb.Worldtask{ + TaskId: nextTaskId, + TaskType: nextTaskConf.Des, + CondiIds: []int32{}, + } + userTask.CurrentTask[nextTaskConf.Group] = wt } else { for _, condiId := range nextTaskConf.Completetask { if condiId == 0 { @@ -117,6 +115,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe condiIds := []int32{condiId} userTask.CurrentTask[nextTaskConf.Group] = &pb.Worldtask{ TaskId: nextTaskId, + TaskType: nextTaskConf.Des, CondiIds: condiIds, } } @@ -125,11 +124,6 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe } } } - //设置当前进行的任务 - userTask.CurrentTask[curTaskConf.Group] = &pb.Worldtask{ - TaskId: nextTaskId, - TaskType: nextTaskConf.Des, - } update := map[string]interface{}{ "currentTask": userTask.CurrentTask, @@ -159,9 +153,6 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe for k, v := range userTask.CurrentTask { nextTask[k] = &pb.Worldtask{ TaskId: v.TaskId, - // CondiIds: v.CondiIds, - // NpcStatus: v.NpcStatus, - // DeliverNpc: v.DeliverNpc, } } } @@ -174,9 +165,15 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe code = pb.ErrorCode_SystemError return } - + } else { + // if _, ok := utils.Findx(userTask.Chapters, req.GroupId); !ok { + // userTask.Chapters = append(userTask.Chapters, req.GroupId) + // update := map[string]interface{}{ + // "chapters": userTask.Chapters, + // } + // this.module.modelWorldtask.Change(uid, update) + // } } - } finishCall := func() { diff --git a/pb/worldtask_msg.pb.go b/pb/worldtask_msg.pb.go index 3f91bae49..7e1e8de85 100644 --- a/pb/worldtask_msg.pb.go +++ b/pb/worldtask_msg.pb.go @@ -837,6 +837,101 @@ func (x *WorldtaskFinishIdsPush) GetTaskList() []*Worldtask { return nil } +// 章节奖励领取 +type WorldtaskChapterawardReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GroupId int32 `protobuf:"varint,1,opt,name=groupId,proto3" json:"groupId"` +} + +func (x *WorldtaskChapterawardReq) Reset() { + *x = WorldtaskChapterawardReq{} + if protoimpl.UnsafeEnabled { + mi := &file_worldtask_worldtask_msg_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WorldtaskChapterawardReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WorldtaskChapterawardReq) ProtoMessage() {} + +func (x *WorldtaskChapterawardReq) ProtoReflect() protoreflect.Message { + mi := &file_worldtask_worldtask_msg_proto_msgTypes[15] + 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 WorldtaskChapterawardReq.ProtoReflect.Descriptor instead. +func (*WorldtaskChapterawardReq) Descriptor() ([]byte, []int) { + return file_worldtask_worldtask_msg_proto_rawDescGZIP(), []int{15} +} + +func (x *WorldtaskChapterawardReq) GetGroupId() int32 { + if x != nil { + return x.GroupId + } + return 0 +} + +type WorldtaskChapterawardResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GroupId int32 `protobuf:"varint,1,opt,name=groupId,proto3" json:"groupId"` +} + +func (x *WorldtaskChapterawardResp) Reset() { + *x = WorldtaskChapterawardResp{} + if protoimpl.UnsafeEnabled { + mi := &file_worldtask_worldtask_msg_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WorldtaskChapterawardResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WorldtaskChapterawardResp) ProtoMessage() {} + +func (x *WorldtaskChapterawardResp) ProtoReflect() protoreflect.Message { + mi := &file_worldtask_worldtask_msg_proto_msgTypes[16] + 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 WorldtaskChapterawardResp.ProtoReflect.Descriptor instead. +func (*WorldtaskChapterawardResp) Descriptor() ([]byte, []int) { + return file_worldtask_worldtask_msg_proto_rawDescGZIP(), []int{16} +} + +func (x *WorldtaskChapterawardResp) GetGroupId() int32 { + if x != nil { + return x.GroupId + } + return 0 +} + var File_worldtask_worldtask_msg_proto protoreflect.FileDescriptor var file_worldtask_worldtask_msg_proto_rawDesc = []byte{ @@ -925,8 +1020,15 @@ var file_worldtask_worldtask_msg_proto_rawDesc = []byte{ 0x16, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x49, 0x64, 0x73, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x57, 0x6f, 0x72, 0x6c, - 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x22, + 0x34, 0x0a, 0x18, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x43, 0x68, 0x61, 0x70, + 0x74, 0x65, 0x72, 0x61, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x49, 0x64, 0x22, 0x35, 0x0a, 0x19, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, + 0x73, 0x6b, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x61, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -941,7 +1043,7 @@ func file_worldtask_worldtask_msg_proto_rawDescGZIP() []byte { return file_worldtask_worldtask_msg_proto_rawDescData } -var file_worldtask_worldtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_worldtask_worldtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_worldtask_worldtask_msg_proto_goTypes = []interface{}{ (*WorldtaskMineReq)(nil), // 0: WorldtaskMineReq (*WorldtaskMineResp)(nil), // 1: WorldtaskMineResp @@ -958,21 +1060,23 @@ var file_worldtask_worldtask_msg_proto_goTypes = []interface{}{ (*WorldtaskBattleFinishReq)(nil), // 12: WorldtaskBattleFinishReq (*WorldtaskBattleFinishResp)(nil), // 13: WorldtaskBattleFinishResp (*WorldtaskFinishIdsPush)(nil), // 14: WorldtaskFinishIdsPush - nil, // 15: WorldtaskNexttaskPush.NextTaskEntry - (*DBWorldtask)(nil), // 16: DBWorldtask - (*BattleFormation)(nil), // 17: BattleFormation - (*BattleInfo)(nil), // 18: BattleInfo - (*BattleReport)(nil), // 19: BattleReport - (*Worldtask)(nil), // 20: Worldtask + (*WorldtaskChapterawardReq)(nil), // 15: WorldtaskChapterawardReq + (*WorldtaskChapterawardResp)(nil), // 16: WorldtaskChapterawardResp + nil, // 17: WorldtaskNexttaskPush.NextTaskEntry + (*DBWorldtask)(nil), // 18: DBWorldtask + (*BattleFormation)(nil), // 19: BattleFormation + (*BattleInfo)(nil), // 20: BattleInfo + (*BattleReport)(nil), // 21: BattleReport + (*Worldtask)(nil), // 22: Worldtask } var file_worldtask_worldtask_msg_proto_depIdxs = []int32{ - 16, // 0: WorldtaskMineResp.task:type_name -> DBWorldtask - 15, // 1: WorldtaskNexttaskPush.nextTask:type_name -> WorldtaskNexttaskPush.NextTaskEntry - 17, // 2: WorldtaskBattleStartReq.battle:type_name -> BattleFormation - 18, // 3: WorldtaskBattleStartResp.info:type_name -> BattleInfo - 19, // 4: WorldtaskBattleFinishReq.report:type_name -> BattleReport - 20, // 5: WorldtaskFinishIdsPush.taskList:type_name -> Worldtask - 20, // 6: WorldtaskNexttaskPush.NextTaskEntry.value:type_name -> Worldtask + 18, // 0: WorldtaskMineResp.task:type_name -> DBWorldtask + 17, // 1: WorldtaskNexttaskPush.nextTask:type_name -> WorldtaskNexttaskPush.NextTaskEntry + 19, // 2: WorldtaskBattleStartReq.battle:type_name -> BattleFormation + 20, // 3: WorldtaskBattleStartResp.info:type_name -> BattleInfo + 21, // 4: WorldtaskBattleFinishReq.report:type_name -> BattleReport + 22, // 5: WorldtaskFinishIdsPush.taskList:type_name -> Worldtask + 22, // 6: WorldtaskNexttaskPush.NextTaskEntry.value:type_name -> Worldtask 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 @@ -1168,6 +1272,30 @@ func file_worldtask_worldtask_msg_proto_init() { return nil } } + file_worldtask_worldtask_msg_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WorldtaskChapterawardReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_worldtask_worldtask_msg_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WorldtaskChapterawardResp); 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{ @@ -1175,7 +1303,7 @@ func file_worldtask_worldtask_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_worldtask_worldtask_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 16, + NumMessages: 18, NumExtensions: 0, NumServices: 0, },