diff --git a/bin/json/game_rdtaskcondi.json b/bin/json/game_rdtaskcondi.json index 91f898737..4413da8df 100644 --- a/bin/json/game_rdtaskcondi.json +++ b/bin/json/game_rdtaskcondi.json @@ -955,6 +955,72 @@ "data4": 0, "data5": 0 }, + { + "id": 183, + "datatype": 2, + "type": 140, + "inited": [], + "data1": 1, + "data2": 10001, + "data3": 0, + "data4": 0, + "data5": 0 + }, + { + "id": 184, + "datatype": 2, + "type": 140, + "inited": [], + "data1": 1, + "data2": 10002, + "data3": 0, + "data4": 0, + "data5": 0 + }, + { + "id": 185, + "datatype": 2, + "type": 140, + "inited": [], + "data1": 1, + "data2": 10003, + "data3": 0, + "data4": 0, + "data5": 0 + }, + { + "id": 186, + "datatype": 2, + "type": 140, + "inited": [], + "data1": 1, + "data2": 20001, + "data3": 0, + "data4": 0, + "data5": 0 + }, + { + "id": 187, + "datatype": 2, + "type": 109, + "inited": [], + "data1": 1, + "data2": 0, + "data3": 0, + "data4": 0, + "data5": 0 + }, + { + "id": 188, + "datatype": 2, + "type": 104, + "inited": [], + "data1": 100, + "data2": 0, + "data3": 0, + "data4": 0, + "data5": 0 + }, { "id": 10001, "datatype": 2, diff --git a/bin/json/game_worldtask.json b/bin/json/game_worldtask.json index 855229a67..a547e1f74 100644 --- a/bin/json/game_worldtask.json +++ b/bin/json/game_worldtask.json @@ -18,7 +18,7 @@ 2, 100001 ], - "completetask": 0, + "completetask": 183, "auto_accept": 0, "overtips": 1, "reword": [ diff --git a/comm/const.go b/comm/const.go index 8f00ce588..5ef705984 100644 --- a/comm/const.go +++ b/comm/const.go @@ -461,7 +461,8 @@ const ( Rtype101 TaskType = 101 //获得X星职业武器N件(历史)(从创号开始记录,每获得1件X星职业武器则进度+1) Rtype102 TaskType = 102 //阵营饰品强化成功N次(历史)(从创号开始记录,强化成功进度+1) Rtype103 TaskType = 103 //获得X星阵营饰品N件(历史)(从创号开始记录,每获得1件X星阵营饰品则进度+1) - Rtype104 TaskType = 104 //消费N个钻石(历史)(从创号开始记录,每次消耗钻石增加消耗额的进度) + //消费N个钻石(历史)(从创号开始记录,每次消耗钻石增加消耗额的进度) + Rtype104 TaskType = 104 Rtype105 TaskType = 105 //商店刷新N次(从接到任务开始,每次刷新商店进度+1) Rtype106 TaskType = 106 //跨服聊天发言N次(从接到任务开始,每次跨服发言成功进度+1) Rtype107 TaskType = 107 //赠送N个人好感度(从接到任务开始,每赠送1个好友好感度则进度+1) diff --git a/comm/imodule.go b/comm/imodule.go index a3754d083..4ba88f88b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -168,6 +168,8 @@ type ( CheckCondi(uid string, condiId int32) (code pb.ErrorCode) // 远程任务条件校验 RemoteCheckCondi(uid string, condiId int32, rsp *pb.DBRtaskRecord) error + // 删除任务条件数据 + RemoveCondi(uid string ,condiId int32) error //任务触发 SendToRtask(session IUserSession, rtaskType TaskType, params ...int32) (code pb.ErrorCode) // 初始化条件数据 diff --git a/modules/combat/api_challengereceive.go b/modules/combat/api_challengereceive.go index a566aecef..747ab4962 100644 --- a/modules/combat/api_challengereceive.go +++ b/modules/combat/api_challengereceive.go @@ -88,7 +88,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC return } this.module.DispenseRes(session, level.Award, true) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype140, level.Id) + this.module.ModuleRtask.SendToRtask(session, comm.Rtype140, 1, level.Id) } } diff --git a/modules/combat/api_drop.go b/modules/combat/api_drop.go index 32717e106..ed9ec4f3e 100644 --- a/modules/combat/api_drop.go +++ b/modules/combat/api_drop.go @@ -94,7 +94,7 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (cod return } this.module.DispenseRes(session, level.Award, true) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype140, level.Id) + this.module.ModuleRtask.SendToRtask(session, comm.Rtype140, 1, level.Id) } session.SendMsg(string(this.module.GetType()), "drop", &pb.CombatDropResp{Code: code, Atns: atns, Pass: pass}) diff --git a/modules/modulebase.go b/modules/modulebase.go index 97136de46..e3b4bb115 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -302,6 +302,9 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn return } this.Debugf("消耗玩家资源: %v", attrs) + if count,ok:= attrs[comm.ResDiamond];ok{ + this.ModuleRtask.SendToRtask(session, comm.Rtype104, count) + } } if len(items) > 0 { code = this.ModuleItems.AddItems(session, items, bPush) diff --git a/modules/rtask/condiFindHandle.go b/modules/rtask/condiFindHandle.go index 8e2c784e8..3930ee896 100644 --- a/modules/rtask/condiFindHandle.go +++ b/modules/rtask/condiFindHandle.go @@ -25,6 +25,8 @@ func (this *ModelRtaskRecord) greatEqualFirstParam(cfg *cfg.GameRdtaskCondiData, return } +// 传递参数小于等于配置参数 +// 适合只比较首个参数(一个参数) func (this *ModelRtaskRecord) lessEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) { if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok { err = errors.WithMessagef(err1, "id: %v type:%v vals:%v", cfg.Id, cfg.Type, vals) diff --git a/modules/rtask/model_record.go b/modules/rtask/model_record.go index b7787a3fd..46a5fe567 100644 --- a/modules/rtask/model_record.go +++ b/modules/rtask/model_record.go @@ -51,6 +51,7 @@ func (this *ModelRtaskRecord) getRecord(uid string) *pb.DBRtaskRecord { // 初始化任务条件数据 // 玩家登录时调用 +// Deprecated func (this *ModelRtaskRecord) initCondiData(uid string) error { dr := this.getRecord(uid) // 判断是否有记录 diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 05d9ec5e0..d57c569af 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -162,12 +162,19 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, update: this.modelRtaskRecord.overrideUpdate, }) + case comm.Rtype18: + this.registerVerifyHandle(v.Id, &rtaskCondi{ + cfg: typeCfg, + find: this.modelRtaskRecord.greatEqualFirstParam, + verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, + update: this.modelRtaskRecord.addUpdate, + }) case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15, - comm.Rtype18, comm.Rtype19, comm.Rtype21, comm.Rtype24, + comm.Rtype19, comm.Rtype21, comm.Rtype24, comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38, comm.Rtype39, comm.Rtype50, comm.Rtype51, comm.Rtype53, comm.Rtype54, comm.Rtype57, comm.Rtype58, comm.Rtype60, - comm.Rtype62, comm.Rtype64, comm.Rtype69, comm.Rtype72: + comm.Rtype62, comm.Rtype64, comm.Rtype69, comm.Rtype72,comm.Rtype104: this.registerVerifyHandle(v.Id, &rtaskCondi{ cfg: typeCfg, find: this.modelRtaskRecord.lessEqualFirstParam, @@ -181,7 +188,7 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { verify: this.modelRtask.verifyRtype20, update: this.modelRtaskRecord.overrideUpdate, }) - case comm.Rtype22: + case comm.Rtype22,comm.Rtype109: this.registerVerifyHandle(v.Id, &rtaskCondi{ cfg: typeCfg, find: this.modelRtaskRecord.equalFirstParam, @@ -317,7 +324,16 @@ func (this *ModuleRtask) CheckCondi(uid string, condiId int32) (code pb.ErrorCod return } +func (this *ModuleRtask) RemoveCondi(uid string, condiId int32) (err error) { + dr := this.modelRtaskRecord.getRecord(uid) + if dr != nil && dr.Vals != nil { + delete(dr.Vals, condiId) + } + return +} + // 初始化任务条件数据 +// Deprecated func (this *ModuleRtask) InitCondiData(uid string) error { return this.modelRtaskRecord.initCondiData(uid) } diff --git a/modules/sociaty/api_cross_agree.go b/modules/sociaty/api_cross_agree.go index 43986c7ba..b6cbca27a 100644 --- a/modules/sociaty/api_cross_agree.go +++ b/modules/sociaty/api_cross_agree.go @@ -51,6 +51,8 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) ( return } + // 触发任务条件 + this.module.ModuleRtask.SendToRtask(session, comm.Rtype109, 1) // 发邮件 if err := this.module.modelSociaty.sendMail("GuildApproved", []string{sociaty.Name}, []string{req.Uid}); err != nil { this.module.Error("发送邮件 模板ID:GuildApproved", log.Fields{"uid": uid, "申请人": req.Uid, "sociatyId": sociaty.Id}) diff --git a/modules/sociaty/api_cross_apply.go b/modules/sociaty/api_cross_apply.go index 993016c16..a992338ac 100644 --- a/modules/sociaty/api_cross_apply.go +++ b/modules/sociaty/api_cross_apply.go @@ -83,7 +83,8 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) ( } // 申请 - if err := this.module.modelSociaty.apply(uid, sociaty); err != nil { + isCheck, err := this.module.modelSociaty.apply(uid, sociaty) + if err != nil { var customError = new(comm.CustomError) if errors.As(err, &customError) { code = customError.Code @@ -93,6 +94,12 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) ( this.module.Error("公会申请", log.Fields{"uid": uid, "sociatyId": req.SociatyId, "err": err.Error()}) return } + + // 无需审核 + if !isCheck { + // 触发任务条件 + this.module.ModuleRtask.SendToRtask(session, comm.Rtype109, 1) + } rsp := &pb.SociatyApplyResp{ Uid: uid, ScoiatyId: req.SociatyId, diff --git a/modules/sociaty/model_sociaty.go b/modules/sociaty/model_sociaty.go index 1b9de59fb..69306c56e 100644 --- a/modules/sociaty/model_sociaty.go +++ b/modules/sociaty/model_sociaty.go @@ -232,9 +232,10 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) { } // 申请公会 -func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error { +func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool,err error) { // 判断公会审批设置 if sociaty.IsApplyCheck { //需要审核 + isCheck = true sociaty.ApplyRecord = append(sociaty.ApplyRecord, &pb.ApplyRecord{ Uid: uid, Ctime: configure.Now().Unix(), @@ -242,15 +243,15 @@ func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error { update := map[string]interface{}{ "applyRecord": sociaty.ApplyRecord, } - return this.updateSociaty(sociaty.Id, update) + err = this.updateSociaty(sociaty.Id, update) } else { //无需审核直接入会 if err := this.addMember(uid, sociaty); err != nil { - return err + return isCheck,err } //初始玩家公会任务 this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id) } - return nil + return } // 设置公会 diff --git a/modules/task/model_task.go b/modules/task/model_task.go index 647bac1fa..99fcad4ef 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -233,6 +233,11 @@ func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) { this.moduleTask.Errorf("uid: %v err:%v", uid, err) return } + //删除任务条件数据 + dr := this.moduleTask.ModuleRtask.GetCondiData(uid) + if dr != nil && dr.Vals!=nil{ + delete(dr.Vals, v.TypeId) + } } } diff --git a/modules/user/api_login.go b/modules/user/api_login.go index 99c8aad1e..b67b79957 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -143,7 +143,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod } // 初始化随机任务数据 - this.module.ModuleRtask.InitCondiData(user.Uid) + // this.module.ModuleRtask.InitCondiData(user.Uid) // 日常登录任务 this.module.ModuleRtask.SendToRtask(session, comm.Rtype7, 1) diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index e7fc92019..8a3cbdd60 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -80,14 +80,15 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe var nextTaskId int32 finishCall := func() { - defer func() { - this.module.Debug("世界任务完成", log.Fields{"uid": uid, "params": req}) - }() nextTaskId = curTaskConf.IdAfter + defer func() { + this.module.Debug("世界任务完成", log.Fields{"uid": uid, "params": req, "nextTaskId": nextTaskId}) + }() + // 完成任务 if err := this.module.modelWorldtask.finishTask(req.GroupId, req.TaskId, userTask); err != nil { code = pb.ErrorCode_WorldtaskFinish - this.module.Error("finishTask", log.Fields{"uid": uid, "groupId": req.GroupId, "taskId": req.TaskId, "err": err.Error()}) + this.module.Error("完成任务失败", log.Fields{"uid": uid, "groupId": req.GroupId, "taskId": req.TaskId, "err": err.Error()}) return } // 发奖 @@ -99,6 +100,10 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe if curTaskConf.Completetask != 0 { if c := this.module.ModuleRtask.CheckCondi(uid, curTaskConf.Completetask); c == pb.ErrorCode_Success { finishCall() + } else { + this.module.Debug("任务完成条件未通过", log.Fields{"uid": uid, "condiId": curTaskConf.Completetask}) + code = pb.ErrorCode_WorldtaskNoComplete + return } } else { finishCall() @@ -113,8 +118,9 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe code = pb.ErrorCode_SystemError } - // 任务完成推送 + // 世界任务类型 if curTaskConf.Des == 2 { + // 任务完成推送 if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{ NextTaskId: nextTaskId, }); err != nil { diff --git a/modules/worldtask/model_worldtask.go b/modules/worldtask/model_worldtask.go index 8ea374fe7..4570e231a 100644 --- a/modules/worldtask/model_worldtask.go +++ b/modules/worldtask/model_worldtask.go @@ -52,7 +52,7 @@ func (this *ModelWorldtask) IsPreFinished(userTask *pb.DBWorldtask, curTaskConf } for _, t := range userTask.TaskList { - if lastTaskId == t.TaskId{ + if lastTaskId == t.TaskId { preTaskFinished = true } } @@ -87,10 +87,10 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta update["uid"] = task.Uid wt := &pb.Worldtask{ - TaskId: taskId, + TaskId: taskId, TaskType: taskConf.Des, } - task.TaskList = append(task.TaskList,wt) + task.TaskList = append(task.TaskList, wt) task.LastTaskIds[groupId] = wt update["taskList"] = task.TaskList @@ -102,7 +102,7 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta if module, err := this.service.GetModule(comm.ModuleLinestory); err == nil { if iLinestory, ok := module.(comm.ILinestory); ok { if err := iLinestory.TaskFinishNotify(task.Uid, taskId, groupId); err != nil { - log.Error("世界任务完成通知支线剧情任务", log.Fields{"uid": task.Uid, "groupId": groupId, "taskId": taskId, "err": err.Error()}) + log.Debug("世界任务完成通知支线剧情任务", log.Fields{"uid": task.Uid, "groupId": groupId, "taskId": taskId, "err": err.Error()}) } } }