From e1e364f9c234b6ef10fb07b3efc296ded5540fa0 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 29 May 2023 15:23:48 +0800 Subject: [PATCH 1/2] bingo worldtask --- cmd/v2/ui/views/bingoview.go | 6 ++- comm/imodule.go | 2 + modules/gm/module.go | 23 +++++++--- modules/worldtask/module.go | 81 +++++++++++++++++++++++++++++++++++- 4 files changed, 103 insertions(+), 9 deletions(-) diff --git a/cmd/v2/ui/views/bingoview.go b/cmd/v2/ui/views/bingoview.go index 5f0587cb6..e7e8eaa45 100644 --- a/cmd/v2/ui/views/bingoview.go +++ b/cmd/v2/ui/views/bingoview.go @@ -64,9 +64,11 @@ func (this *BingoView) CreateView(t *model.TestCase) fyne.CanvasObject { var bingo string if ttxt == "" && nEntry.Text == "" { bingo = fmt.Sprintf("bingo:%s", aSel.Selected) - } else if ttxt == "" { + } else if ttxt != "" && nEntry.Text == "" { + bingo = fmt.Sprintf("bingo:%s,%s", aSel.Selected, ttxt) + } else if ttxt == "" && nEntry.Text != "" { bingo = fmt.Sprintf("bingo:%s,%s", aSel.Selected, nEntry.Text) - } else { + } else if ttxt != "" && nEntry.Text != "" { bingo = fmt.Sprintf("bingo:%s,%s,%s", aSel.Selected, ttxt, nEntry.Text) } logrus.Info(bingo) diff --git a/comm/imodule.go b/comm/imodule.go index 87c545cdf..93a9a7406 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -396,6 +396,8 @@ type ( TaskCondFinishNotify(session IUserSession, condIds []int32) error // bingo任务 BingoJumpTask(session IUserSession, groupId, rtaskId int32) error + // 通过任务ID bingo + JumpTaskByTaskId(session IUserSession, rtaskId int32) error // 查询我的世界任务 GetMyWorldtask(uid string) *pb.DBWorldtask // 获取分组任务 diff --git a/modules/gm/module.go b/modules/gm/module.go index 6afd6c39f..46a51d638 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -33,33 +33,33 @@ type GM struct { configure *configureComp } -//模块名 +// 模块名 func (this *GM) GetType() core.M_Modules { return comm.ModuleGM } -//模块初始化接口 注册用户创建角色事件 +// 模块初始化接口 注册用户创建角色事件 func (this *GM) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) return } -//模块初始化接口 注册用户创建角色事件 +// 模块初始化接口 注册用户创建角色事件 func (this *GM) Start() (err error) { err = this.ModuleBase.Start() this.service.RegisterFunctionName(string(comm.Rpc_ModuleGMCreateCmd), this.Rpc_ModuleGMCreateCmd) return } -//装备组件 +// 装备组件 func (this *GM) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } -//bingo:Iamyoudad +// bingo:Iamyoudad func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorCode) { cmd = strings.Replace(cmd, " ", "", -1) // 去空格 @@ -162,6 +162,19 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC ) } } + } else if len(datas) == 2 && (datas[0] == "worldtask") { + module, err := this.service.GetModule(comm.ModuleWorldtask) + if err != nil { + return + } + if wt, ok := module.(comm.IWorldtask); ok { + if err = wt.JumpTaskByTaskId(session, utils.ToInt32(datas[1])); err != nil { + this.Error("bingo 世界任务", + log.Field{Key: "params", Value: datas}, + log.Field{Key: "err", Value: err.Error()}, + ) + } + } } else if len(datas) == 1 && (datas[0] == "manhero") { // 获取满星、等级、觉醒、共鸣技能 module1, err := this.service.GetModule(comm.ModuleHero) if err != nil { diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index f548731ef..0eb5cec88 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -190,7 +190,7 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId //遍历 if taskConf.Ontxe != 0 && taskConf.IdAfter != 0 { for _, v := range this.worldtaskConf.GetDataList() { - if v.Group == groupId && v.Key <= taskId && v.Des == 2 { //只做主线的des=2 + if v.Group == groupId && v.Key <= taskId && v.Des == 2 { mytask.TaskList = append(mytask.TaskList, v.Key) } } @@ -202,7 +202,7 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId "taskList": mytask.TaskList, } - //当前任务 + //下个任务 nextTaskIds := this.modelWorldtask.findNextTasks(taskId) if mytask.CurrentTask == nil { @@ -226,6 +226,73 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId return session.SendMsg(string(this.GetType()), "finishids", rsp) } +// 通过任务ID bingo +func (this *Worldtask) JumpTaskByTaskId(session comm.IUserSession, taskId int32) error { + uid := session.GetUserId() + //查询当前世界任务数据 + mytask, err := this.modelWorldtask.getWorldtask(uid) + if err != nil { + return err + } + + // 如果是空 或Uid是空 初始一条基础数据 + if mytask == nil { + mytask = &pb.DBWorldtask{} + mytask.Uid = uid + if err := this.modelWorldtask.Add(uid, mytask); err != nil { + this.Error("添加世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err}) + return err + } + } else if mytask.Uid == "" { + update := map[string]interface{}{ + "uid": uid, + } + if err := this.modelWorldtask.Change(uid, update); err != nil { + this.Error("更新世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err}) + return err + } + } + + //重置taskList + mytask.TaskList = []int32{} + // 判断任务ID是否已完成 + // if _, ok := utils.Findx(mytask.TaskList, taskId); ok { + // this.Error("GM 世界任务已完成", log.Field{Key: "taskId", Value: taskId}) + // return comm.NewCustomError(pb.ErrorCode_WorldtaskFinihed) + // } + + // 获取当前bingo的任务配置 + taskConf := this.worldtaskConf.GetDataMap()[taskId] + if taskConf == nil { + return comm.NewCustomError(pb.ErrorCode_ConfigNoFound) + } + + // 返回所有前置任务 + mytask.TaskList = this.recursionTasks(taskId, mytask.TaskList) + + update := map[string]interface{}{ + "taskList": mytask.TaskList, + } + + if mytask.CurrentTask == nil { + mytask.CurrentTask = make(map[int32]*pb.Worldtask) + } + + mytask.CurrentTask[taskConf.Group] = &pb.Worldtask{ + TaskId: taskId, + TaskType: taskConf.Des, + } + update["currentTask"] = mytask.CurrentTask + + if err := this.modelWorldtask.Change(uid, update); err != nil { + return err + } + + rsp := &pb.WorldtaskFinishIdsPush{} + + return session.SendMsg(string(this.GetType()), "finishids", rsp) +} + // 返回任务ID func (this *Worldtask) GetWorldTaskBy(session comm.IUserSession, groupId int32) (taskId int32) { uid := session.GetUserId() @@ -331,3 +398,13 @@ func (this *Worldtask) UpdateTaskStatus(uid string, taskId int32) { } } + +func (this *Worldtask) recursionTasks(taskId int32, taskList []int32) []int32 { + if taskConf, ok := this.worldtaskConf.GetDataMap()[taskId]; ok { + if taskConf.Ontxe > 0 { + taskList = append(taskList, taskConf.Ontxe) + this.recursionTasks(taskConf.Ontxe, taskList) + } + } + return taskList +} From afcbd2c7666f898c6dff7c83e8d5e6efd38e77d5 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 29 May 2023 16:14:21 +0800 Subject: [PATCH 2/2] update worldtask gm --- bin/json/game_rdtaskcondi.json | 10 +++++----- modules/rtask/module.go | 5 ++++- modules/rtask/verifyHandle.go | 28 ++++++++++------------------ modules/worldtask/module.go | 15 +++++++++------ 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/bin/json/game_rdtaskcondi.json b/bin/json/game_rdtaskcondi.json index aaf8210e3..efef404e3 100644 --- a/bin/json/game_rdtaskcondi.json +++ b/bin/json/game_rdtaskcondi.json @@ -6261,7 +6261,7 @@ "type_sp": 1, "tasktxt": { "key": "taskcond_rdtask_condi_tasktxt_369", - "text": "强化武器+3(引导自动强化)" + "text": "强化任意装备3次" }, "type": 92, "valid": 0, @@ -6295,7 +6295,7 @@ "type_sp": 1, "tasktxt": { "key": "taskcond_rdtask_condi_tasktxt_371", - "text": "通关1次维京远征boss2难度1" + "text": "通关维京远征boss2难度1" }, "type": 73, "valid": 0, @@ -8119,9 +8119,9 @@ "type": 93, "valid": 0, "NPC": 10291, - "data1": 6, - "data2": 1, - "data3": 0, + "data1": 1, + "data2": 6, + "data3": 1, "data4": 0, "data5": 0 }, diff --git a/modules/rtask/module.go b/modules/rtask/module.go index ffcc9cede..321d3beac 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -283,7 +283,10 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, record *pb.DB if len(params) == 1 { ok = true } else { - ok, d, _ = handle.verify(uid, conf, params...) + ok, d, err = handle.verify(uid, conf, params...) + if err != nil { + // this.Error("参数校验失败", log.Field{Key: "err", Value: err.Error()}) + } } if !ok { diff --git a/modules/rtask/verifyHandle.go b/modules/rtask/verifyHandle.go index b41969ad3..12c52ffba 100644 --- a/modules/rtask/verifyHandle.go +++ b/modules/rtask/verifyHandle.go @@ -2,20 +2,20 @@ package rtask import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" - "github.com/pkg/errors" "github.com/spf13/cast" ) // n params (1-GreatEqual 2-equal 3-equal 4-equal 5-equal) func (this *ModelRtaskRecord) verifyMultiEqual(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) { if len(params) == 0 { - err = errors.New("玩家参数数据缺失") + err = fmt.Errorf("玩家参数数据缺失,用户参数:%v", params) return } var paramLen int @@ -89,17 +89,18 @@ func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, cfg *cfg.GameRdt // firstParam (first-greatEqual) func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) { - if len(params) == 1 { - ok = true - // ok, err = soGreatEqual(params[0], cfg.Data1) + if len(params) != 1 { + err = fmt.Errorf("玩家参数数据缺失,用户参数:%v", params) + return } + ok = true return } // three params (first-greatEqual second-equal third-lessEqual) func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) { if len(params) != 3 { - err = errors.New("玩家参数数据缺失") + err = fmt.Errorf("玩家参数数据缺失,用户参数:%v", params) return } var paramLen int @@ -128,7 +129,7 @@ func (this *ModelRtaskRecord) verifyThirdLessEqualParam(uid string, cfg *cfg.Gam // three params (first-greatEqual second-equal third-greatEqual) func (this *ModelRtaskRecord) verifyThirdGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) { if len(params) != 3 { - err = errors.New("玩家参数数据缺失") + err = fmt.Errorf("玩家参数数据缺失,用户参数:%v", params) return } var paramLen int @@ -157,20 +158,11 @@ func (this *ModelRtaskRecord) verifyThirdGreatEqualParam(uid string, cfg *cfg.Ga // two params (first-Equal second-Equal) func (this *ModelRtaskRecord) veriftyEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) { if len(params) != 2 { - err = errors.New("玩家参数数据缺失") + err = fmt.Errorf("玩家参数数据缺失,用户参数:%v", params) return } // var paramLen int if _, err = lenParam(cfg, params...); err == nil { - //参数比较,默认第一个参数soGreateEqual,其它soEqual - // switch paramLen { - // case 1: - // ok, err = soGreat(params[0], cfg.Data1) - // return - // case 2: - // if ok, err = soGreat(params[0], cfg.Data1); !ok { - // return - // } if ok, err = soEqual(params[1], cfg.Data2); !ok { return } @@ -182,7 +174,7 @@ func (this *ModelRtaskRecord) veriftyEqualParam(uid string, cfg *cfg.GameRdtaskC // two params (first-Equal second-GreatEqual) func (this *ModelRtaskRecord) veriftyGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData, params ...int32) (ok bool, count int32, err error) { if len(params) != 2 { - err = errors.New("玩家参数数据缺失") + err = fmt.Errorf("玩家参数数据缺失,用户参数:%v", params) return } // var paramLen int diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index 0eb5cec88..b0ee9ebb9 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -268,7 +268,7 @@ func (this *Worldtask) JumpTaskByTaskId(session comm.IUserSession, taskId int32) } // 返回所有前置任务 - mytask.TaskList = this.recursionTasks(taskId, mytask.TaskList) + mytask.TaskList = this.recursionTasks(taskId) update := map[string]interface{}{ "taskList": mytask.TaskList, @@ -399,12 +399,15 @@ func (this *Worldtask) UpdateTaskStatus(uid string, taskId int32) { } } -func (this *Worldtask) recursionTasks(taskId int32, taskList []int32) []int32 { +func (this *Worldtask) recursionTasks(taskId int32) (taskIds []int32) { if taskConf, ok := this.worldtaskConf.GetDataMap()[taskId]; ok { - if taskConf.Ontxe > 0 { - taskList = append(taskList, taskConf.Ontxe) - this.recursionTasks(taskConf.Ontxe, taskList) + preId := taskConf.Ontxe + for preId > 0 { + if tc, ok := this.worldtaskConf.GetDataMap()[preId]; ok { + taskIds = append(taskIds, preId) + preId = tc.Ontxe + } } } - return taskList + return taskIds }