From 35b11e7247e8a37f45bb2d173cec251ba4210df6 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 16 Dec 2022 11:54:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/task/model_task.go | 43 +++--- pb/mainline_msg.pb.go | 35 ++++- pb/task_db.pb.go | 301 +++++++++++++++++++++++-------------- pb/task_msg.pb.go | 12 +- 4 files changed, 241 insertions(+), 150 deletions(-) diff --git a/modules/task/model_task.go b/modules/task/model_task.go index 04a86248d..cbb646abb 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -36,12 +36,12 @@ func (this *ModelTask) Init(service core.IService, module core.IModule, comp cor // 查询完成的且未领取的任务 发现未领取返回true func (this *ModelTask) noReceiveTask(uid string, taskTag comm.TaskTag) (bool, error) { - list := []*pb.DBTask{} - if err := this.GetList(uid, &list); err != nil { + var task *pb.DBTask + if err := this.GetList(uid, &task); err != nil { this.moduleTask.Errorf("getTaskList err %v", err) return false, err } - for _, v := range list { + for _, v := range task.List { if v.Tag == int32(taskTag) && v.Status == 1 && v.Received == 0 { return true, nil } @@ -51,15 +51,15 @@ func (this *ModelTask) noReceiveTask(uid string, taskTag comm.TaskTag) (bool, er //获取玩家任务列表 func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newlist []*pb.DBTask) { - list := []*pb.DBTask{} - if err := this.GetList(uid, &list); err != nil { + var task *pb.DBTask + if err := this.GetList(uid, &task); err != nil { this.moduleTask.Errorf("getTaskList err %v", err) return } // 排序 - sort.SliceStable(list, func(i, j int) bool { - return list[i].Sort < list[j].Sort + sort.SliceStable(task.List, func(i, j int) bool { + return task.List[i].Sort < task.List[j].Sort }) dr := this.moduleTask.ModuleRtask.GetCondiData(uid) @@ -68,9 +68,9 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newli } // 筛选出指定tag的任务 - var taskList []*pb.DBTask - for _, v := range list { - if v.Tag == int32(taskTag) { + var taskList []*pb.TaskData + for _, v := range task.List { + if task.Tag == int32(taskTag) { if p, ok := dr.Vals[v.TypeId]; ok { if len(p.Data) > 0 { v.Progress = p.Data[0] @@ -154,21 +154,24 @@ func (this *ModelTask) getTaskById(uid string, taskId int32) (newlist []*pb.DBTa //初始化任务 func (this *ModelTask) initTask(uid string, taskTag comm.TaskTag) error { data := this.moduleTask.configure.getTaskByTag(int32(taskTag)) + objId := primitive.NewObjectID().Hex() + task := &pb.DBTask{ + Uid: uid, + Id: objId, + } for _, cnf := range data { - objId := primitive.NewObjectID().Hex() - task := &pb.DBTask{ - Id: objId, - Tag: cnf.IdTag, - Uid: uid, + task.List = append(task.List, &pb.TaskData{ + Tag: cnf.IdTag, TypeId: cnf.TypeId, TaskId: cnf.Key, Active: cnf.Active, Sort: cnf.IdList, - } - if err := this.AddList(uid, task.Id, task); err != nil { - this.moduleTask.Errorf("initTask addlists err %v", err) - return err - } + }) + } + + if err := this.AddList(uid, task.Id, task); err != nil { + this.moduleTask.Errorf("initTask addlists err %v", err) + return err } return nil diff --git a/pb/mainline_msg.pb.go b/pb/mainline_msg.pb.go index bbd7216c4..a92d4b3e0 100644 --- a/pb/mainline_msg.pb.go +++ b/pb/mainline_msg.pb.go @@ -406,7 +406,9 @@ type MainlineChallengeOverResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Data *DBMainline `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` //当前章节信息 + Data *DBMainline `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` //当前章节信息 + Newheros []string `protobuf:"bytes,2,rep,name=newheros,proto3" json:"newheros"` //获得的新英雄 + Olv int32 `protobuf:"varint,3,opt,name=olv,proto3" json:"olv"` //以前的等级 } func (x *MainlineChallengeOverResp) Reset() { @@ -448,6 +450,20 @@ func (x *MainlineChallengeOverResp) GetData() *DBMainline { return nil } +func (x *MainlineChallengeOverResp) GetNewheros() []string { + if x != nil { + return x.Newheros + } + return nil +} + +func (x *MainlineChallengeOverResp) GetOlv() int32 { + if x != nil { + return x.Olv + } + return 0 +} + // 推送新章节 type MainlineNewChapterPush struct { state protoimpl.MessageState @@ -540,16 +556,19 @@ var file_mainline_mainline_msg_proto_rawDesc = []byte{ 0x6e, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x3c, 0x0a, + 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x6a, 0x0a, 0x19, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x69, - 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x39, 0x0a, 0x16, 0x4d, - 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x65, 0x77, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, - 0x72, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x6e, + 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6e, + 0x65, 0x77, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x6c, 0x76, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6f, 0x6c, 0x76, 0x22, 0x39, 0x0a, 0x16, 0x4d, 0x61, 0x69, + 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x65, 0x77, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x50, + 0x75, 0x73, 0x68, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0b, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/task_db.pb.go b/pb/task_db.pb.go index a56bb940b..cc101ccc6 100644 --- a/pb/task_db.pb.go +++ b/pb/task_db.pb.go @@ -25,16 +25,11 @@ type DBTask struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - TaskId int32 `protobuf:"varint,3,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //任务Id - Tag int32 `protobuf:"varint,4,opt,name=tag,proto3" json:"tag" bson:"tag"` //标签 - Progress int32 `protobuf:"varint,5,opt,name=progress,proto3" json:"progress" bson:"progress"` //任务进度/完成次数 - Active int32 `protobuf:"varint,6,opt,name=active,proto3" json:"active" bson:"active"` //活跃度 - Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status" bson:"status"` // 任务状态 默认0未完成 1已完成 - Received int32 `protobuf:"varint,8,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 - TypeId int32 `protobuf:"varint,9,opt,name=typeId,proto3" json:"typeId" bson:"typeId"` - Sort int32 `protobuf:"varint,10,opt,name=sort,proto3" json:"sort" bson:"sort"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + DayList []*TaskData `protobuf:"bytes,4,rep,name=dayList,proto3" json:"dayList" bson:"dayList"` //日常任务列表 + WeekList []*TaskData `protobuf:"bytes,5,rep,name=weekList,proto3" json:"weekList" bson:"weekList"` //周常任务列表 + ActivityList []*ActivityData `protobuf:"bytes,6,rep,name=activityList,proto3" json:"activityList" bson:"activityList"` //活跃度列表 } func (x *DBTask) Reset() { @@ -83,76 +78,44 @@ func (x *DBTask) GetUid() string { return "" } -func (x *DBTask) GetTaskId() int32 { +func (x *DBTask) GetDayList() []*TaskData { if x != nil { - return x.TaskId + return x.DayList } - return 0 + return nil } -func (x *DBTask) GetTag() int32 { +func (x *DBTask) GetWeekList() []*TaskData { if x != nil { - return x.Tag + return x.WeekList } - return 0 + return nil } -func (x *DBTask) GetProgress() int32 { +func (x *DBTask) GetActivityList() []*ActivityData { if x != nil { - return x.Progress + return x.ActivityList } - return 0 + return nil } -func (x *DBTask) GetActive() int32 { - if x != nil { - return x.Active - } - return 0 -} - -func (x *DBTask) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *DBTask) GetReceived() int32 { - if x != nil { - return x.Received - } - return 0 -} - -func (x *DBTask) GetTypeId() int32 { - if x != nil { - return x.TypeId - } - return 0 -} - -func (x *DBTask) GetSort() int32 { - if x != nil { - return x.Sort - } - return 0 -} - -type DBTaskActive struct { +type TaskData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - RId int32 `protobuf:"varint,3,opt,name=rId,proto3" json:"rId" bson:"taskId"` //rewardId - Tag int32 `protobuf:"varint,4,opt,name=tag,proto3" json:"tag" bson:"tag"` //标签 - Received int32 `protobuf:"varint,5,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 + TaskId int32 `protobuf:"varint,3,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //任务Id + Tag int32 `protobuf:"varint,4,opt,name=tag,proto3" json:"tag" bson:"tag"` //标签 + Progress int32 `protobuf:"varint,5,opt,name=progress,proto3" json:"progress" bson:"progress"` //任务进度/完成次数 + Active int32 `protobuf:"varint,6,opt,name=active,proto3" json:"active" bson:"active"` //活跃度 + Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status" bson:"status"` // 任务状态 默认0未完成 1已完成 + Received int32 `protobuf:"varint,8,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 + TypeId int32 `protobuf:"varint,9,opt,name=typeId,proto3" json:"typeId" bson:"typeId"` + Sort int32 `protobuf:"varint,10,opt,name=sort,proto3" json:"sort" bson:"sort"` } -func (x *DBTaskActive) Reset() { - *x = DBTaskActive{} +func (x *TaskData) Reset() { + *x = TaskData{} if protoimpl.UnsafeEnabled { mi := &file_task_task_db_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -160,13 +123,13 @@ func (x *DBTaskActive) Reset() { } } -func (x *DBTaskActive) String() string { +func (x *TaskData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DBTaskActive) ProtoMessage() {} +func (*TaskData) ProtoMessage() {} -func (x *DBTaskActive) ProtoReflect() protoreflect.Message { +func (x *TaskData) ProtoReflect() protoreflect.Message { mi := &file_task_task_db_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -178,40 +141,124 @@ func (x *DBTaskActive) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DBTaskActive.ProtoReflect.Descriptor instead. -func (*DBTaskActive) Descriptor() ([]byte, []int) { +// Deprecated: Use TaskData.ProtoReflect.Descriptor instead. +func (*TaskData) Descriptor() ([]byte, []int) { return file_task_task_db_proto_rawDescGZIP(), []int{1} } -func (x *DBTaskActive) GetId() string { +func (x *TaskData) GetTaskId() int32 { if x != nil { - return x.Id - } - return "" -} - -func (x *DBTaskActive) GetUid() string { - if x != nil { - return x.Uid - } - return "" -} - -func (x *DBTaskActive) GetRId() int32 { - if x != nil { - return x.RId + return x.TaskId } return 0 } -func (x *DBTaskActive) GetTag() int32 { +func (x *TaskData) GetTag() int32 { if x != nil { return x.Tag } return 0 } -func (x *DBTaskActive) GetReceived() int32 { +func (x *TaskData) GetProgress() int32 { + if x != nil { + return x.Progress + } + return 0 +} + +func (x *TaskData) GetActive() int32 { + if x != nil { + return x.Active + } + return 0 +} + +func (x *TaskData) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *TaskData) GetReceived() int32 { + if x != nil { + return x.Received + } + return 0 +} + +func (x *TaskData) GetTypeId() int32 { + if x != nil { + return x.TypeId + } + return 0 +} + +func (x *TaskData) GetSort() int32 { + if x != nil { + return x.Sort + } + return 0 +} + +type ActivityData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RId int32 `protobuf:"varint,3,opt,name=rId,proto3" json:"rId" bson:"taskId"` //rewardId + Tag int32 `protobuf:"varint,4,opt,name=tag,proto3" json:"tag" bson:"tag"` //标签 + Received int32 `protobuf:"varint,5,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 +} + +func (x *ActivityData) Reset() { + *x = ActivityData{} + if protoimpl.UnsafeEnabled { + mi := &file_task_task_db_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ActivityData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActivityData) ProtoMessage() {} + +func (x *ActivityData) ProtoReflect() protoreflect.Message { + mi := &file_task_task_db_proto_msgTypes[2] + 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 ActivityData.ProtoReflect.Descriptor instead. +func (*ActivityData) Descriptor() ([]byte, []int) { + return file_task_task_db_proto_rawDescGZIP(), []int{2} +} + +func (x *ActivityData) GetRId() int32 { + if x != nil { + return x.RId + } + return 0 +} + +func (x *ActivityData) GetTag() int32 { + if x != nil { + return x.Tag + } + return 0 +} + +func (x *ActivityData) GetReceived() int32 { if x != nil { return x.Received } @@ -222,30 +269,36 @@ var File_task_task_db_proto protoreflect.FileDescriptor var file_task_task_db_proto_rawDesc = []byte{ 0x0a, 0x12, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe8, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x12, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa9, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, - 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, - 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, - 0x6f, 0x72, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, - 0x70, 0x0a, 0x0c, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, - 0x64, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x64, 0x12, 0x23, 0x0a, 0x07, 0x64, 0x61, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x07, 0x64, + 0x61, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x08, 0x77, 0x65, 0x65, 0x6b, 0x4c, 0x69, + 0x73, 0x74, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x44, + 0x61, 0x74, 0x61, 0x52, 0x08, 0x77, 0x65, 0x65, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x31, 0x0a, + 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x06, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, + 0x74, 0x61, 0x52, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, + 0x22, 0xc8, 0x01, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, + 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, + 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, + 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, + 0x16, 0x0a, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x4e, 0x0a, 0x0c, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, + 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, + 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, + 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -260,17 +313,21 @@ func file_task_task_db_proto_rawDescGZIP() []byte { return file_task_task_db_proto_rawDescData } -var file_task_task_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_task_task_db_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_task_task_db_proto_goTypes = []interface{}{ (*DBTask)(nil), // 0: DBTask - (*DBTaskActive)(nil), // 1: DBTaskActive + (*TaskData)(nil), // 1: TaskData + (*ActivityData)(nil), // 2: ActivityData } var file_task_task_db_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: DBTask.dayList:type_name -> TaskData + 1, // 1: DBTask.weekList:type_name -> TaskData + 2, // 2: DBTask.activityList:type_name -> ActivityData + 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_task_task_db_proto_init() } @@ -292,7 +349,19 @@ func file_task_task_db_proto_init() { } } file_task_task_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DBTaskActive); i { + switch v := v.(*TaskData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_task_task_db_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ActivityData); i { case 0: return &v.state case 1: @@ -310,7 +379,7 @@ func file_task_task_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_task_task_db_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/task_msg.pb.go b/pb/task_msg.pb.go index 28d013f22..9ea8d6e4c 100644 --- a/pb/task_msg.pb.go +++ b/pb/task_msg.pb.go @@ -271,7 +271,7 @@ type TaskActiveListResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - List []*DBTaskActive `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` //活跃度列表 + List []*ActivityData `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` //活跃度列表 Active int32 `protobuf:"varint,2,opt,name=active,proto3" json:"active"` //活跃度值 } @@ -307,7 +307,7 @@ func (*TaskActiveListResp) Descriptor() ([]byte, []int) { return file_task_task_msg_proto_rawDescGZIP(), []int{5} } -func (x *TaskActiveListResp) GetList() []*DBTaskActive { +func (x *TaskActiveListResp) GetList() []*ActivityData { if x != nil { return x.List } @@ -597,8 +597,8 @@ var file_task_task_msg_proto_rawDesc = []byte{ 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x4f, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x6c, - 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x54, 0x61, - 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x16, + 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x40, 0x0a, 0x14, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x18, @@ -647,11 +647,11 @@ var file_task_task_msg_proto_goTypes = []interface{}{ (*TaskDoStrategyResp)(nil), // 9: TaskDoStrategyResp (*TaskFinishedPush)(nil), // 10: TaskFinishedPush (*DBTask)(nil), // 11: DBTask - (*DBTaskActive)(nil), // 12: DBTaskActive + (*ActivityData)(nil), // 12: ActivityData } var file_task_task_msg_proto_depIdxs = []int32{ 11, // 0: TaskListResp.list:type_name -> DBTask - 12, // 1: TaskActiveListResp.list:type_name -> DBTaskActive + 12, // 1: TaskActiveListResp.list:type_name -> ActivityData 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 From 96cd327d8712b6a273ed0f1592e538c929a2da3d Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 16 Dec 2022 15:29:54 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=94=B9=E5=AD=97=E6=AE=B5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pb/task_db.pb.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pb/task_db.pb.go b/pb/task_db.pb.go index cc101ccc6..4c2eb002b 100644 --- a/pb/task_db.pb.go +++ b/pb/task_db.pb.go @@ -207,7 +207,7 @@ type ActivityData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RId int32 `protobuf:"varint,3,opt,name=rId,proto3" json:"rId" bson:"taskId"` //rewardId + TaskId int32 `protobuf:"varint,3,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //taskId Tag int32 `protobuf:"varint,4,opt,name=tag,proto3" json:"tag" bson:"tag"` //标签 Received int32 `protobuf:"varint,5,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 } @@ -244,9 +244,9 @@ func (*ActivityData) Descriptor() ([]byte, []int) { return file_task_task_db_proto_rawDescGZIP(), []int{2} } -func (x *ActivityData) GetRId() int32 { +func (x *ActivityData) GetTaskId() int32 { if x != nil { - return x.RId + return x.TaskId } return 0 } @@ -292,13 +292,14 @@ var file_task_task_db_proto_rawDesc = []byte{ 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x4e, 0x0a, 0x0c, 0x41, - 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, - 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, - 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, - 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, - 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x54, 0x0a, 0x0c, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x74, + 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, + 0x6b, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( From 9acb59b119a64854d0401fc4be81d6d93c3092d9 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Mon, 19 Dec 2022 10:13:12 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/views/task_activelist.go | 6 +- cmd/v2/ui/views/task_activereceive.go | 2 +- cmd/v2/ui/views/task_list.go | 4 +- comm/imodule.go | 6 +- modules/rtask/help.go | 2 +- modules/rtask/verifyHandle.go | 2 +- modules/task/api_activereceive.go | 77 +++--- modules/task/api_list.go | 14 +- modules/task/api_receive.go | 34 ++- modules/task/api_strategy.go | 39 --- modules/task/model_active.go | 80 ++++-- modules/task/model_task.go | 361 +++++++++++++++++--------- modules/task/module.go | 21 +- modules/user/api_login.go | 2 +- pb/task_db.pb.go | 176 +++++++++---- pb/task_msg.pb.go | 223 ++++------------ 16 files changed, 572 insertions(+), 477 deletions(-) delete mode 100644 modules/task/api_strategy.go diff --git a/cmd/v2/ui/views/task_activelist.go b/cmd/v2/ui/views/task_activelist.go index 3c0354757..7005fd3d5 100644 --- a/cmd/v2/ui/views/task_activelist.go +++ b/cmd/v2/ui/views/task_activelist.go @@ -57,7 +57,7 @@ func (this *TaskActiveListView) CreateView(t *model.TestCase) fyne.CanvasObject } if err := service.GetPttService().SendToClient( t.MainType, "activereceive", - &pb.TaskActiveReceiveReq{Id: selItemId, TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil { + &pb.TaskActiveReceiveReq{Id: cast.ToInt32(selItemId), TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil { logrus.Error(err) return } @@ -94,8 +94,8 @@ func (this *TaskActiveListView) dataListener() { for _, v := range rsp.List { item := common.Item{ - Id: cast.ToString(v.Id), - Text: fmt.Sprintf("任务ID:%s 领取状态:%d", cast.ToString(v.RId), v.Received), + Id: cast.ToString(v.TaskId), + Text: fmt.Sprintf("任务ID:%s 领取状态:%d", cast.ToString(v.TaskId), v.Received), } this.itemList.AddItem(item) } diff --git a/cmd/v2/ui/views/task_activereceive.go b/cmd/v2/ui/views/task_activereceive.go index dfaf5a2dc..bc51c7830 100644 --- a/cmd/v2/ui/views/task_activereceive.go +++ b/cmd/v2/ui/views/task_activereceive.go @@ -25,7 +25,7 @@ func (this *TaskActiveReceiveView) CreateView(t *model.TestCase) fyne.CanvasObje this.form.OnSubmit = func() { if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.TaskActiveReceiveReq{ - Id: id.Text, + Id: cast.ToInt32(id.Text), TaskTag: cast.ToInt32(tagSelect.Selected), }); err != nil { logrus.Error(err) diff --git a/cmd/v2/ui/views/task_list.go b/cmd/v2/ui/views/task_list.go index b0893d6e4..1182a236e 100644 --- a/cmd/v2/ui/views/task_list.go +++ b/cmd/v2/ui/views/task_list.go @@ -54,7 +54,7 @@ func (this *TaskListView) CreateView(t *model.TestCase) fyne.CanvasObject { } if err := service.GetPttService().SendToClient( t.MainType, "receive", - &pb.TaskReceiveReq{Id: selId, TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil { + &pb.TaskReceiveReq{Id: cast.ToInt32(selId), TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil { logrus.Error(err) return } @@ -90,7 +90,7 @@ func (this *TaskListView) dataListener() { for _, v := range rsp.List { item := common.Item{ - Id: cast.ToString(v.Id), + Id: cast.ToString(v.TaskId), Text: fmt.Sprintf("%s 是否完成:%d 是否领奖:%d 进度:%d", cast.ToString(v.TaskId), v.Status, v.Received, v.Progress), } this.itemList.AddItem(item) diff --git a/comm/imodule.go b/comm/imodule.go index 04889b95f..73409fbc6 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -153,9 +153,9 @@ type ( // 清理玩家任务数据 CleanData(uid string) // 获取当前任务 - GetTaskById(uid string, taskId int32) *pb.DBTask - // 获取已完成的任务列表 - GetTaskFinished(uid string, taskType TaskTag) []*pb.DBTask + GetTaskById(uid string, taskTag, taskId int32) *pb.TaskData + // 获取已完成的日任务列表 + GetTaskDayFinished(uid string) []*pb.TaskData ///红点 IReddot } diff --git a/modules/rtask/help.go b/modules/rtask/help.go index 477a2a421..33f7e6bce 100644 --- a/modules/rtask/help.go +++ b/modules/rtask/help.go @@ -132,7 +132,7 @@ func hasUpdateData(len int, data *pb.RtaskData, vals ...int32) map[int32]int32 { } func printCondiLog(uid string, cfg *cfg.GameRdtaskCondiData) { - log.Infof("uid:%v condiId:%v rtype:%v", uid, cfg.Id, cfg.Type) + log.Debugf("uid:%v condiId:%v rtype:%v", uid, cfg.Id, cfg.Type) } type Num interface { diff --git a/modules/rtask/verifyHandle.go b/modules/rtask/verifyHandle.go index ea7cdd235..5148c949a 100644 --- a/modules/rtask/verifyHandle.go +++ b/modules/rtask/verifyHandle.go @@ -142,7 +142,7 @@ func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) ( } if ml, y := m.(comm.ITask); y { - for _, task := range ml.GetTaskFinished(uid, comm.TASK_DAILY) { + for _, task := range ml.GetTaskDayFinished(uid) { if task.TaskId >= cfg.Data1 { ok = true break diff --git a/modules/task/api_activereceive.go b/modules/task/api_activereceive.go index 499d0d94c..b002b5e93 100644 --- a/modules/task/api_activereceive.go +++ b/modules/task/api_activereceive.go @@ -11,7 +11,7 @@ import ( //活跃度领取 func (this *apiComp) ActiveReceiveCheck(session comm.IUserSession, req *pb.TaskActiveReceiveReq) (code pb.ErrorCode) { - if req.Id == "" { + if req.Id == 0 { code = pb.ErrorCode_TaskIdEmpty } else if req.TaskTag <= 0 || req.TaskTag > 2 { code = pb.ErrorCode_TaskTagEmpty @@ -25,17 +25,6 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive } uid := session.GetUserId() - // ua := this.moduleTask.modelTaskActive.getUserActive(uid, req.Id, comm.TaskTag(req.TaskTag)) - // if ua == nil { - // code = pb.ErrorCode_TaskActiveNofound - // return - // } - - //判断是否已领取 - // if ua.Received == 1 { - // code = pb.ErrorCode_TaskReceived - // return - // } ue, err := this.moduleTask.ModuleUser.GetUserExpand(uid) if err != nil { code = pb.ErrorCode_DBError @@ -49,39 +38,47 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive var rewards []*cfg.Gameatn // 玩家的 activeList := this.moduleTask.modelTaskActive.getActiveListByTag(uid, comm.TaskTag(req.TaskTag)) + var activityData *pb.ActivityData for _, v := range activeList { - if v.Received != 1 { //未领取 - conf := this.moduleTask.configure.getTaskActiveById(v.RId) - if conf == nil { - code = pb.ErrorCode_ConfigNoFound + if v.TaskId == req.Id { + activityData = v + break + } + } + + if activityData == nil { + code = pb.ErrorCode_TaskNotFound + return + } + + if activityData.Received != 1 { //未领取 + conf := this.moduleTask.configure.getTaskActiveById(activityData.TaskId) + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + update := make(map[string]interface{}) + if req.TaskTag == int32(comm.TASK_DAILY) { + if ue.Activeday < conf.Active { + code = pb.ErrorCode_TaskActiveNoenough return } - - // get user expand - - update := make(map[string]interface{}) - if req.TaskTag == int32(comm.TASK_DAILY) { - if ue.Activeday < conf.Active { - continue - } - } else if req.TaskTag == int32(comm.TASK_WEEKLY) { - if ue.Activeweek < conf.Active { - continue - } + } else if req.TaskTag == int32(comm.TASK_WEEKLY) { + if ue.Activeweek < conf.Active { + code = pb.ErrorCode_TaskActiveNoenough + return } - update["received"] = 1 - if len(update) > 0 { - if err := this.moduleTask.modelTaskActive.updateReceive(session.GetUserId(), - v.Id, - comm.TaskTag(req.TaskTag), - update); err != nil { - this.moduleTask.Errorf("updateReceive err %v", err) - code = pb.ErrorCode_DBError - return - } - } - rewards = append(rewards, conf.Reword...) } + update["received"] = 1 + if len(update) > 0 { + if err := this.moduleTask.modelTaskActive.updateReceive(session.GetUserId(), update); err != nil { + this.moduleTask.Errorf("updateReceive err %v", err) + code = pb.ErrorCode_DBError + return + } + } + rewards = append(rewards, conf.Reword...) } if len(rewards) > 0 { diff --git a/modules/task/api_list.go b/modules/task/api_list.go index afdad1d8d..1a9a8cf1d 100644 --- a/modules/task/api_list.go +++ b/modules/task/api_list.go @@ -30,7 +30,19 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.TaskListReq) (code } }() - rsp.List = this.moduleTask.modelTask.getTaskListByTag(session.GetUserId(), comm.TaskTag(req.TaskTag)) + task := this.moduleTask.modelTask.getTaskListByTag(session.GetUserId(), comm.TaskTag(req.TaskTag)) + if task == nil { + code = pb.ErrorCode_TaskNotFound + return + } + switch req.TaskTag { + case int32(comm.TASK_DAILY): + rsp.List = task.DayList + case int32(comm.TASK_WEEKLY): + rsp.List = task.WeekList + case int32(comm.TASK_ACHIEVE): + rsp.List = task.AchieveList + } return } diff --git a/modules/task/api_receive.go b/modules/task/api_receive.go index 196e27132..15e681099 100644 --- a/modules/task/api_receive.go +++ b/modules/task/api_receive.go @@ -11,7 +11,7 @@ import ( //任务奖励领取 func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.TaskReceiveReq) (code pb.ErrorCode) { - if req.Id == "" { + if req.Id == 0 { code = pb.ErrorCode_TaskIdEmpty } else if req.TaskTag == 0 { code = pb.ErrorCode_TaskTagEmpty @@ -32,19 +32,38 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) return } + var taskDataList []*pb.TaskData + + switch req.TaskTag { + case int32(comm.TASK_DAILY): + taskDataList = userTask.DayList + case int32(comm.TASK_WEEKLY): + taskDataList = userTask.WeekList + case int32(comm.TASK_ACHIEVE): + taskDataList = userTask.AchieveList + } + + resp := &pb.TaskReceiveResp{} + var taskData *pb.TaskData + for _, v := range taskDataList { + if v.TaskId == req.Id { + taskData = v + } + } + //判断是否完成 - if userTask.Status == 0 { + if taskData.Status == 0 { code = pb.ErrorCode_TaskNoFinished return } //判断任务是否领取 - if userTask.Received == 1 { + if taskData.Received == 1 { code = pb.ErrorCode_TaskReceived return } // 待领取的任务配置 - conf := this.moduleTask.configure.getTaskById(userTask.TaskId) + conf := this.moduleTask.configure.getTaskById(taskData.TaskId) if conf == nil { code = pb.ErrorCode_ConfigNoFound return @@ -88,14 +107,11 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) update := map[string]interface{}{ "received": 1, } - if err := this.moduleTask.modelTask.modifyUserTask(session.GetUserId(), userTask.Id, update); err != nil { + if err := this.moduleTask.modelTask.modifyUserTask(session.GetUserId(), taskData.TaskId, update); err != nil { code = pb.ErrorCode_DBError return } - - resp := &pb.TaskReceiveResp{ - TaskId: userTask.TaskId, - } + resp.TaskId = taskData.TaskId err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeReceive, resp) if err != nil { diff --git a/modules/task/api_strategy.go b/modules/task/api_strategy.go deleted file mode 100644 index 2bb90b51e..000000000 --- a/modules/task/api_strategy.go +++ /dev/null @@ -1,39 +0,0 @@ -package task - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - - "google.golang.org/protobuf/proto" -) - -//卡牌攻略 -func (this *apiComp) StrategyCheck(session comm.IUserSession, req *pb.TaskDoStrategyReq) (code pb.ErrorCode) { - if req.HeroCfgId == 0 { - code = pb.ErrorCode_ReqParameterError - } - return -} - -//进入卡牌攻略 -func (this *apiComp) Strategy(session comm.IUserSession, req *pb.TaskDoStrategyReq) (code pb.ErrorCode, data proto.Message) { - if code = this.StrategyCheck(session, req); code != pb.ErrorCode_Success { - return - } - - resp := &pb.TaskDoStrategyResp{} - - taskIds, err := this.moduleTask.modelTask.inStrategy(session.GetUserId(), req.HeroCfgId) - if err != nil { - code = pb.ErrorCode_SystemError - return - } - - resp.TaskIds = taskIds - - err = session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeStrategy, resp) - if err != nil { - code = pb.ErrorCode_SystemError - } - return -} diff --git a/modules/task/model_active.go b/modules/task/model_active.go index d51a450e4..9fb0f1dea 100644 --- a/modules/task/model_active.go +++ b/modules/task/model_active.go @@ -29,32 +29,48 @@ func (this *ModelTaskActive) Init(service core.IService, module core.IModule, co //初始化活跃度 func (this *ModelTaskActive) initActiveReward(uid string, taskTag comm.TaskTag) { + task := &pb.DBActivity{} + if err := this.Get(uid, task); err != nil { + if err == mongo.ErrNoDocuments { + objId := primitive.NewObjectID().Hex() + task = &pb.DBActivity{ + Uid: uid, + Id: objId, + } + this.moduleTask.modelTaskActive.Add(uid, task) + } else { + this.moduleTask.Errorf("getTaskList err %v", err) + return + } + } + data := this.moduleTask.configure.getTaskActiveByTag(int32(taskTag)) for _, conf := range data { - objId := primitive.NewObjectID().Hex() - ta := &pb.DBTaskActive{ - Id: objId, - Uid: uid, - Tag: int32(taskTag), - RId: conf.Key, - } - if err := this.moduleTask.modelTaskActive.AddList(uid, ta.Id, ta); err != nil { - this.moduleTask.Errorf("uid:%v tag:%v initActiv add err %v", uid, err) - return + ta := &pb.ActivityData{ + Tag: int32(taskTag), + TaskId: conf.Key, } + task.ActivityList = append(task.ActivityList, ta) + } + update := map[string]interface{}{ + "activityList": task.ActivityList, + } + if err := this.moduleTask.modelTaskActive.Change(uid, update); err != nil { + this.moduleTask.Errorf("uid:%v tag:%v initActivity err %v", uid, err) + return } } //获取玩家活跃度列表 -func (this *ModelTaskActive) getActiveListByTag(uid string, taskTag comm.TaskTag) (list []*pb.DBTaskActive) { - al := []*pb.DBTaskActive{} - if err := this.GetList(uid, &al); err != nil { - this.moduleTask.Errorf("getUserActiveList err:%v", err) - return al +func (this *ModelTaskActive) getActiveListByTag(uid string, taskTag comm.TaskTag) (list []*pb.ActivityData) { + task := &pb.DBActivity{} + if err := this.Get(uid, task); err != nil { + this.moduleTask.Errorf("getTaskList err %v", err) + return } - for _, v := range al { + for _, v := range task.ActivityList { if v.Tag == int32(taskTag) { list = append(list, v) } @@ -65,12 +81,13 @@ func (this *ModelTaskActive) getActiveListByTag(uid string, taskTag comm.TaskTag // 查询完成的且未领取的任务 发现未领取返回true func (this *ModelTaskActive) noReceiveTaskActive(uid string, taskTag comm.TaskTag) (bool, error) { - list := []*pb.DBTaskActive{} - if err := this.GetList(uid, &list); err != nil { - this.moduleTask.Errorf("getUserActiveList err:%v", err) + task := &pb.DBActivity{} + if err := this.Get(uid, task); err != nil { + this.moduleTask.Errorf("getTaskActivityList err %v", err) return false, err } - for _, v := range list { + + for _, v := range task.ActivityList { if v.Tag == int32(taskTag) && v.Received == 0 { return true, nil } @@ -79,21 +96,21 @@ func (this *ModelTaskActive) noReceiveTaskActive(uid string, taskTag comm.TaskTa } //获取玩家活跃记录 id 唯一ID -func (this *ModelTaskActive) getUserActive(uid, id string, taskTag comm.TaskTag) *pb.DBTaskActive { +func (this *ModelTaskActive) getUserActive(uid string, taskId int32, taskTag comm.TaskTag) *pb.ActivityData { record := this.getActiveListByTag(uid, taskTag) for _, v := range record { - if v.Id == id { + if v.TaskId == taskId { return v } } return nil } -func (this *ModelTaskActive) updateReceive(uid, id string, taskTag comm.TaskTag, data map[string]interface{}) (err error) { +func (this *ModelTaskActive) updateReceive(uid string, data map[string]interface{}) (err error) { if len(data) == 0 { return } - return this.moduleTask.modelTaskActive.ChangeList(uid, id, data) + return this.moduleTask.modelTaskActive.Change(uid, data) } //清空活跃度任务 @@ -103,10 +120,17 @@ func (this *ModelTaskActive) clearTask(uid string, taskTag ...comm.TaskTag) { return } data := this.getActiveListByTag(uid, taskTag[0]) - for _, v := range data { - if err := this.moduleTask.modelTaskActive.DelListlds(uid, v.Id); err != nil { - this.moduleTask.Errorf("uid: %v err:%v", uid, err) - return + for i, v := range data { + if v.Tag == int32(taskTag[0]) { + data = append(data[:i], data[i+1:]...) } } + update := map[string]interface{}{ + "activityList": data, + } + if err := this.moduleTask.modelTaskActive.Change(uid, update); err != nil { + this.moduleTask.Errorf("uid: %v err:%v", uid, err) + return + } + } diff --git a/modules/task/model_task.go b/modules/task/model_task.go index cbb646abb..ad8d126a4 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -36,53 +36,74 @@ func (this *ModelTask) Init(service core.IService, module core.IModule, comp cor // 查询完成的且未领取的任务 发现未领取返回true func (this *ModelTask) noReceiveTask(uid string, taskTag comm.TaskTag) (bool, error) { - var task *pb.DBTask - if err := this.GetList(uid, &task); err != nil { + task := &pb.DBTask{} + if err := this.Get(uid, task); err != nil { this.moduleTask.Errorf("getTaskList err %v", err) return false, err } - for _, v := range task.List { - if v.Tag == int32(taskTag) && v.Status == 1 && v.Received == 0 { - return true, nil + if taskTag == comm.TASK_DAILY { + for _, v := range task.DayList { + if v.Status == 1 && v.Received == 0 { + return true, nil + } + } + } else if taskTag == comm.TASK_WEEKLY { + for _, v := range task.WeekList { + if v.Status == 1 && v.Received == 0 { + return true, nil + } } } return false, nil } //获取玩家任务列表 -func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newlist []*pb.DBTask) { - var task *pb.DBTask - if err := this.GetList(uid, &task); err != nil { +func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) *pb.DBTask { + task := &pb.DBTask{} + if err := this.Get(uid, task); err != nil { this.moduleTask.Errorf("getTaskList err %v", err) - return + return nil + } + + if task == nil { + return nil } // 排序 - sort.SliceStable(task.List, func(i, j int) bool { - return task.List[i].Sort < task.List[j].Sort + sort.SliceStable(task.DayList, func(i, j int) bool { + return task.DayList[i].Sort < task.DayList[j].Sort + }) + sort.SliceStable(task.WeekList, func(i, j int) bool { + return task.WeekList[i].Sort < task.WeekList[j].Sort }) dr := this.moduleTask.ModuleRtask.GetCondiData(uid) if dr == nil { - return + return nil } // 筛选出指定tag的任务 - var taskList []*pb.TaskData - for _, v := range task.List { - if task.Tag == int32(taskTag) { + if taskTag == comm.TASK_DAILY { + for _, v := range task.DayList { + if p, ok := dr.Vals[v.TypeId]; ok { + if len(p.Data) > 0 { + v.Progress = p.Data[0] + } + } + } + } else if taskTag == comm.TASK_WEEKLY { + for _, v := range task.WeekList { if p, ok := dr.Vals[v.TypeId]; ok { if len(p.Data) > 0 { v.Progress = p.Data[0] } } - taskList = append(taskList, v) } } - // 当前玩家任务 - getCurTask := func(taskId int32) *pb.DBTask { - for _, v := range list { + // 当前玩家成就任务 + getCurTask := func(taskId int32) *pb.TaskData { + for _, v := range task.AchieveList { if v.TaskId == taskId { return v } @@ -103,117 +124,183 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newli } // 成就列表 + var achieveList []*pb.TaskData if taskTag == comm.TASK_ACHIEVE { - for _, v := range taskList { + for _, v := range task.AchieveList { if curTask := this.moduleTask.configure.getTaskById(v.TaskId); curTask != nil { if v.Received == 0 { isFirst := this.moduleTask.configure.isFirstTask(curTask.Key) if curTask.IdAfter == 0 && isFirst { //未领取和没有下个连续任务的 - newlist = append(newlist, v) + achieveList = append(achieveList, v) continue } if isFirst && curTask.IdAfter != 0 { //连续任务的第一个任务 next := this.moduleTask.configure.getTaskById(curTask.IdAfter) if next != nil && v.Received == 0 { - newlist = append(newlist, v) + achieveList = append(achieveList, v) } } else { if isReceived(curTask.Key) { - newlist = append(newlist, v) + achieveList = append(achieveList, v) } - // else { - // break - // } } } } } - } else { - newlist = taskList + task.AchieveList = achieveList } - return + + return task } // 获取用户任务 -func (this *ModelTask) getTaskById(uid string, taskId int32) (newlist []*pb.DBTask) { - list := []*pb.DBTask{} - if err := this.GetList(uid, &list); err != nil { +func (this *ModelTask) getTaskById(uid string, taskTag comm.TaskTag, taskId int32) *pb.DBTask { + task := &pb.DBTask{} + if err := this.Get(uid, task); err != nil { this.moduleTask.Errorf("getTaskById err %v", err) - return + return nil } - for _, v := range list { - if v.TaskId == taskId { - newlist = append(newlist, v) + if task != nil { + if taskTag == comm.TASK_DAILY { + for _, v := range task.DayList { + if v.TaskId == taskId { + task.DayList = append(task.DayList, v) + } + } + } else if taskTag == comm.TASK_WEEKLY { + for _, v := range task.WeekList { + if v.TaskId == taskId { + task.WeekList = append(task.WeekList, v) + } + } + } else if taskTag == comm.TASK_ACHIEVE { + for _, v := range task.AchieveList { + if v.TaskId == taskId { + task.AchieveList = append(task.AchieveList, v) + } + } } } - return + + return task } //初始化任务 func (this *ModelTask) initTask(uid string, taskTag comm.TaskTag) error { - data := this.moduleTask.configure.getTaskByTag(int32(taskTag)) - objId := primitive.NewObjectID().Hex() - task := &pb.DBTask{ - Uid: uid, - Id: objId, + task := &pb.DBTask{} + if err := this.Get(uid, task); err != nil { + if err == mongo.ErrNoDocuments { + objId := primitive.NewObjectID().Hex() + task = &pb.DBTask{ + Uid: uid, + Id: objId, + } + if err := this.Add(uid, task); err != nil { + this.moduleTask.Errorf("initTask addlists err %v", err) + return err + } + } else { + this.moduleTask.Errorf("getTaskList err %v", err) + return err + } } + + data := this.moduleTask.configure.getTaskByTag(int32(taskTag)) + update := map[string]interface{}{} for _, cnf := range data { - task.List = append(task.List, &pb.TaskData{ - Tag: cnf.IdTag, + t := &pb.TaskData{ + Tag: cnf.IdTag, TypeId: cnf.TypeId, TaskId: cnf.Key, Active: cnf.Active, Sort: cnf.IdList, - }) + } + if taskTag == comm.TASK_DAILY { + task.DayList = append(task.DayList, t) + update["dayList"] = task.DayList + } else if taskTag == comm.TASK_WEEKLY { + task.WeekList = append(task.WeekList, t) + update["weekList"] = task.WeekList + } else if taskTag == comm.TASK_ACHIEVE { + task.AchieveList = append(task.AchieveList, t) + update["achieveList"] = task.AchieveList + } } - if err := this.AddList(uid, task.Id, task); err != nil { - this.moduleTask.Errorf("initTask addlists err %v", err) + if err := this.Change(uid, update); err != nil { + this.moduleTask.Errorf("initTask err %v", err) return err } - return nil } //查询用户任务 -func (this *ModelTask) getUserTask(uid string, taskId string) *pb.DBTask { - userTask := &pb.DBTask{} - if err := this.moduleTask.modelTask.GetListObj(uid, taskId, userTask); err != nil { - this.moduleTask.Errorf("getUserTask err:%v", err) +func (this *ModelTask) getUserTask(uid string, taskId int32) *pb.DBTask { + task := &pb.DBTask{} + if err := this.Get(uid, task); err != nil { + this.moduleTask.Errorf("getTaskList err %v", err) return nil } - return userTask + return task } -// 获取已完成的任务 -func (this *ModelTask) getFinishTasks(uid string, taskTag comm.TaskTag) (list []*pb.DBTask) { - taskList := this.getTaskListByTag(uid, taskTag) - for _, v := range taskList { - if v.Status == 1 { - list = append(list, v) +// 获取已完成的(日、周)任务 +func (this *ModelTask) getFinishTasks(uid string, taskTag comm.TaskTag) (list []*pb.TaskData) { + task := this.getTaskListByTag(uid, taskTag) + if taskTag == comm.TASK_DAILY { + for _, v := range task.DayList { + if v.Status == 1 { + list = append(list, v) + } + } + } else if taskTag == comm.TASK_WEEKLY { + for _, v := range task.WeekList { + if v.Status == 1 { + list = append(list, v) + } } } return } -// 获取待处理的任务 -func (this *ModelTask) getUnFinishTasks(uid string, taskId int32) (list []*pb.DBTask) { - taskList := this.getTaskById(uid, taskId) - for _, v := range taskList { - if v.Status == 0 { - list = append(list, v) +// 获取待处理的(日、周)任务 +func (this *ModelTask) getUnFinishTasks(uid string, taskId int32) (list []*pb.TaskData) { + task := &pb.DBTask{} + if err := this.Get(uid, task); err != nil { + this.moduleTask.Errorf("getTaskById err %v", err) + return nil + } + + if task != nil { + for _, v := range task.DayList { + if v.TaskId == taskId && v.Status == 0 { + list = append(list, v) + } + } + + for _, v := range task.WeekList { + if v.TaskId == taskId && v.Status == 0 { + list = append(list, v) + } + } + + for _, v := range task.AchieveList { + if v.TaskId == taskId && v.Status == 0 { + list = append(list, v) + } } } + return } //检查任务状态 返回等待处理的任务 -func (this *ModelTask) checkTask(uid string, taskId int32) (*pb.DBTask, bool) { +func (this *ModelTask) checkTask(uid string, taskId int32) (*pb.TaskData, bool) { taskList := this.getUnFinishTasks(uid, taskId) for _, v := range taskList { - if taskId == v.TaskId && v.Status == 0 { + if taskId == v.TaskId { return v, true } } @@ -221,12 +308,47 @@ func (this *ModelTask) checkTask(uid string, taskId int32) (*pb.DBTask, bool) { } //更改用户任务 -func (this *ModelTask) modifyUserTask(uid string, taskId string, data map[string]interface{}) error { - if err := this.ChangeList(uid, taskId, data); err != nil { - this.moduleTask.Errorf("err %v", err) - return err +func (this *ModelTask) modifyUserTask(uid string, taskId int32, data map[string]interface{}) error { + var task *pb.DBTask + if err := this.GetList(uid, &task); err != nil { + this.moduleTask.Errorf("getTaskById err %v", err) + return nil } - return nil + var err error + for _, v := range task.DayList { + if v.TaskId == taskId { + v.Progress = data["progress"].(int32) + v.Status = data["status"].(int32) + } + } + day_update := map[string]interface{}{ + "dayList": task.DayList, + } + err = this.Change(uid, day_update) + + for _, v := range task.WeekList { + if v.TaskId == taskId { + v.Progress = data["progress"].(int32) + v.Status = data["status"].(int32) + } + } + week_update := map[string]interface{}{ + "weekList": task.WeekList, + } + err = this.Change(uid, week_update) + + for _, v := range task.AchieveList { + if v.TaskId == taskId { + v.Progress = data["progress"].(int32) + v.Status = data["status"].(int32) + } + } + achieve_update := map[string]interface{}{ + "achieveList": task.AchieveList, + } + err = this.Change(uid, achieve_update) + + return err } //清空任务 @@ -235,56 +357,59 @@ func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) { this.moduleTask.Error("TaskTag参数缺失", log.Fields{"uid": uid, "params": taskTag}) return } - taskList := this.getTaskListByTag(uid, taskTag[0]) + var task *pb.DBTask + if err := this.GetList(uid, &task); err != nil { + this.moduleTask.Errorf("getTaskById err %v", err) + return + } + + if task == nil { + this.moduleTask.Error("任务数据空", log.Fields{"uid": uid, "taskTag": taskTag}) + return + } + dr := this.moduleTask.ModuleRtask.GetCondiData(uid) - for _, v := range taskList { - if err := this.moduleTask.modelTask.DelListlds(uid, v.Id); err != nil { - this.moduleTask.Error("清除任务", log.Fields{"uid": uid, "taskId": v.Id}) - return - } - //删除任务条件数据 - if dr != nil && dr.Vals != nil { - delete(dr.Vals, v.TypeId) - } - } - if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil { - this.moduleTask.Error("更新任务条件数据", log.Fields{"uid": uid}) - } -} -//进入卡牌攻略 -// Deprecated -func (this *ModelTask) inStrategy(uid string, heroCfgId int32) (taskIds []int32, err error) { - //检查此英雄攻略是否完成 - taskList := this.getTaskListByTag(uid, comm.TASK_STRATEGY) - allFinished := true - for _, v := range taskList { - conf := this.moduleTask.configure.getTaskById(v.TaskId) - if conf != nil { - // if conf.RestrictiveCondition == heroCfgId && v.Status != 1 { - // allFinished = false - // break - // } - } - } - - if !allFinished { - //重置状态 - for _, v := range taskList { - if v.Status != 0 { - update := map[string]interface{}{ - "status": 0, - } - if err = this.modifyUserTask(uid, v.Id, update); err != nil { - this.moduleTask.Errorf("doStrategy err %v", err) - break - } + update := map[string]interface{}{} + if taskTag[0] == comm.TASK_DAILY { + for _, v := range task.DayList { + //删除任务条件数据 + if dr != nil && dr.Vals != nil { + delete(dr.Vals, v.TypeId) } - taskIds = append(taskIds, v.TaskId) } + if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil { + this.moduleTask.Error("更新任务条件数据", log.Fields{"uid": uid}) + } + update["dayList"] = make([]*pb.TaskData, 0) + } else if taskTag[0] == comm.TASK_WEEKLY { + for _, v := range task.WeekList { + //删除任务条件数据 + if dr != nil && dr.Vals != nil { + delete(dr.Vals, v.TypeId) + } + } + if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil { + this.moduleTask.Error("更新任务条件数据", log.Fields{"uid": uid}) + } + update["weekList"] = make([]*pb.TaskData, 0) + } else if taskTag[0] == comm.TASK_ACHIEVE { + for _, v := range task.AchieveList { + //删除任务条件数据 + if dr != nil && dr.Vals != nil { + delete(dr.Vals, v.TypeId) + } + } + if err := this.moduleTask.ModuleRtask.ChangeCondi(uid, dr.Vals); err != nil { + this.moduleTask.Error("更新任务条件数据", log.Fields{"uid": uid}) + } + update["weekList"] = make([]*pb.TaskData, 0) + } + + if err := this.moduleTask.modelTask.Change(uid, update); err != nil { + this.moduleTask.Error("清空任务数据", log.Fields{"uid": uid}) } - return } // 任务处理 @@ -321,6 +446,7 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface progress int32 update map[string]interface{} ) + if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == pb.ErrorCode_Success { // update data if ret != nil && len(ret.Data) > 0 { @@ -330,7 +456,6 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface "progress": progress, "status": 1, } - // err = this.updateActive(tl.Uid, conf.Key) } else { if ret != nil && len(ret.Data) > 0 { progress = ret.Data[0] @@ -339,7 +464,7 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface "progress": progress, } } - if err = this.modifyUserTask(tl.Uid, task.Id, update); err != nil { + if err = this.modifyUserTask(tl.Uid, task.TaskId, update); err != nil { return } this.moduleTask.Debug("更新任务", diff --git a/modules/task/module.go b/modules/task/module.go index de480b92e..67d36385d 100644 --- a/modules/task/module.go +++ b/modules/task/module.go @@ -104,17 +104,21 @@ func (this *ModuleTask) resetActive(uid string, taskTag comm.TaskTag) { } // 获取玩家指定任务 -func (this *ModuleTask) GetTaskById(uid string, taskId int32) *pb.DBTask { - list := []*pb.DBTask{} - if err := this.modelTask.GetList(uid, &list); err != nil { +func (this *ModuleTask) GetTaskById(uid string, taskTag, taskId int32) *pb.TaskData { + var task *pb.DBTask + if err := this.modelTask.GetList(uid, &task); err != nil { log.Errorf("GetTaskById err %v", err) return nil } - for _, v := range list { - if v.TaskId == taskId { - return v + + if taskTag == int32(comm.TASK_DAILY) { + for _, v := range task.DayList { + if v.TaskId == taskId { + return v + } } } + return nil } @@ -134,8 +138,9 @@ func (this *ModuleTask) CleanData(uid string) { //任务处理器注册 type taskHandle func(uid string, taskId int32, tp *pb.TaskParam) *pb.DBTask -func (this *ModuleTask) GetTaskFinished(uid string, taskTage comm.TaskTag) []*pb.DBTask { - return this.modelTask.getFinishTasks(uid, taskTage) +// 获取每日任务列表 +func (this *ModuleTask) GetTaskDayFinished(uid string) []*pb.TaskData { + return this.modelTask.getFinishTasks(uid, comm.TASK_DAILY) } func (this *ModuleTask) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) { diff --git a/modules/user/api_login.go b/modules/user/api_login.go index 2ad67e0fd..15689549b 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -146,7 +146,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod // 初始化随机任务数据 // this.module.ModuleRtask.InitCondiData(user.Uid) // 日常登录任务 - this.module.ModuleRtask.SendToRtask(session, comm.Rtype7, 1) + this.module.ModuleRtask.SendToRtask(session, comm.Rtype8, 1) this.module.ModulePrivilege.CheckDailyPrivilegeMail(session) //推送登录公告 diff --git a/pb/task_db.pb.go b/pb/task_db.pb.go index 4c2eb002b..76f8f9c72 100644 --- a/pb/task_db.pb.go +++ b/pb/task_db.pb.go @@ -25,11 +25,11 @@ type DBTask struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - DayList []*TaskData `protobuf:"bytes,4,rep,name=dayList,proto3" json:"dayList" bson:"dayList"` //日常任务列表 - WeekList []*TaskData `protobuf:"bytes,5,rep,name=weekList,proto3" json:"weekList" bson:"weekList"` //周常任务列表 - ActivityList []*ActivityData `protobuf:"bytes,6,rep,name=activityList,proto3" json:"activityList" bson:"activityList"` //活跃度列表 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + DayList []*TaskData `protobuf:"bytes,4,rep,name=dayList,proto3" json:"dayList" bson:"dayList"` //日常任务列表 + WeekList []*TaskData `protobuf:"bytes,5,rep,name=weekList,proto3" json:"weekList" bson:"weekList"` //周常任务列表 + AchieveList []*TaskData `protobuf:"bytes,6,rep,name=achieveList,proto3" json:"achieveList" bson:"achieveList"` //成就任务列表 } func (x *DBTask) Reset() { @@ -92,9 +92,9 @@ func (x *DBTask) GetWeekList() []*TaskData { return nil } -func (x *DBTask) GetActivityList() []*ActivityData { +func (x *DBTask) GetAchieveList() []*TaskData { if x != nil { - return x.ActivityList + return x.AchieveList } return nil } @@ -202,20 +202,83 @@ func (x *TaskData) GetSort() int32 { return 0 } +type DBActivity struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + ActivityList []*ActivityData `protobuf:"bytes,3,rep,name=activityList,proto3" json:"activityList" bson:"activityList"` //活跃度列表 +} + +func (x *DBActivity) Reset() { + *x = DBActivity{} + if protoimpl.UnsafeEnabled { + mi := &file_task_task_db_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBActivity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBActivity) ProtoMessage() {} + +func (x *DBActivity) ProtoReflect() protoreflect.Message { + mi := &file_task_task_db_proto_msgTypes[2] + 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 DBActivity.ProtoReflect.Descriptor instead. +func (*DBActivity) Descriptor() ([]byte, []int) { + return file_task_task_db_proto_rawDescGZIP(), []int{2} +} + +func (x *DBActivity) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBActivity) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *DBActivity) GetActivityList() []*ActivityData { + if x != nil { + return x.ActivityList + } + return nil +} + type ActivityData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TaskId int32 `protobuf:"varint,3,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //taskId - Tag int32 `protobuf:"varint,4,opt,name=tag,proto3" json:"tag" bson:"tag"` //标签 - Received int32 `protobuf:"varint,5,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 + TaskId int32 `protobuf:"varint,1,opt,name=taskId,proto3" json:"taskId" bson:"taskId"` //taskId + Tag int32 `protobuf:"varint,2,opt,name=tag,proto3" json:"tag" bson:"tag"` //标签 + Received int32 `protobuf:"varint,3,opt,name=received,proto3" json:"received" bson:"received"` //领取状态 默认0未领取 1已领取 } func (x *ActivityData) Reset() { *x = ActivityData{} if protoimpl.UnsafeEnabled { - mi := &file_task_task_db_proto_msgTypes[2] + mi := &file_task_task_db_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -228,7 +291,7 @@ func (x *ActivityData) String() string { func (*ActivityData) ProtoMessage() {} func (x *ActivityData) ProtoReflect() protoreflect.Message { - mi := &file_task_task_db_proto_msgTypes[2] + mi := &file_task_task_db_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -241,7 +304,7 @@ func (x *ActivityData) ProtoReflect() protoreflect.Message { // Deprecated: Use ActivityData.ProtoReflect.Descriptor instead. func (*ActivityData) Descriptor() ([]byte, []int) { - return file_task_task_db_proto_rawDescGZIP(), []int{2} + return file_task_task_db_proto_rawDescGZIP(), []int{3} } func (x *ActivityData) GetTaskId() int32 { @@ -269,37 +332,42 @@ var File_task_task_db_proto protoreflect.FileDescriptor var file_task_task_db_proto_rawDesc = []byte{ 0x0a, 0x12, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa9, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x12, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01, 0x0a, 0x06, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x07, 0x64, 0x61, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x07, 0x64, 0x61, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x08, 0x77, 0x65, 0x65, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x44, - 0x61, 0x74, 0x61, 0x52, 0x08, 0x77, 0x65, 0x65, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x31, 0x0a, - 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x06, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, - 0x74, 0x61, 0x52, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, - 0x22, 0xc8, 0x01, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, - 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, - 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, - 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, - 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, - 0x16, 0x0a, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, - 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x54, 0x0a, 0x0c, 0x41, - 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x74, - 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, - 0x6b, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x61, 0x74, 0x61, 0x52, 0x08, 0x77, 0x65, 0x65, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2b, 0x0a, + 0x0b, 0x61, 0x63, 0x68, 0x69, 0x65, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x06, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x61, + 0x63, 0x68, 0x69, 0x65, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xc8, 0x01, 0x0a, 0x08, 0x54, + 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, + 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x61, + 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, + 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, + 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x79, 0x70, + 0x65, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x79, 0x70, 0x65, 0x49, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x61, 0x0a, 0x0a, 0x44, 0x42, 0x41, 0x63, 0x74, 0x69, 0x76, + 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x31, 0x0a, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, + 0x79, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0c, 0x61, 0x63, 0x74, 0x69, + 0x76, 0x69, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x54, 0x0a, 0x0c, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 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, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, + 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x42, 0x06, + 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -314,21 +382,23 @@ func file_task_task_db_proto_rawDescGZIP() []byte { return file_task_task_db_proto_rawDescData } -var file_task_task_db_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_task_task_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_task_task_db_proto_goTypes = []interface{}{ (*DBTask)(nil), // 0: DBTask (*TaskData)(nil), // 1: TaskData - (*ActivityData)(nil), // 2: ActivityData + (*DBActivity)(nil), // 2: DBActivity + (*ActivityData)(nil), // 3: ActivityData } var file_task_task_db_proto_depIdxs = []int32{ 1, // 0: DBTask.dayList:type_name -> TaskData 1, // 1: DBTask.weekList:type_name -> TaskData - 2, // 2: DBTask.activityList:type_name -> ActivityData - 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 + 1, // 2: DBTask.achieveList:type_name -> TaskData + 3, // 3: DBActivity.activityList:type_name -> ActivityData + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_task_task_db_proto_init() } @@ -362,6 +432,18 @@ func file_task_task_db_proto_init() { } } file_task_task_db_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBActivity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_task_task_db_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ActivityData); i { case 0: return &v.state @@ -380,7 +462,7 @@ func file_task_task_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_task_task_db_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/task_msg.pb.go b/pb/task_msg.pb.go index 9ea8d6e4c..a34d8d381 100644 --- a/pb/task_msg.pb.go +++ b/pb/task_msg.pb.go @@ -26,8 +26,8 @@ type TaskReceiveReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` // 1日常/2周常/3成就 - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id"` //任务唯一ID + TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` // 1日常/2周常/3成就 + Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id"` //任务唯一ID } func (x *TaskReceiveReq) Reset() { @@ -69,11 +69,11 @@ func (x *TaskReceiveReq) GetTaskTag() int32 { return 0 } -func (x *TaskReceiveReq) GetId() string { +func (x *TaskReceiveReq) GetId() int32 { if x != nil { return x.Id } - return "" + return 0 } type TaskReceiveResp struct { @@ -176,7 +176,7 @@ type TaskListResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - List []*DBTask `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` + List []*TaskData `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` } func (x *TaskListResp) Reset() { @@ -211,7 +211,7 @@ func (*TaskListResp) Descriptor() ([]byte, []int) { return file_task_task_msg_proto_rawDescGZIP(), []int{3} } -func (x *TaskListResp) GetList() []*DBTask { +func (x *TaskListResp) GetList() []*TaskData { if x != nil { return x.List } @@ -327,8 +327,8 @@ type TaskActiveReceiveReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` // 1日常/2周常 - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id"` //唯一id + TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` // 1日常/2周常 + Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id"` //唯一id } func (x *TaskActiveReceiveReq) Reset() { @@ -370,11 +370,11 @@ func (x *TaskActiveReceiveReq) GetTaskTag() int32 { return 0 } -func (x *TaskActiveReceiveReq) GetId() string { +func (x *TaskActiveReceiveReq) GetId() int32 { if x != nil { return x.Id } - return "" + return 0 } type TaskActiveReceiveResp struct { @@ -382,8 +382,8 @@ type TaskActiveReceiveResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id"` + TaskTag int32 `protobuf:"varint,1,opt,name=taskTag,proto3" json:"taskTag"` + Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id"` } func (x *TaskActiveReceiveResp) Reset() { @@ -425,108 +425,13 @@ func (x *TaskActiveReceiveResp) GetTaskTag() int32 { return 0 } -func (x *TaskActiveReceiveResp) GetId() string { +func (x *TaskActiveReceiveResp) GetId() int32 { if x != nil { return x.Id } - return "" -} - -//攻略 -type TaskDoStrategyReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - HeroCfgId int32 `protobuf:"varint,1,opt,name=heroCfgId,proto3" json:"heroCfgId"` //英雄ID -} - -func (x *TaskDoStrategyReq) Reset() { - *x = TaskDoStrategyReq{} - if protoimpl.UnsafeEnabled { - mi := &file_task_task_msg_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TaskDoStrategyReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TaskDoStrategyReq) ProtoMessage() {} - -func (x *TaskDoStrategyReq) ProtoReflect() protoreflect.Message { - mi := &file_task_task_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 TaskDoStrategyReq.ProtoReflect.Descriptor instead. -func (*TaskDoStrategyReq) Descriptor() ([]byte, []int) { - return file_task_task_msg_proto_rawDescGZIP(), []int{8} -} - -func (x *TaskDoStrategyReq) GetHeroCfgId() int32 { - if x != nil { - return x.HeroCfgId - } return 0 } -type TaskDoStrategyResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - TaskIds []int32 `protobuf:"varint,1,rep,packed,name=taskIds,proto3" json:"taskIds"` //任务ID -} - -func (x *TaskDoStrategyResp) Reset() { - *x = TaskDoStrategyResp{} - if protoimpl.UnsafeEnabled { - mi := &file_task_task_msg_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TaskDoStrategyResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TaskDoStrategyResp) ProtoMessage() {} - -func (x *TaskDoStrategyResp) ProtoReflect() protoreflect.Message { - mi := &file_task_task_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 TaskDoStrategyResp.ProtoReflect.Descriptor instead. -func (*TaskDoStrategyResp) Descriptor() ([]byte, []int) { - return file_task_task_msg_proto_rawDescGZIP(), []int{9} -} - -func (x *TaskDoStrategyResp) GetTaskIds() []int32 { - if x != nil { - return x.TaskIds - } - return nil -} - //任务完成推送 type TaskFinishedPush struct { state protoimpl.MessageState @@ -539,7 +444,7 @@ type TaskFinishedPush struct { func (x *TaskFinishedPush) Reset() { *x = TaskFinishedPush{} if protoimpl.UnsafeEnabled { - mi := &file_task_task_msg_proto_msgTypes[10] + mi := &file_task_task_msg_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -552,7 +457,7 @@ func (x *TaskFinishedPush) String() string { func (*TaskFinishedPush) ProtoMessage() {} func (x *TaskFinishedPush) ProtoReflect() protoreflect.Message { - mi := &file_task_task_msg_proto_msgTypes[10] + mi := &file_task_task_msg_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -565,7 +470,7 @@ func (x *TaskFinishedPush) ProtoReflect() protoreflect.Message { // Deprecated: Use TaskFinishedPush.ProtoReflect.Descriptor instead. func (*TaskFinishedPush) Descriptor() ([]byte, []int) { - return file_task_task_msg_proto_rawDescGZIP(), []int{10} + return file_task_task_msg_proto_rawDescGZIP(), []int{8} } func (x *TaskFinishedPush) GetTaskId() int32 { @@ -584,41 +489,35 @@ var file_task_task_msg_proto_rawDesc = []byte{ 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x29, 0x0a, 0x0f, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, + 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x29, 0x0a, 0x0f, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x27, 0x0a, 0x0b, 0x54, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x2b, 0x0a, 0x0c, 0x54, 0x61, 0x73, - 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x6c, 0x69, 0x73, - 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x54, 0x61, 0x73, 0x6b, - 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x2d, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, - 0x74, 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x74, - 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, - 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x4f, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, - 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x6c, - 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x63, 0x74, 0x69, - 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x16, - 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, - 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x40, 0x0a, 0x14, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, - 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x18, - 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x41, 0x0a, 0x15, 0x54, 0x61, 0x73, 0x6b, - 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x31, 0x0a, 0x11, 0x54, - 0x61, 0x73, 0x6b, 0x44, 0x6f, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x65, 0x71, - 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x43, 0x66, 0x67, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x43, 0x66, 0x67, 0x49, 0x64, 0x22, 0x2e, - 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x6f, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x22, 0x2a, - 0x0a, 0x10, 0x54, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x50, 0x75, - 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x2d, 0x0a, 0x0c, 0x54, 0x61, 0x73, + 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, 0x6c, 0x69, 0x73, + 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x61, + 0x74, 0x61, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x2d, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, + 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, + 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, + 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x4f, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, + 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x40, 0x0a, 0x14, 0x54, 0x61, 0x73, 0x6b, + 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, + 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x41, 0x0a, 0x15, 0x54, 0x61, + 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2a, 0x0a, + 0x10, 0x54, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x50, 0x75, 0x73, + 0x68, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -633,7 +532,7 @@ func file_task_task_msg_proto_rawDescGZIP() []byte { return file_task_task_msg_proto_rawDescData } -var file_task_task_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_task_task_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_task_task_msg_proto_goTypes = []interface{}{ (*TaskReceiveReq)(nil), // 0: TaskReceiveReq (*TaskReceiveResp)(nil), // 1: TaskReceiveResp @@ -643,15 +542,13 @@ var file_task_task_msg_proto_goTypes = []interface{}{ (*TaskActiveListResp)(nil), // 5: TaskActiveListResp (*TaskActiveReceiveReq)(nil), // 6: TaskActiveReceiveReq (*TaskActiveReceiveResp)(nil), // 7: TaskActiveReceiveResp - (*TaskDoStrategyReq)(nil), // 8: TaskDoStrategyReq - (*TaskDoStrategyResp)(nil), // 9: TaskDoStrategyResp - (*TaskFinishedPush)(nil), // 10: TaskFinishedPush - (*DBTask)(nil), // 11: DBTask - (*ActivityData)(nil), // 12: ActivityData + (*TaskFinishedPush)(nil), // 8: TaskFinishedPush + (*TaskData)(nil), // 9: TaskData + (*ActivityData)(nil), // 10: ActivityData } var file_task_task_msg_proto_depIdxs = []int32{ - 11, // 0: TaskListResp.list:type_name -> DBTask - 12, // 1: TaskActiveListResp.list:type_name -> ActivityData + 9, // 0: TaskListResp.list:type_name -> TaskData + 10, // 1: TaskActiveListResp.list:type_name -> ActivityData 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 @@ -763,30 +660,6 @@ func file_task_task_msg_proto_init() { } } file_task_task_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskDoStrategyReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_task_task_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskDoStrategyResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_task_task_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TaskFinishedPush); i { case 0: return &v.state @@ -805,7 +678,7 @@ func file_task_task_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_task_task_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 11, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, From 4893f8496b8f777212217f398c83d52f98e15cfa Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 19 Dec 2022 10:20:08 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=98=B5=E8=90=A5boss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_enchantboss.json | 2018 +++++++++++++++++ bin/json/game_enchantshop.json | 102 + modules/enchant/api.go | 49 + modules/enchant/api_buy.go | 137 ++ modules/enchant/api_challenge.go | 90 + modules/enchant/api_challengeover.go | 119 + modules/enchant/api_getlist.go | 95 + modules/enchant/api_ranklist.go | 59 + modules/enchant/comp_configure.go | 112 + modules/enchant/model_hunting.go | 79 + modules/enchant/model_rank.go | 82 + modules/enchant/module.go | 181 ++ sys/configure/structs/Game.EnchantBoss.go | 42 + sys/configure/structs/Game.EnchantBossData.go | 143 ++ sys/configure/structs/Game.EnchantShop.go | 42 + sys/configure/structs/Game.EnchantShopData.go | 50 + 16 files changed, 3400 insertions(+) create mode 100644 bin/json/game_enchantboss.json create mode 100644 bin/json/game_enchantshop.json create mode 100644 modules/enchant/api.go create mode 100644 modules/enchant/api_buy.go create mode 100644 modules/enchant/api_challenge.go create mode 100644 modules/enchant/api_challengeover.go create mode 100644 modules/enchant/api_getlist.go create mode 100644 modules/enchant/api_ranklist.go create mode 100644 modules/enchant/comp_configure.go create mode 100644 modules/enchant/model_hunting.go create mode 100644 modules/enchant/model_rank.go create mode 100644 modules/enchant/module.go create mode 100644 sys/configure/structs/Game.EnchantBoss.go create mode 100644 sys/configure/structs/Game.EnchantBossData.go create mode 100644 sys/configure/structs/Game.EnchantShop.go create mode 100644 sys/configure/structs/Game.EnchantShopData.go diff --git a/bin/json/game_enchantboss.json b/bin/json/game_enchantboss.json new file mode 100644 index 000000000..605a683ac --- /dev/null +++ b/bin/json/game_enchantboss.json @@ -0,0 +1,2018 @@ +[ + { + "id": 101, + "bossid": 1, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "SSS", + "score_low": 6666667, + "score_up": 99999999, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text1", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text1", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 102, + "bossid": 1, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "SS", + "score_low": 3500001, + "score_up": 6666666, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 2 + }, + { + "a": "attr", + "t": "diamond", + "n": 2 + }, + { + "a": "attr", + "t": "diamond", + "n": 2 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 2 + }, + { + "a": "attr", + "t": "diamond", + "n": 2 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text1", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text1", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301014, + 301015, + 301016 + ] + }, + { + "id": 103, + "bossid": 1, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "S", + "score_low": 1800001, + "score_up": 3500000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 3 + }, + { + "a": "attr", + "t": "diamond", + "n": 3 + }, + { + "a": "attr", + "t": "diamond", + "n": 3 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 3 + }, + { + "a": "attr", + "t": "diamond", + "n": 3 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text1", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text1", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301017, + 301018, + 301019 + ] + }, + { + "id": 104, + "bossid": 1, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "A+", + "score_low": 800001, + "score_up": 1800000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 4 + }, + { + "a": "attr", + "t": "diamond", + "n": 4 + }, + { + "a": "attr", + "t": "diamond", + "n": 4 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 4 + }, + { + "a": "attr", + "t": "diamond", + "n": 4 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text1", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text1", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 105, + "bossid": 1, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "A", + "score_low": 350001, + "score_up": 800000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 5 + }, + { + "a": "attr", + "t": "diamond", + "n": 5 + }, + { + "a": "attr", + "t": "diamond", + "n": 5 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 5 + }, + { + "a": "attr", + "t": "diamond", + "n": 5 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text1", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text1", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 106, + "bossid": 1, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "B", + "score_low": 100001, + "score_up": 350000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 6 + }, + { + "a": "attr", + "t": "diamond", + "n": 6 + }, + { + "a": "attr", + "t": "diamond", + "n": 6 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 6 + }, + { + "a": "attr", + "t": "diamond", + "n": 6 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text1", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text1", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301014, + 301015, + 301016 + ] + }, + { + "id": 107, + "bossid": 1, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "C", + "score_low": 0, + "score_up": 100000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 7 + }, + { + "a": "attr", + "t": "diamond", + "n": 7 + }, + { + "a": "attr", + "t": "diamond", + "n": 7 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 7 + }, + { + "a": "attr", + "t": "diamond", + "n": 7 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text1", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text1", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301017, + 301018, + 301019 + ] + }, + { + "id": 201, + "bossid": 2, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "SSS", + "score_low": 6666667, + "score_up": 99999999, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 8 + }, + { + "a": "attr", + "t": "diamond", + "n": 8 + }, + { + "a": "attr", + "t": "diamond", + "n": 8 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 8 + }, + { + "a": "attr", + "t": "diamond", + "n": 8 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text2", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text2", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 202, + "bossid": 2, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "SS", + "score_low": 3500001, + "score_up": 6666666, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 9 + }, + { + "a": "attr", + "t": "diamond", + "n": 9 + }, + { + "a": "attr", + "t": "diamond", + "n": 9 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 9 + }, + { + "a": "attr", + "t": "diamond", + "n": 9 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text2", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text2", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301014, + 301015, + 301016 + ] + }, + { + "id": 203, + "bossid": 2, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "S", + "score_low": 1800001, + "score_up": 3500000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 10 + }, + { + "a": "attr", + "t": "diamond", + "n": 10 + }, + { + "a": "attr", + "t": "diamond", + "n": 10 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 10 + }, + { + "a": "attr", + "t": "diamond", + "n": 10 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text2", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text2", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301017, + 301018, + 301019 + ] + }, + { + "id": 204, + "bossid": 2, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "A+", + "score_low": 800001, + "score_up": 1800000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 11 + }, + { + "a": "attr", + "t": "diamond", + "n": 11 + }, + { + "a": "attr", + "t": "diamond", + "n": 11 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 11 + }, + { + "a": "attr", + "t": "diamond", + "n": 11 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text2", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text2", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 205, + "bossid": 2, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "A", + "score_low": 350001, + "score_up": 800000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 12 + }, + { + "a": "attr", + "t": "diamond", + "n": 12 + }, + { + "a": "attr", + "t": "diamond", + "n": 12 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 12 + }, + { + "a": "attr", + "t": "diamond", + "n": 12 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text2", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text2", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 206, + "bossid": 2, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "B", + "score_low": 100001, + "score_up": 350000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 13 + }, + { + "a": "attr", + "t": "diamond", + "n": 13 + }, + { + "a": "attr", + "t": "diamond", + "n": 13 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 13 + }, + { + "a": "attr", + "t": "diamond", + "n": 13 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text2", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text2", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301014, + 301015, + 301016 + ] + }, + { + "id": 207, + "bossid": 2, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "C", + "score_low": 0, + "score_up": 100000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 14 + }, + { + "a": "attr", + "t": "diamond", + "n": 14 + }, + { + "a": "attr", + "t": "diamond", + "n": 14 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 14 + }, + { + "a": "attr", + "t": "diamond", + "n": 14 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text2", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text2", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301017, + 301018, + 301019 + ] + }, + { + "id": 301, + "bossid": 3, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "SSS", + "score_low": 6666667, + "score_up": 99999999, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 15 + }, + { + "a": "attr", + "t": "diamond", + "n": 15 + }, + { + "a": "attr", + "t": "diamond", + "n": 15 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 15 + }, + { + "a": "attr", + "t": "diamond", + "n": 15 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text3", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text3", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 302, + "bossid": 3, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "SS", + "score_low": 3500001, + "score_up": 6666666, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 16 + }, + { + "a": "attr", + "t": "diamond", + "n": 16 + }, + { + "a": "attr", + "t": "diamond", + "n": 16 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 16 + }, + { + "a": "attr", + "t": "diamond", + "n": 16 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text3", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text3", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301014, + 301015, + 301016 + ] + }, + { + "id": 303, + "bossid": 3, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "S", + "score_low": 1800001, + "score_up": 3500000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 17 + }, + { + "a": "attr", + "t": "diamond", + "n": 17 + }, + { + "a": "attr", + "t": "diamond", + "n": 17 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 17 + }, + { + "a": "attr", + "t": "diamond", + "n": 17 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text3", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text3", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301017, + 301018, + 301019 + ] + }, + { + "id": 304, + "bossid": 3, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "A+", + "score_low": 800001, + "score_up": 1800000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 18 + }, + { + "a": "attr", + "t": "diamond", + "n": 18 + }, + { + "a": "attr", + "t": "diamond", + "n": 18 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 18 + }, + { + "a": "attr", + "t": "diamond", + "n": 18 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text3", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text3", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 305, + "bossid": 3, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "A", + "score_low": 350001, + "score_up": 800000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 19 + }, + { + "a": "attr", + "t": "diamond", + "n": 19 + }, + { + "a": "attr", + "t": "diamond", + "n": 19 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 19 + }, + { + "a": "attr", + "t": "diamond", + "n": 19 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text3", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text3", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301011, + 301012, + 301013 + ] + }, + { + "id": 306, + "bossid": 3, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "B", + "score_low": 100001, + "score_up": 350000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 20 + }, + { + "a": "attr", + "t": "diamond", + "n": 20 + }, + { + "a": "attr", + "t": "diamond", + "n": 20 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 20 + }, + { + "a": "attr", + "t": "diamond", + "n": 20 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text3", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text3", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301014, + 301015, + 301016 + ] + }, + { + "id": 307, + "bossid": 3, + "name": { + "key": "viking_boss_1001", + "text": "火焰泰坦" + }, + "grade": "C", + "score_low": 0, + "score_up": 100000, + "reward_drop": [ + 10001, + 10002 + ], + "dropshow1": [ + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + }, + { + "a": "attr", + "t": "diamond", + "n": 1 + } + ], + "dropshow2": [ + { + "a": "attr", + "t": "diamond", + "n": 21 + }, + { + "a": "attr", + "t": "diamond", + "n": 21 + }, + { + "a": "attr", + "t": "diamond", + "n": 21 + } + ], + "dropshow3": [ + { + "a": "attr", + "t": "diamond", + "n": 21 + }, + { + "a": "attr", + "t": "diamond", + "n": 21 + } + ], + "dropshow": [ + 1000, + 900, + 78 + ], + "bossmodel": 11009, + "main_text": { + "key": "main_text3", + "text": "BOSS主界面描述" + }, + "strategy_text": { + "key": "strategy_text3", + "text": "BOSS攻略描述" + }, + "boss_skill": 51004, + "boss": [ + 301017, + 301018, + 301019 + ] + } +] \ No newline at end of file diff --git a/bin/json/game_enchantshop.json b/bin/json/game_enchantshop.json new file mode 100644 index 000000000..b66be6731 --- /dev/null +++ b/bin/json/game_enchantshop.json @@ -0,0 +1,102 @@ +[ + { + "buynum": 1, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 10 + } + ] + }, + { + "buynum": 2, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 20 + } + ] + }, + { + "buynum": 3, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 30 + } + ] + }, + { + "buynum": 4, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 40 + } + ] + }, + { + "buynum": 5, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 50 + } + ] + }, + { + "buynum": 6, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 60 + } + ] + }, + { + "buynum": 7, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 70 + } + ] + }, + { + "buynum": 8, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 80 + } + ] + }, + { + "buynum": 9, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 90 + } + ] + }, + { + "buynum": 10, + "need": [ + { + "a": "attr", + "t": "diamond", + "n": 100 + } + ] + } +] \ No newline at end of file diff --git a/modules/enchant/api.go b/modules/enchant/api.go new file mode 100644 index 000000000..18eda61f9 --- /dev/null +++ b/modules/enchant/api.go @@ -0,0 +1,49 @@ +package enchant + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" +) + +const ( + HuntingGetListResp = "getlist" + HuntingChallengeResp = "challenge" + HuntingChallengeOverResp = "challengeover" + HuntingSkillLvResp = "skilllv" + HuntingGetRewardResp = "getreward" + HuntingBuyResp = "buy" + HuntingRankListResp = "ranklist" +) + +type apiComp struct { + modules.MCompGate + service core.IService + configure *configureComp + module *Hunting + friend comm.IFriend + chat comm.IChat +} + +//组件初始化接口 +func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + err = this.MCompGate.Init(service, module, comp, options) + this.module = module.(*Hunting) + + this.service = service + return +} + +func (this *apiComp) Start() (err error) { + err = this.MCompGate.Start() + var module core.IModule + if module, err = this.service.GetModule(comm.ModuleFriend); err != nil { + return + } + this.friend = module.(comm.IFriend) + if module, err = this.service.GetModule(comm.ModuleChat); err != nil { + return + } + this.chat = module.(comm.IChat) + return +} diff --git a/modules/enchant/api_buy.go b/modules/enchant/api_buy.go new file mode 100644 index 000000000..17b24b376 --- /dev/null +++ b/modules/enchant/api_buy.go @@ -0,0 +1,137 @@ +package enchant + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + "go_dreamfactory/utils" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) BuyCheck(session comm.IUserSession, req *pb.HuntingBuyReq) (code pb.ErrorCode) { + if req.Count <= 0 { + code = pb.ErrorCode_ReqParameterError + return + } + return +} + +func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code pb.ErrorCode, data proto.Message) { + var ( + curByCount int32 + costRes *cfg.Gameatn // 门票atn 类型 只取T + mapData map[string]interface{} + szCostRes []*cfg.Gameatn // 购买累计消耗 + curCount int32 // 当前门票数量 + addCount int32 //获得数量 + ) + mapData = make(map[string]interface{}, 0) + code = this.BuyCheck(session, req) + if code != pb.ErrorCode_Success { + return // 参数校验失败直接返回 + } + list, err := this.module.modelHunting.getHuntingList(session.GetUserId()) + if err != nil { + code = pb.ErrorCode_DBError + return + } + + // 校验是不是今天 + if !utils.IsToday(list.CTime) { + list.CTime = configure.Now().Unix() + list.BuyCount = 0 + mapData["cTime"] = list.CTime + mapData["buyCount"] = list.BuyCount + } else { + curByCount = list.BuyCount + } + curByCount += req.Count // 当前需要购买的数量 + if this.configure.GetMaxBuyChallengeCount() < curByCount { + code = pb.ErrorCode_HuntingBuyMaxCount + return + } + conf := this.module.configure.GetGlobalConf() + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + costRes = conf.HuntingCos + if costRes == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 + curCount = amount + if amount < conf.HuntingNum { + if list.RecoveryTime == 0 { + list.RecoveryTime = configure.Now().Unix() + } + for { // 计算恢复时间 + if list.RecoveryTime+int64(conf.HuntingRecovery*60) <= configure.Now().Unix() { + curCount++ + list.RecoveryTime += int64(conf.HuntingRecovery * 60) + if curCount >= conf.HuntingNum { + list.RecoveryTime = 0 + break + } + } else { + break + } + } + if curCount-amount > 0 { + addCount = curCount - amount + } + } else { + list.RecoveryTime = 0 + } + addCount += req.Count + if amount+addCount > conf.VikingNum { + code = pb.ErrorCode_VikingBuyMaxCount + return + } + mapData["recoveryTime"] = list.RecoveryTime + + for i := list.BuyCount + 1; i <= curByCount; i++ { + _cfg := this.configure.GetBuyChallengeCount(i) + if _cfg == nil { + code = pb.ErrorCode_HuntingBuyMaxCount + return + } + szCostRes = append(szCostRes, _cfg.Need...) + } + sz := make([]*cfg.Gameatn, 0) + for _, v := range szCostRes { + bFound := false + for _, v1 := range sz { + if v.A == v1.A && v.T == v1.T { + v1.N += v.N + bFound = true + break + } + } + if !bFound { + sz = append(sz, v) + } + } + //消耗 + if code = this.module.ConsumeRes(session, sz, true); code != pb.ErrorCode_Success { + return + } + res := &cfg.Gameatn{ + A: "item", + T: costRes.T, + N: addCount, + } + if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success { + return + } + list.BuyCount = curByCount + mapData["buyCount"] = curByCount + code = this.module.ModifyHuntingData(session.GetUserId(), mapData) + + session.SendMsg(string(this.module.GetType()), HuntingBuyResp, &pb.HuntingBuyResp{Data: list}) + return +} diff --git a/modules/enchant/api_challenge.go b/modules/enchant/api_challenge.go new file mode 100644 index 000000000..a3baf53a7 --- /dev/null +++ b/modules/enchant/api_challenge.go @@ -0,0 +1,90 @@ +package enchant + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.HuntingChallengeReq) (code pb.ErrorCode) { + if req.BossType <= 0 && req.Difficulty > 0 { + code = pb.ErrorCode_ReqParameterError + return + } + return +} + +///挑战主线关卡 +func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallengeReq) (code pb.ErrorCode, data proto.Message) { + + code = this.ChallengeCheck(session, req) + if code != pb.ErrorCode_Success { + return // 参数校验失败直接返回 + } + + hunting, err := this.module.modelHunting.getHuntingList(session.GetUserId()) + if err != nil { + code = pb.ErrorCode_PagodaNotFound + return + } + conf := this.module.configure.GetGlobalConf() + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + costRes := conf.HuntingCos + if costRes == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + if code = this.module.CheckRes(session, []*cfg.Gameatn{costRes}); code != pb.ErrorCode_Success { + code = pb.ErrorCode_HuntingNoChallengeCount + return + } + // if hunting.ChallengeCount > this.module.configure.GetGlobalConf().HuntingNum+hunting.BuyCount { + // code = pb.ErrorCode_HuntingMaxChallengeCount + // return + // } + cfgData := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty) + if cfgData == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + value, ok := hunting.Boss[req.BossType] + if !ok { // 类型校验 + hunting.Boss[req.BossType] = 0 + } + if value < req.Difficulty { + if value+1 != req.Difficulty { + code = pb.ErrorCode_HuntingLvErr + return + } + } + + code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{ + Ptype: pb.PlayType_hunting, + Title: "", + Format: &pb.BattleFormation{ + Leadpos: req.Leadpos, + Format: req.Teamids, + }, + Mformat: cfgData.Boss, + }) + if code != pb.ErrorCode_Success { + return + } + session.SendMsg(string(this.module.GetType()), HuntingChallengeResp, &pb.HuntingChallengeResp{ + Info: &pb.BattleInfo{Id: record.Id, Title: record.Title, Btype: record.Btype, Ptype: record.Ptype, RedCompId: record.RedCompId, Redflist: record.Redflist, BlueCompId: record.BlueCompId, Buleflist: record.Buleflist}, + BossType: req.BossType, + Difficulty: req.Difficulty, + }) + if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { + this.chat.SendSysChatToWorld(comm.ChatSystem15, nil, req.BossType, req.Difficulty, user.Name) + } else { + this.module.Errorf("no found userdata uid:%s", session.GetUserId()) + } + return +} diff --git a/modules/enchant/api_challengeover.go b/modules/enchant/api_challengeover.go new file mode 100644 index 000000000..d3bdd872b --- /dev/null +++ b/modules/enchant/api_challengeover.go @@ -0,0 +1,119 @@ +package enchant + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.HuntingChallengeOverReq) (code pb.ErrorCode) { + if req.BossType <= 0 && req.Difficulty > 0 { + code = pb.ErrorCode_ReqParameterError + return + } + return +} + +///挑战主线关卡 +func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingChallengeOverReq) (code pb.ErrorCode, data proto.Message) { + var ( + mapData map[string]interface{} + newChallenge bool // 新的关卡 + reward []*cfg.Gameatn + bWin bool // 战斗是否胜利 + ) + mapData = make(map[string]interface{}, 0) + reward = make([]*cfg.Gameatn, 0) + code = this.ChallengeOverCheck(session, req) + if code != pb.ErrorCode_Success { + return // 参数校验失败直接返回 + } + + hunting, err := this.module.modelHunting.getHuntingList(session.GetUserId()) + if err != nil { + code = pb.ErrorCode_PagodaNotFound + return + } + conf := this.module.configure.GetGlobalConf() + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + costRes := conf.HuntingCos + if costRes == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + if code = this.module.CheckRes(session, []*cfg.Gameatn{costRes}); code != pb.ErrorCode_Success { + code = pb.ErrorCode_HuntingNoChallengeCount + return + } + + cfgHunting := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty) + if cfgHunting == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + value, ok := hunting.Boss[req.BossType] + if !ok { // 类型校验 + hunting.Boss[req.BossType] = 0 + } + if value < req.Difficulty { + if value+1 != req.Difficulty { + code = pb.ErrorCode_HuntingLvErr + return + } + newChallenge = true + } + // 校验门票数量够不够 + if code = this.module.ConsumeRes(session, []*cfg.Gameatn{costRes}, true); code != pb.ErrorCode_Success { + return + } + // check + code, bWin = this.module.battle.CheckBattleReport(session, req.Report) + if code != pb.ErrorCode_Success { + return + } + + amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 + + if amount < conf.HuntingNum { + hunting.RecoveryTime = configure.Now().Unix() + mapData["recoveryTime"] = hunting.RecoveryTime + } + if bWin { + this.module.CheckRank(session.GetUserId(), req.BossType, req.Difficulty, hunting, req.Report) + } + // 耗时校验 当前战斗胜利时间消耗小于之前刷新数据 + + // 发放通关随机奖励 + reward = this.module.configure.GetDropReward(cfgHunting.Drop) // 获取掉落奖励 + if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success { + return + } + if newChallenge && bWin { // 新关卡挑战通过 发放首通奖励 + if code = this.module.DispenseRes(session, cfgHunting.Firstprize, true); code != pb.ErrorCode_Success { + return + } + hunting.Boss[req.BossType] += 1 + mapData["boss"] = hunting.Boss + + } + for k := range hunting.Boss { + hunting.Boss[k] += 1 + } + mapData["challengeTime"] = hunting.BossTime + code = this.module.ModifyHuntingData(session.GetUserId(), mapData) + session.SendMsg(string(this.module.GetType()), HuntingChallengeOverResp, &pb.HuntingChallengeOverResp{Data: hunting}) + + // 随机任务统计 + this.module.ModuleRtask.SendToRtask(session, comm.Rtype81, req.Difficulty, req.BossType) + this.module.ModuleRtask.SendToRtask(session, comm.Rtype82, req.BossType) + + return +} diff --git a/modules/enchant/api_getlist.go b/modules/enchant/api_getlist.go new file mode 100644 index 000000000..8b6d7f8ca --- /dev/null +++ b/modules/enchant/api_getlist.go @@ -0,0 +1,95 @@ +package enchant + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + "go_dreamfactory/utils" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.HuntingGetListReq) (code pb.ErrorCode) { + + return +} + +func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListReq) (code pb.ErrorCode, data proto.Message) { + var ( + mapData map[string]interface{} + curCount int32 + ) + mapData = make(map[string]interface{}, 0) + code = this.GetListCheck(session, req) + if code != pb.ErrorCode_Success { + return // 参数校验失败直接返回 + } + + list, err := this.module.modelHunting.getHuntingList(session.GetUserId()) + if err != nil { + code = pb.ErrorCode_DBError + return + } + // 校验 是不是当天 + if !utils.IsToday(list.CTime) { + list.CTime = configure.Now().Unix() + list.BuyCount = 0 + mapData["cTime"] = list.CTime + mapData["buyCount"] = list.BuyCount + + } + // 检查恢复时间 + conf := this.module.configure.GetGlobalConf() + if conf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + costRes := conf.HuntingCos + if costRes == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 + curCount = amount + if amount < conf.HuntingNum { + if list.RecoveryTime == 0 { + list.RecoveryTime = configure.Now().Unix() + } + for { // 计算恢复时间 + if list.RecoveryTime+int64(conf.HuntingRecovery*60) <= configure.Now().Unix() { + curCount++ + list.RecoveryTime += int64(conf.HuntingRecovery * 60) + if curCount >= conf.HuntingNum { + list.RecoveryTime = 0 + break + } + } else { + break + } + } + + addCount := curCount - amount + if addCount > 0 { + res := &cfg.Gameatn{ + A: "item", + T: costRes.T, + N: addCount, + } + if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success { + return + } + } + } else { + list.RecoveryTime = 0 + } + mapData["recoveryTime"] = list.RecoveryTime + code = this.module.ModifyHuntingData(session.GetUserId(), mapData) //修改内存信息 + // 发送难度 + for k := range list.Boss { + list.Boss[k] += 1 + } + session.SendMsg(string(this.module.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list}) + return +} diff --git a/modules/enchant/api_ranklist.go b/modules/enchant/api_ranklist.go new file mode 100644 index 000000000..85ef360c0 --- /dev/null +++ b/modules/enchant/api_ranklist.go @@ -0,0 +1,59 @@ +package enchant + +import ( + "context" + "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/redis/pipe" + "go_dreamfactory/pb" + "strconv" + + "github.com/go-redis/redis/v8" + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) RankListCheck(session comm.IUserSession, req *pb.HuntingRankListReq) (code pb.ErrorCode) { + + return +} + +func (this *apiComp) RankList(session comm.IUserSession, req *pb.HuntingRankListReq) (code pb.ErrorCode, data proto.Message) { + var ( + szRank []*pb.DBHuntingRank + rd *redis.StringSliceCmd + ) + code = this.RankListCheck(session, req) + if code != pb.ErrorCode_Success { + return // 参数校验失败直接返回 + } + if !req.Friend { + var ( + pipe *pipe.RedisPipe = this.module.modelHunting.Redis.RedisPipe(context.TODO()) + ) + rd = pipe.ZRange("huntingRank"+strconv.Itoa(int(req.BoosType)), 0, -1) + + if _, err := pipe.Exec(); err != nil { + this.module.Errorln(err) + return + } + _dataList := rd.Val() + for _, v := range _dataList { + result := &pb.DBHuntingRank{} + if err := this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil { + szRank = append(szRank, result) + } + } + + } else { + uids := this.friend.GetFriendList(session.GetUserId()) + for _, id := range uids { + rankData := this.module.modulerank.getHuntingRankListByBossType(id, req.BoosType) + if rankData != nil { + szRank = append(szRank, rankData) + } + } + } + + session.SendMsg(string(this.module.GetType()), HuntingRankListResp, &pb.HuntingRankListResp{Ranks: szRank}) + return +} diff --git a/modules/enchant/comp_configure.go b/modules/enchant/comp_configure.go new file mode 100644 index 000000000..d7aba3dec --- /dev/null +++ b/modules/enchant/comp_configure.go @@ -0,0 +1,112 @@ +package enchant + +import ( + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + "sync" +) + +const ( + game_huntingboss = "game_huntingboss.json" + game_challenge = "game_huntingchallenge.json" +) + +///配置管理基础组件 +type configureComp struct { + hlock sync.RWMutex + modules.MCompConfigure + _huntingMap map[int64]*cfg.GameHuntingBossData +} + +//组件初始化接口 +func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + err = this.MCompConfigure.Init(service, module, comp, options) + + this._huntingMap = make(map[int64]*cfg.GameHuntingBossData, 0) + configure.RegisterConfigure(game_huntingboss, cfg.NewGameHuntingBoss, func() { + if v, err := this.GetConfigure(game_huntingboss); err == nil { + if configure, ok := v.(*cfg.GameHuntingBoss); ok { + this.hlock.Lock() + defer this.hlock.Unlock() + for _, value := range configure.GetDataList() { + this._huntingMap[int64(value.Type<<16)+int64(value.Difficulty)] = value + } + return + } + } else { + log.Errorf("get game_huntingboss conf err:%v", err) + } + return + }) + err = this.LoadConfigure(game_challenge, cfg.NewGameHuntingChallenge) + return +} + +// 参数: boss类型 难度 +func (this *configureComp) GetHuntingBossConfigData(bossType int32, difficulty int32) (data *cfg.GameHuntingBossData) { + + return this._huntingMap[int64(bossType<<16)+int64(difficulty)] +} + +//加载多个配置文件 +func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) { + for k, v := range confs { + err = configure.RegisterConfigure(k, v, nil) + if err != nil { + log.Errorf("配置文件:%s解析失败!", k) + break + } + } + return +} + +//读取配置数据 +func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { + return configure.GetConfigure(name) +} + +// get boss Type +func (this *configureComp) GetHuntingBossTypeConfigData() (mapType map[int32]struct{}) { + + mapType = make(map[int32]struct{}, 0) + if v, err := this.GetConfigure(game_huntingboss); err == nil { + if configure, ok := v.(*cfg.GameHuntingBoss); ok { + this.hlock.Lock() + defer this.hlock.Unlock() + for _, value := range configure.GetDataList() { + if _, ok := mapType[value.Type]; !ok { + mapType[value.Type] = struct{}{} + } + } + + } + } + return +} + +func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameHuntingChallengeData) { + if v, err := this.GetConfigure(game_challenge); err == nil { + if configure, ok := v.(*cfg.GameHuntingChallenge); ok { + data = configure.Get(index) + return + } + } else { + log.Errorf("get game_challenge conf err:%v", err) + } + + return +} +func (this *configureComp) GetMaxBuyChallengeCount() int32 { + if v, err := this.GetConfigure(game_challenge); err == nil { + if configure, ok := v.(*cfg.GameHuntingChallenge); ok { + return int32(len(configure.GetDataList())) + } + } else { + log.Errorf("get game_challenge conf err:%v", err) + } + + return 0 +} diff --git a/modules/enchant/model_hunting.go b/modules/enchant/model_hunting.go new file mode 100644 index 000000000..f468fbbdf --- /dev/null +++ b/modules/enchant/model_hunting.go @@ -0,0 +1,79 @@ +package enchant + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/mgo" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + "strconv" + + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" +) + +type modelHunting struct { + modules.MCompModel + module *Hunting +} + +func (this *modelHunting) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.TableName = string(comm.TableHunting) + err = this.MCompModel.Init(service, module, comp, options) + this.module = module.(*Hunting) + // uid 创建索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) + return +} + +func (this *modelHunting) modifyHuntingDataByObjId(uid string, data map[string]interface{}) error { + return this.Change(uid, data) +} + +// 获取列表信息 +func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err error) { + result = &pb.DBHunting{ + Id: primitive.NewObjectID().Hex(), + Uid: uid, + Boss: make(map[int32]int32), + BossTime: make(map[string]int32), + } + if err = this.Get(uid, result); err != nil && mgo.MongodbNil != err { + + return + } + if mgo.MongodbNil == err { + if len(result.Boss) == 0 { + _cfg := this.module.configure.GetHuntingBossTypeConfigData() + for k := range _cfg { + result.Boss[k] = 0 + str := strconv.Itoa(int(k)) + "_1" + result.BossTime[str] = 0 + } + } + this.Add(uid, result) + } + err = nil + return result, err +} + +// 红点检测 +func (this *modelHunting) checkReddot32(uid string) bool { + + conf := this.module.configure.GetGlobalConf() + if conf == nil { + return false + } + costRes := conf.HuntingCos + if costRes == nil { + return false + } + amount := int32(this.module.ModuleItems.QueryItemAmount(uid, costRes.T)) // 获取当前数量 + if amount > 0 { + return true + } + return false +} diff --git a/modules/enchant/model_rank.go b/modules/enchant/model_rank.go new file mode 100644 index 000000000..22f91442d --- /dev/null +++ b/modules/enchant/model_rank.go @@ -0,0 +1,82 @@ +package enchant + +import ( + "context" + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/redis/pipe" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + "go_dreamfactory/sys/db" + + "github.com/go-redis/redis/v8" +) + +type ModelRank struct { + modules.MCompModel + moduleHunting *Hunting +} + +func (this *ModelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.TableName = comm.TableHuntingRecord // 挑战记录 + err = this.MCompModel.Init(service, module, comp, options) + this.moduleHunting = module.(*Hunting) + return +} + +func (this *ModelRank) AddRankList(uId string, objId string, data *pb.DBHuntingRank) (err error) { + + if err = this.AddList(uId, objId, data); err != nil { + return + } + return nil +} + +func (this *ModelRank) getHuntingRankList(uid string) []*pb.DBHuntingRank { + ranks := make([]*pb.DBHuntingRank, 0) + err := this.GetList(uid, &ranks) + if err != nil { + return nil + } + return ranks +} + +func (this *ModelRank) getHuntingRankListByBossType(uid string, bossType int32) *pb.DBHuntingRank { + ranks := make([]*pb.DBHuntingRank, 0) + err := this.GetList(uid, &ranks) + if err != nil { + return nil + } + for _, v := range ranks { + if v.Bosstype == bossType { + return v + } + } + return nil +} + +// 排行数据写跨服 +func (this *ModelRank) SetRankListData(tableName string, score int32, uid string) { + if !db.IsCross() { + if conn, err := db.Cross(); err == nil { + var ( + pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO()) + menbers *redis.Z + ) + + menbers = &redis.Z{Score: float64(score), Member: uid} + + if cmd := pipe.ZAdd(tableName, menbers); cmd != nil { + + dock, err1 := cmd.Result() + if err1 != nil { + this.moduleHunting.Errorln(dock, err1) + } + } + if _, err := pipe.Exec(); err != nil { + this.moduleHunting.Errorln(err) + return + } + } + } +} diff --git a/modules/enchant/module.go b/modules/enchant/module.go new file mode 100644 index 000000000..5d94d3f49 --- /dev/null +++ b/modules/enchant/module.go @@ -0,0 +1,181 @@ +package enchant + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + "go_dreamfactory/sys/db" + "strconv" + "time" + + "go.mongodb.org/mongo-driver/bson/primitive" +) + +type Hunting struct { + modules.ModuleBase + modelHunting *modelHunting + api *apiComp + configure *configureComp + modulerank *ModelRank + battle comm.IBattle + service core.IService +} + +func NewModule() core.IModule { + return &Hunting{} +} + +func (this *Hunting) GetType() core.M_Modules { + return comm.ModuleHunting +} + +func (this *Hunting) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { + err = this.ModuleBase.Init(service, module, options) + this.service = service + return +} + +func (this *Hunting) Start() (err error) { + err = this.ModuleBase.Start() + var module core.IModule + if module, err = this.service.GetModule(comm.ModuleBattle); err != nil { + return + } + + this.battle = module.(comm.IBattle) + return +} + +func (this *Hunting) OnInstallComp() { + this.ModuleBase.OnInstallComp() + this.api = this.RegisterComp(new(apiComp)).(*apiComp) + this.modelHunting = this.RegisterComp(new(modelHunting)).(*modelHunting) + this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank) + this.configure = this.RegisterComp(new(configureComp)).(*configureComp) +} + +// 接口信息 +func (this *Hunting) ModifyHuntingData(uid string, data map[string]interface{}) (code pb.ErrorCode) { + err := this.modelHunting.modifyHuntingDataByObjId(uid, data) + if err != nil { + code = pb.ErrorCode_DBError + } + return +} + +func (this *Hunting) CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingRank) { + list, err := this.modelHunting.getHuntingList(uid) + if err != nil { + for k := range list.Boss { + _d := this.modulerank.getHuntingRankListByBossType(uid, k) + if _d != nil { + data = append(data, _d) + } + } + } + return +} +func (this *Hunting) CheckRank(uid string, boosID int32, difficulty int32, hunting *pb.DBHunting, report *pb.BattleReport) { + costTime := report.Costtime + key := strconv.Itoa(int(boosID)) + "_" + strconv.Itoa(int(difficulty)) + + if hunting.BossTime[key] > costTime || hunting.BossTime[key] == 0 && difficulty >= hunting.Boss[boosID] { // 刷新记录 + hunting.BossTime[key] = costTime + szLine := make([]*pb.LineUp, 5) + Leadpos := 0 + if report != nil && report.Info != nil && len(report.Info.Redflist) > 0 { + costTime = report.Costtime + Leadpos = int(report.Info.Redflist[0].Leadpos) + for i, v := range report.Info.Redflist[0].Team { + if v != nil { + szLine[i] = &pb.LineUp{ + Cid: v.HeroID, + Star: v.Star, + Lv: v.Lv, + } + } + } + } + // 写入排行榜 + objID := "" + bFind := false + ranks := this.modulerank.getHuntingRankList(uid) + for _, v := range ranks { + if v.Bosstype == boosID { + mapRankData := make(map[string]interface{}, 0) + mapRankData["difficulty"] = difficulty + mapRankData["bosstype"] = boosID + mapRankData["Leadpos"] = Leadpos + mapRankData["line"] = szLine + mapRankData["costTime"] = costTime + conn_, _ := db.Cross() + dbModel := db.NewDBModel(comm.TableHuntingRank, time.Hour, conn_) + dbModel.ChangeList(uid, v.Id, mapRankData) + objID = v.Id + bFind = true + break + } + } + if !bFind { + userinfo := this.ModuleUser.GetUser(uid) + new := &pb.DBHuntingRank{ + Id: primitive.NewObjectID().Hex(), + Uid: uid, + Difficulty: difficulty, + Bosstype: boosID, + Nickname: userinfo.Name, + Icon: "", + Lv: userinfo.Lv, + Leadpos: int32(Leadpos), + Line: szLine, + CostTime: costTime, + } + objID = new.Id + conn_, _ := db.Cross() + dbModel := db.NewDBModel(comm.TableHuntingRank, time.Hour, conn_) + dbModel.AddList(uid, new.Id, new) + } + this.modulerank.SetRankListData("huntingRank"+strconv.Itoa(int(boosID)), difficulty<<16+costTime, objID) + } +} + +//红点查询 +func (this *Hunting) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) { + reddot = make(map[comm.ReddotType]bool) + for _, v := range rid { + switch v { + case comm.Reddot32: + reddot[comm.Reddot32] = this.modelHunting.checkReddot32(session.GetUserId()) + break + + } + } + return +} + +// 解锁远征所有难度 +func (this *Hunting) CompleteAllLevel(session comm.IUserSession) (code pb.ErrorCode) { + list, err := this.modelHunting.getHuntingList(session.GetUserId()) + if err != nil { + code = pb.ErrorCode_DBError + return + } + mapData := make(map[string]interface{}, 0) + // 查配置获取每个Boss的最大难度 + for k := range list.Boss { + for i := 1; ; i++ { + conf := this.configure.GetHuntingBossConfigData(k, int32(i)) + if conf == nil { + list.Boss[k] = int32(i - 1) + } + } + } + mapData["boss"] = list.Boss + code = this.ModifyHuntingData(session.GetUserId(), mapData) + for k := range list.Boss { + list.Boss[k] += 1 + } + session.SendMsg(string(this.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list}) + return +} diff --git a/sys/configure/structs/Game.EnchantBoss.go b/sys/configure/structs/Game.EnchantBoss.go new file mode 100644 index 000000000..4d84c9e1d --- /dev/null +++ b/sys/configure/structs/Game.EnchantBoss.go @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +type GameEnchantBoss struct { + _dataMap map[int32]*GameEnchantBossData + _dataList []*GameEnchantBossData +} + +func NewGameEnchantBoss(_buf []map[string]interface{}) (*GameEnchantBoss, error) { + _dataList := make([]*GameEnchantBossData, 0, len(_buf)) + dataMap := make(map[int32]*GameEnchantBossData) + for _, _ele_ := range _buf { + if _v, err2 := DeserializeGameEnchantBossData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Id] = _v + } + } + return &GameEnchantBoss{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *GameEnchantBoss) GetDataMap() map[int32]*GameEnchantBossData { + return table._dataMap +} + +func (table *GameEnchantBoss) GetDataList() []*GameEnchantBossData { + return table._dataList +} + +func (table *GameEnchantBoss) Get(key int32) *GameEnchantBossData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/Game.EnchantBossData.go b/sys/configure/structs/Game.EnchantBossData.go new file mode 100644 index 000000000..d42584ab8 --- /dev/null +++ b/sys/configure/structs/Game.EnchantBossData.go @@ -0,0 +1,143 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +import "errors" + +type GameEnchantBossData struct { + Id int32 + Bossid int32 + Name string + Grade string + ScoreLow int32 + ScoreUp int32 + RewardDrop []int32 + Dropshow1 []*Gameatn + Dropshow2 []*Gameatn + Dropshow3 []*Gameatn + Dropshow []int32 + Bossmodel int32 + MainText string + StrategyText string + BossSkill int32 + Boss []int32 +} + +const TypeId_GameEnchantBossData = -287548876 + +func (*GameEnchantBossData) GetTypeId() int32 { + return -287548876 +} + +func (_v *GameEnchantBossData)Deserialize(_buf map[string]interface{}) (err error) { + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["bossid"].(float64); !_ok_ { err = errors.New("bossid error"); return }; _v.Bossid = int32(_tempNum_) } + {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["name"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Name error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Name, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } } + { var _ok_ bool; if _v.Grade, _ok_ = _buf["grade"].(string); !_ok_ { err = errors.New("grade error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["score_low"].(float64); !_ok_ { err = errors.New("score_low error"); return }; _v.ScoreLow = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["score_up"].(float64); !_ok_ { err = errors.New("score_up error"); return }; _v.ScoreUp = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["reward_drop"].([]interface{}); !_ok_ { err = errors.New("reward_drop error"); return } + + _v.RewardDrop = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.RewardDrop = append(_v.RewardDrop, _list_v_) + } + } + + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["dropshow1"].([]interface{}); !_ok_ { err = errors.New("dropshow1 error"); return } + + _v.Dropshow1 = make([]*Gameatn, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ *Gameatn + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } } + _v.Dropshow1 = append(_v.Dropshow1, _list_v_) + } + } + + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["dropshow2"].([]interface{}); !_ok_ { err = errors.New("dropshow2 error"); return } + + _v.Dropshow2 = make([]*Gameatn, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ *Gameatn + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } } + _v.Dropshow2 = append(_v.Dropshow2, _list_v_) + } + } + + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["dropshow3"].([]interface{}); !_ok_ { err = errors.New("dropshow3 error"); return } + + _v.Dropshow3 = make([]*Gameatn, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ *Gameatn + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } } + _v.Dropshow3 = append(_v.Dropshow3, _list_v_) + } + } + + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["dropshow"].([]interface{}); !_ok_ { err = errors.New("dropshow error"); return } + + _v.Dropshow = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Dropshow = append(_v.Dropshow, _list_v_) + } + } + + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["bossmodel"].(float64); !_ok_ { err = errors.New("bossmodel error"); return }; _v.Bossmodel = int32(_tempNum_) } + {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["main_text"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.MainText error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.MainText, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } } + {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["strategy_text"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.StrategyText error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.StrategyText, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["boss_skill"].(float64); !_ok_ { err = errors.New("boss_skill error"); return }; _v.BossSkill = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["boss"].([]interface{}); !_ok_ { err = errors.New("boss error"); return } + + _v.Boss = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Boss = append(_v.Boss, _list_v_) + } + } + + return +} + +func DeserializeGameEnchantBossData(_buf map[string]interface{}) (*GameEnchantBossData, error) { + v := &GameEnchantBossData{} + if err := v.Deserialize(_buf); err == nil { + return v, nil + } else { + return nil, err + } +} diff --git a/sys/configure/structs/Game.EnchantShop.go b/sys/configure/structs/Game.EnchantShop.go new file mode 100644 index 000000000..1f37a0138 --- /dev/null +++ b/sys/configure/structs/Game.EnchantShop.go @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +type GameEnchantShop struct { + _dataMap map[int32]*GameEnchantShopData + _dataList []*GameEnchantShopData +} + +func NewGameEnchantShop(_buf []map[string]interface{}) (*GameEnchantShop, error) { + _dataList := make([]*GameEnchantShopData, 0, len(_buf)) + dataMap := make(map[int32]*GameEnchantShopData) + for _, _ele_ := range _buf { + if _v, err2 := DeserializeGameEnchantShopData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Buynum] = _v + } + } + return &GameEnchantShop{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *GameEnchantShop) GetDataMap() map[int32]*GameEnchantShopData { + return table._dataMap +} + +func (table *GameEnchantShop) GetDataList() []*GameEnchantShopData { + return table._dataList +} + +func (table *GameEnchantShop) Get(key int32) *GameEnchantShopData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/Game.EnchantShopData.go b/sys/configure/structs/Game.EnchantShopData.go new file mode 100644 index 000000000..30e7c72ec --- /dev/null +++ b/sys/configure/structs/Game.EnchantShopData.go @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +import "errors" + +type GameEnchantShopData struct { + Buynum int32 + Need []*Gameatn +} + +const TypeId_GameEnchantShopData = 1535577405 + +func (*GameEnchantShopData) GetTypeId() int32 { + return 1535577405 +} + +func (_v *GameEnchantShopData)Deserialize(_buf map[string]interface{}) (err error) { + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["buynum"].(float64); !_ok_ { err = errors.New("buynum error"); return }; _v.Buynum = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["need"].([]interface{}); !_ok_ { err = errors.New("need error"); return } + + _v.Need = make([]*Gameatn, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ *Gameatn + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } } + _v.Need = append(_v.Need, _list_v_) + } + } + + return +} + +func DeserializeGameEnchantShopData(_buf map[string]interface{}) (*GameEnchantShopData, error) { + v := &GameEnchantShopData{} + if err := v.Deserialize(_buf); err == nil { + return v, nil + } else { + return nil, err + } +}