This commit is contained in:
meixiongfeng 2022-11-23 16:58:21 +08:00
commit 7465615e86
17 changed files with 134 additions and 22 deletions

View File

@ -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,

View File

@ -18,7 +18,7 @@
2,
100001
],
"completetask": 0,
"completetask": 183,
"auto_accept": 0,
"overtips": 1,
"reword": [

View File

@ -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)

View File

@ -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)
// 初始化条件数据

View File

@ -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)
}
}

View File

@ -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})

View File

@ -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)

View File

@ -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)

View File

@ -51,6 +51,7 @@ func (this *ModelRtaskRecord) getRecord(uid string) *pb.DBRtaskRecord {
// 初始化任务条件数据
// 玩家登录时调用
// Deprecated
func (this *ModelRtaskRecord) initCondiData(uid string) error {
dr := this.getRecord(uid)
// 判断是否有记录

View File

@ -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)
}

View File

@ -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})

View File

@ -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,

View File

@ -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
}
// 设置公会

View File

@ -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)
}
}
}

View File

@ -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)

View File

@ -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 {

View File

@ -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
}
}
@ -90,7 +90,7 @@ func (this *ModelWorldtask) finishTask(groupId, taskId int32, task *pb.DBWorldta
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()})
}
}
}