From 1cec020d6c6e1b86a9a6fe9cf69caf9b084e9764 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 11 Nov 2022 10:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=96=E7=95=8C=E4=BB=BB=E5=8A=A1bingo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/views/bingoview.go | 2 +- cmd/v2/ui/views/worldtask_mine.go | 2 +- modules/gm/module.go | 12 ++- modules/worldtask/module.go | 59 +++++++++++++- pb/worldtask_msg.pb.go | 125 +++++++----------------------- 5 files changed, 96 insertions(+), 104 deletions(-) diff --git a/cmd/v2/ui/views/bingoview.go b/cmd/v2/ui/views/bingoview.go index 079ed1aa2..0d71d1fd7 100644 --- a/cmd/v2/ui/views/bingoview.go +++ b/cmd/v2/ui/views/bingoview.go @@ -46,7 +46,7 @@ func (this *BingoView) CreateView(t *model.TestCase) fyne.CanvasObject { aSel = &widget.Select{} gridContainer = container.NewGridWithColumns(3, aSel, tEntry, nEntry) - aSel.Options = []string{"选择", "attr", "item", "hero", "equi", "mapid", "pataid", "rtask"} + aSel.Options = []string{"选择", "attr", "item", "hero", "equi", "mapid", "pataid", "worldtask"} aSel.SetSelected("选择") aSel.OnChanged = func(s string) { if s == "attr" { diff --git a/cmd/v2/ui/views/worldtask_mine.go b/cmd/v2/ui/views/worldtask_mine.go index 105c5fde9..81963bce8 100644 --- a/cmd/v2/ui/views/worldtask_mine.go +++ b/cmd/v2/ui/views/worldtask_mine.go @@ -72,7 +72,7 @@ func (this *WorldtaskMineView) CreateView(t *model.TestCase) fyne.CanvasObject { logrus.Error(err) } dconf.Hide() - // this.mineReq() + this.mineReq() } form.SubmitText = "确定" dconf.Resize(fyne.NewSize(400, 200)) diff --git a/modules/gm/module.go b/modules/gm/module.go index 8f35875ee..0dbe02a6f 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -125,11 +125,17 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC } } this.Debugf("使用bingo命令", log.Field{"uid", session.GetUserId()}, datas[0], res) - } else if len(datas) == 3 && (datas[0] == "rtask") { - err := this.ModuleRtask.BingoRtask(session, utils.ToInt32(datas[1]), utils.ToInt32(datas[2])) + } else if len(datas) == 3 && (datas[0] == "worldtask") { + module, err := this.service.GetModule(comm.ModuleWorldtask) if err != nil { - this.Errorf("bingo rdTask Failed ,Parameter :%s,%s %v", datas[1], datas[2], err) + return } + if wt, ok := module.(comm.IWorldtask); ok { + if err = wt.BingoJumpTask(session, utils.ToInt32(datas[1]), utils.ToInt32(datas[2])); err != nil { + this.Errorf("bingo worldTask Failed ,Parameter :%s,%s %v", datas[1], datas[2], err) + } + } + } } diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index 240f56b24..64f9b7541 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -1,6 +1,7 @@ package worldtask import ( + "errors" "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/base" @@ -120,7 +121,61 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e } // bingo世界任务跳跃 支持回退 -func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, rtaskId int32) error { - // d, err := this.modelWorldtask.getWorldtask(session.GetUserId()) +func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId int32) error { + uid := session.GetUserId() + mytask, err := this.modelWorldtask.getWorldtask(uid) + if err != nil { + return err + } + // 更新数据 + update := map[string]interface{}{} + + conf, err := this.configure.getWorldtaskCfg() + if err != nil || conf == nil { + return errors.New("config is nil") + } + + taskConf, err := this.configure.getWorldtaskById(taskId) + if err != nil || taskConf == nil { + return fmt.Errorf("taskId: %v config is nil", taskId) + } + + if mytask.LastTaskIds == nil { + mytask.LastTaskIds = make(map[int32]int32) + } + //重置taskList + mytask.TaskList = []*pb.Worldtask{} + + //遍历 + if taskConf.Ontxe != 0 && taskConf.IdAfter != 0 { + for _, v := range conf.GetDataList() { + if v.Group == groupId && v.Key <= taskId { + mytask.LastTaskIds[groupId] = v.Key + mytask.TaskList = append(mytask.TaskList, &pb.Worldtask{ + TaskId: v.Key, + Status: 1, + }) + } + break + } + } else { + mytask.LastTaskIds[groupId] = taskId + mytask.TaskList = append(mytask.TaskList, &pb.Worldtask{ + TaskId: taskId, + Status: 1, + }) + } + update = map[string]interface{}{ + "lastTaskIds": mytask.LastTaskIds, + "taskList": mytask.TaskList, + } + + this.modelWorldtask.Change(uid, update) + + rsp := &pb.WorldtaskFinishIdsPush{ + TaskList: mytask.TaskList, + } + + session.SendMsg(string(this.GetType()), "finishIds", rsp) return nil } diff --git a/pb/worldtask_msg.pb.go b/pb/worldtask_msg.pb.go index ce40485c2..a60416c96 100644 --- a/pb/worldtask_msg.pb.go +++ b/pb/worldtask_msg.pb.go @@ -488,65 +488,18 @@ func (x *WorldtaskBattleFinishResp) GetTaskId() int32 { } // 当前完成的任务列表推送 -type WorldtaskList struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - TaskId []int32 `protobuf:"varint,1,rep,packed,name=taskId,proto3" json:"taskId"` //任务ID -} - -func (x *WorldtaskList) Reset() { - *x = WorldtaskList{} - if protoimpl.UnsafeEnabled { - mi := &file_worldtask_worldtask_msg_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WorldtaskList) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WorldtaskList) ProtoMessage() {} - -func (x *WorldtaskList) ProtoReflect() protoreflect.Message { - mi := &file_worldtask_worldtask_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 WorldtaskList.ProtoReflect.Descriptor instead. -func (*WorldtaskList) Descriptor() ([]byte, []int) { - return file_worldtask_worldtask_msg_proto_rawDescGZIP(), []int{9} -} - -func (x *WorldtaskList) GetTaskId() []int32 { - if x != nil { - return x.TaskId - } - return nil -} - type WorldtaskFinishIdsPush struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Tasks map[int32]*WorldtaskList `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //完成的任务 key:groupId val:任务ID + TaskList []*Worldtask `protobuf:"bytes,1,rep,name=taskList,proto3" json:"taskList"` //完成的任务 key:groupId val:任务ID } func (x *WorldtaskFinishIdsPush) Reset() { *x = WorldtaskFinishIdsPush{} if protoimpl.UnsafeEnabled { - mi := &file_worldtask_worldtask_msg_proto_msgTypes[10] + mi := &file_worldtask_worldtask_msg_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -559,7 +512,7 @@ func (x *WorldtaskFinishIdsPush) String() string { func (*WorldtaskFinishIdsPush) ProtoMessage() {} func (x *WorldtaskFinishIdsPush) ProtoReflect() protoreflect.Message { - mi := &file_worldtask_worldtask_msg_proto_msgTypes[10] + mi := &file_worldtask_worldtask_msg_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -572,12 +525,12 @@ func (x *WorldtaskFinishIdsPush) ProtoReflect() protoreflect.Message { // Deprecated: Use WorldtaskFinishIdsPush.ProtoReflect.Descriptor instead. func (*WorldtaskFinishIdsPush) Descriptor() ([]byte, []int) { - return file_worldtask_worldtask_msg_proto_rawDescGZIP(), []int{10} + return file_worldtask_worldtask_msg_proto_rawDescGZIP(), []int{9} } -func (x *WorldtaskFinishIdsPush) GetTasks() map[int32]*WorldtaskList { +func (x *WorldtaskFinishIdsPush) GetTaskList() []*Worldtask { if x != nil { - return x.Tasks + return x.TaskList } return nil } @@ -630,20 +583,12 @@ var file_worldtask_worldtask_msg_proto_rawDesc = []byte{ 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 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, 0x0d, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, - 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, - 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x9c, 0x01, 0x0a, 0x16, 0x57, 0x6f, 0x72, - 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x49, 0x64, 0x73, 0x50, - 0x75, 0x73, 0x68, 0x12, 0x38, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, - 0x6e, 0x69, 0x73, 0x68, 0x49, 0x64, 0x73, 0x50, 0x75, 0x73, 0x68, 0x2e, 0x54, 0x61, 0x73, 0x6b, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x1a, 0x48, 0x0a, - 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x57, - 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x40, 0x0a, 0x16, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, + 0x73, 0x68, 0x49, 0x64, 0x73, 0x50, 0x75, 0x73, 0x68, 0x12, 0x26, 0x0a, 0x08, 0x74, 0x61, 0x73, + 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x57, 0x6f, + 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, + 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -658,7 +603,7 @@ func file_worldtask_worldtask_msg_proto_rawDescGZIP() []byte { return file_worldtask_worldtask_msg_proto_rawDescData } -var file_worldtask_worldtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_worldtask_worldtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_worldtask_worldtask_msg_proto_goTypes = []interface{}{ (*WorldtaskMineReq)(nil), // 0: WorldtaskMineReq (*WorldtaskMineResp)(nil), // 1: WorldtaskMineResp @@ -669,24 +614,22 @@ var file_worldtask_worldtask_msg_proto_goTypes = []interface{}{ (*WorldtaskBattleStartResp)(nil), // 6: WorldtaskBattleStartResp (*WorldtaskBattleFinishReq)(nil), // 7: WorldtaskBattleFinishReq (*WorldtaskBattleFinishResp)(nil), // 8: WorldtaskBattleFinishResp - (*WorldtaskList)(nil), // 9: WorldtaskList - (*WorldtaskFinishIdsPush)(nil), // 10: WorldtaskFinishIdsPush - nil, // 11: WorldtaskFinishIdsPush.TasksEntry - (*DBWorldtask)(nil), // 12: DBWorldtask - (*BattleInfo)(nil), // 13: BattleInfo - (*BattleReport)(nil), // 14: BattleReport + (*WorldtaskFinishIdsPush)(nil), // 9: WorldtaskFinishIdsPush + (*DBWorldtask)(nil), // 10: DBWorldtask + (*BattleInfo)(nil), // 11: BattleInfo + (*BattleReport)(nil), // 12: BattleReport + (*Worldtask)(nil), // 13: Worldtask } var file_worldtask_worldtask_msg_proto_depIdxs = []int32{ - 12, // 0: WorldtaskMineResp.task:type_name -> DBWorldtask - 13, // 1: WorldtaskBattleStartResp.info:type_name -> BattleInfo - 14, // 2: WorldtaskBattleFinishReq.report:type_name -> BattleReport - 11, // 3: WorldtaskFinishIdsPush.tasks:type_name -> WorldtaskFinishIdsPush.TasksEntry - 9, // 4: WorldtaskFinishIdsPush.TasksEntry.value:type_name -> WorldtaskList - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 10, // 0: WorldtaskMineResp.task:type_name -> DBWorldtask + 11, // 1: WorldtaskBattleStartResp.info:type_name -> BattleInfo + 12, // 2: WorldtaskBattleFinishReq.report:type_name -> BattleReport + 13, // 3: WorldtaskFinishIdsPush.taskList:type_name -> Worldtask + 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_worldtask_worldtask_msg_proto_init() } @@ -806,18 +749,6 @@ func file_worldtask_worldtask_msg_proto_init() { } } file_worldtask_worldtask_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorldtaskList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_worldtask_worldtask_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*WorldtaskFinishIdsPush); i { case 0: return &v.state @@ -836,7 +767,7 @@ func file_worldtask_worldtask_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_worldtask_worldtask_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 12, + NumMessages: 10, NumExtensions: 0, NumServices: 0, },