From 865d82ae9dda5448c3c56e278198f659fe946f97 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 18 Nov 2022 17:04:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=96=E7=95=8C=E4=BB=BB=E5=8A=A1=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E4=BB=BB=E5=8A=A1=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/worldtask/api_finish.go | 2 +- modules/worldtask/api_mine.go | 14 +++++++++ modules/worldtask/model_worldtask.go | 18 ++++++++---- modules/worldtask/module.go | 19 +++++++----- pb/worldtask_db.pb.go | 44 +++++++++++++++------------- 5 files changed, 61 insertions(+), 36 deletions(-) diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 336e2a0d8..e7fc92019 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -71,7 +71,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe //判断任务是否已完成 for _, t := range userTask.TaskList { - if t.TaskId == req.TaskId && t.Status == 1 { + if t.TaskId == req.TaskId { code = pb.ErrorCode_WorldtaskFinihed return } diff --git a/modules/worldtask/api_mine.go b/modules/worldtask/api_mine.go index abb3f96a1..b15a64469 100644 --- a/modules/worldtask/api_mine.go +++ b/modules/worldtask/api_mine.go @@ -21,7 +21,21 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.WorldtaskMineReq) ( code = pb.ErrorCode_DBError return } + var list []*pb.Worldtask + for _, v := range myWorldtask.TaskList { + if v.TaskType == 2 { //世界任务 + list = append(list, v) + } + } + var wtMp = make(map[int32]*pb.Worldtask) + for k, v := range myWorldtask.LastTaskIds { + if v.TaskType == 2 { + wtMp[k] = v + } + } + myWorldtask.LastTaskIds = wtMp + myWorldtask.TaskList = list rsp := &pb.WorldtaskMineResp{ Task: myWorldtask, } diff --git a/modules/worldtask/model_worldtask.go b/modules/worldtask/model_worldtask.go index d7a884d63..8ea374fe7 100644 --- a/modules/worldtask/model_worldtask.go +++ b/modules/worldtask/model_worldtask.go @@ -52,7 +52,7 @@ func (this *ModelWorldtask) IsPreFinished(userTask *pb.DBWorldtask, curTaskConf } for _, t := range userTask.TaskList { - if lastTaskId == t.TaskId && t.Status == 1 { + if lastTaskId == t.TaskId{ preTaskFinished = true } } @@ -77,15 +77,21 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta } update := map[string]interface{}{} if task.LastTaskIds == nil { - task.LastTaskIds = make(map[int32]int32) + task.LastTaskIds = make(map[int32]*pb.Worldtask) + } + + taskConf := this.moduleWorldtask.worldtaskConf.GetDataMap()[taskId] + if taskConf == nil { + return comm.NewCustomError(pb.ErrorCode_ConfigNoFound) } update["uid"] = task.Uid - task.TaskList = append(task.TaskList, &pb.Worldtask{ + wt := &pb.Worldtask{ TaskId: taskId, - Status: 1, //完成 - }) - task.LastTaskIds[groupId] = taskId + TaskType: taskConf.Des, + } + task.TaskList = append(task.TaskList,wt) + task.LastTaskIds[groupId] = wt update["taskList"] = task.TaskList update["lastTaskIds"] = task.LastTaskIds diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index 6c206c1ee..e46a9bb4a 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -172,7 +172,7 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId } if mytask.LastTaskIds == nil { - mytask.LastTaskIds = make(map[int32]int32) + mytask.LastTaskIds = make(map[int32]*pb.Worldtask) } //重置taskList mytask.TaskList = []*pb.Worldtask{} @@ -181,20 +181,23 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId if taskConf.Ontxe != 0 && taskConf.IdAfter != 0 { for _, v := range this.worldtaskConf.GetDataList() { if v.Group == groupId && v.Key <= taskId { - mytask.LastTaskIds[groupId] = v.Key + mytask.LastTaskIds[groupId] = &pb.Worldtask{ + TaskId: v.Key, + TaskType: v.Des, + } mytask.TaskList = append(mytask.TaskList, &pb.Worldtask{ TaskId: v.Key, - Status: 1, }) } break } } else { - mytask.LastTaskIds[groupId] = taskId - mytask.TaskList = append(mytask.TaskList, &pb.Worldtask{ - TaskId: taskId, - Status: 1, - }) + wt := &pb.Worldtask{ + TaskId: taskId, + TaskType: taskConf.Des, + } + mytask.LastTaskIds[groupId] = wt + mytask.TaskList = append(mytask.TaskList, wt) } update = map[string]interface{}{ "lastTaskIds": mytask.LastTaskIds, diff --git a/pb/worldtask_db.pb.go b/pb/worldtask_db.pb.go index 495f69c2d..edaede57a 100644 --- a/pb/worldtask_db.pb.go +++ b/pb/worldtask_db.pb.go @@ -25,9 +25,9 @@ type DBWorldtask struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //玩家ID - LastTaskIds map[int32]int32 `protobuf:"bytes,2,rep,name=lastTaskIds,proto3" json:"lastTaskIds" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"lastTaskId"` //上一次完成的任务 key:groupId val:任务ID - TaskList []*Worldtask `protobuf:"bytes,3,rep,name=taskList,proto3" json:"taskList" bson:"taskList"` // 任务列表 + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //玩家ID + LastTaskIds map[int32]*Worldtask `protobuf:"bytes,2,rep,name=lastTaskIds,proto3" json:"lastTaskIds" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3" bson:"lastTaskId"` //上一次完成的任务 key:groupId val:任务ID + TaskList []*Worldtask `protobuf:"bytes,3,rep,name=taskList,proto3" json:"taskList" bson:"taskList"` // 任务列表 } func (x *DBWorldtask) Reset() { @@ -69,7 +69,7 @@ func (x *DBWorldtask) GetUid() string { return "" } -func (x *DBWorldtask) GetLastTaskIds() map[int32]int32 { +func (x *DBWorldtask) GetLastTaskIds() map[int32]*Worldtask { if x != nil { return x.LastTaskIds } @@ -88,8 +88,8 @@ type Worldtask struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TaskId int32 `protobuf:"varint,1,opt,name=taskId,proto3" json:"taskId" bson:"taskIds"` //任务ID - Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status" bson:"status"` //任务状态 0 未完成 1已完成 + TaskId int32 `protobuf:"varint,1,opt,name=taskId,proto3" json:"taskId" bson:"taskIds"` //任务ID + TaskType int32 `protobuf:"varint,3,opt,name=taskType,proto3" json:"taskType" bson:"taskType"` //任务类型 1 日/周常 2随机任务 3支线剧情 } func (x *Worldtask) Reset() { @@ -131,9 +131,9 @@ func (x *Worldtask) GetTaskId() int32 { return 0 } -func (x *Worldtask) GetStatus() int32 { +func (x *Worldtask) GetTaskType() int32 { if x != nil { - return x.Status + return x.TaskType } return 0 } @@ -142,7 +142,7 @@ var File_worldtask_worldtask_db_proto protoreflect.FileDescriptor var file_worldtask_worldtask_db_proto_rawDesc = []byte{ 0x0a, 0x1c, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x77, 0x6f, 0x72, 0x6c, - 0x64, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc8, + 0x64, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd4, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x3f, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x18, @@ -151,15 +151,16 @@ var file_worldtask_worldtask_db_proto_rawDesc = []byte{ 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x12, 0x26, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 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, 0x1a, 0x3e, 0x0a, 0x10, 0x4c, 0x61, 0x73, + 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x1a, 0x4a, 0x0a, 0x10, 0x4c, 0x61, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3b, 0x0a, 0x09, 0x57, 0x6f, 0x72, - 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x16, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, + 0x2e, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3f, 0x0a, 0x09, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, + 0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, + 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, + 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -184,11 +185,12 @@ var file_worldtask_worldtask_db_proto_goTypes = []interface{}{ var file_worldtask_worldtask_db_proto_depIdxs = []int32{ 2, // 0: DBWorldtask.lastTaskIds:type_name -> DBWorldtask.LastTaskIdsEntry 1, // 1: DBWorldtask.taskList:type_name -> Worldtask - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 1, // 2: DBWorldtask.LastTaskIdsEntry.value:type_name -> Worldtask + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_worldtask_worldtask_db_proto_init() }