This commit is contained in:
liwei1dao 2023-05-29 21:21:22 +08:00
commit c753d2fc90
4 changed files with 62 additions and 66 deletions

View File

@ -3,52 +3,46 @@ package rtask
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"strings"
"github.com/spf13/cast"
) )
func (this *apiComp) RtestCheck(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode) { func (this *apiComp) RtestCheck(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode) {
if len(req.Params) < 1 {
code = pb.ErrorCode_ReqParameterError
}
return return
} }
func (this *apiComp) Rtest(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode, data *pb.ErrorData) { func (this *apiComp) Rtest(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode, data *pb.ErrorData) {
rsp := &pb.RtaskTestResp{Flag: true, RtaskType: req.RtaskType} if code = this.RtestCheck(session, req); code != pb.ErrorCode_Success {
if req.CondiId != 0 {
if code = this.module.CheckCondi(session.GetUserId(), req.CondiId); code != pb.ErrorCode_Success {
rsp.Flag = false
}
} else if req.GroupId != 0 {
// 获取当前玩家
rtask := this.module.modelRtask.GetRtask(session.GetUserId())
if rtask == nil {
code = pb.ErrorCode_RtaskNoRtask
return return
} }
rsp := &pb.RtaskTestResp{Flag: true, RtaskType: req.RtaskType}
rtaskIds := make([]int32, 0) // 校验
ids := strings.Split(req.RtaskIds, ",") if req.CondiId != 0 {
for _, id := range ids { condIds, err := this.module.ModuleBuried.CheckCondition(session.GetUserId(), req.CondiId)
rtaskIds = append(rtaskIds, cast.ToInt32(id)) if err == nil && len(condIds) > 0 {
rsp.Flag = false
} }
// 触发
if v, ok := rtask.FrtaskIds[req.GroupId]; ok { } else if req.RtaskType != 0 && len(req.Params) > 0 {
v.RtaskIds = rtaskIds conds := []int32{}
} else { switch len(req.Params) {
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds) case 2:
rtask.FrtaskIds[req.GroupId] = &pb.FrtaskIds{RtaskIds: rtaskIds} conds[0] = req.Params[1]
case 3:
conds[0] = req.Params[1]
conds[1] = req.Params[2]
case 4:
conds[0] = req.Params[1]
conds[1] = req.Params[2]
conds[2] = req.Params[3]
case 5:
conds[0] = req.Params[1]
conds[1] = req.Params[2]
conds[2] = req.Params[3]
conds[3] = req.Params[4]
} }
this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.TaskType(req.RtaskType), req.Params[0], conds...))
update := map[string]interface{}{
"frtaskIds": rtask.FrtaskIds,
}
this.module.modelRtask.Change(rtask.Uid, update)
} else {
// this.module.ModuleBuried.TriggerBuried(session.GetUserId(), &comm.BuriedParam{
// TT: comm.TaskType(req.RtaskType),
// Params: req.Params,
// })
rsp.Flag = true rsp.Flag = true
} }

View File

@ -13,12 +13,13 @@ func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.TaskSendReq) (
} }
func (this *apiComp) Send(session comm.IUserSession, req *pb.TaskSendReq) (code pb.ErrorCode, data *pb.ErrorData) { func (this *apiComp) Send(session comm.IUserSession, req *pb.TaskSendReq) (code pb.ErrorCode, data *pb.ErrorData) {
if imodule, err := this.service.GetModule(comm.ModuleRtask); err == nil { // if imodule, err := this.service.GetModule(comm.ModuleRtask); err == nil {
if itask, ok := imodule.(comm.IRtask); ok { // if itask, ok := imodule.(comm.IRtask); ok {
itask.TriggerTask(session.GetUserId(), comm.GetTaskParam(comm.TaskType(req.TaskType), req.Params...)) // itask.TriggerTask(session.GetUserId(), comm.GetTaskParam(comm.TaskType(req.TaskType), req.Params...))
} // }
} // }
// this.module.ModuleBuried.TriggerBuried(session.GetUserId(),comm.GetBuriedParam(comm.TaskType(req.TaskType)))
rsp := &pb.TaskSendResp{ rsp := &pb.TaskSendResp{
IsSucc: true, IsSucc: true,
} }

View File

@ -98,7 +98,7 @@ func (this *ModelTaskActive) noReceiveTaskActive(uid string, taskTag comm.TaskTa
} }
task := &pb.DBActivity{} task := &pb.DBActivity{}
if err := this.Get(uid, task); err != nil { if err := this.Get(uid, task); err != nil {
this.moduleTask.Errorf("getTaskActivityList err %v", err) // this.moduleTask.Warnf("getTaskActivityList err %v", err)
return false, err return false, err
} }

View File

@ -81,9 +81,6 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
} else { } else {
//触发任务 //触发任务
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype70, 1, req.BattleConfId)) go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype70, 1, req.BattleConfId))
}
}
}
if userTask.CurrentTask == nil { if userTask.CurrentTask == nil {
userTask.CurrentTask = make(map[int32]*pb.Worldtask) userTask.CurrentTask = make(map[int32]*pb.Worldtask)
} }
@ -101,11 +98,15 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
} }
//推送 //推送
session.SendMsg(string(this.module.GetType()), "completecondis", &pb.WorldtaskCompletecondisPush{ // session.SendMsg(string(this.module.GetType()), "completecondis", &pb.WorldtaskCompletecondisPush{
GroupId: req.GroupId, // GroupId: req.GroupId,
TaskId: req.TaskId, // TaskId: req.TaskId,
CondiIds: userTask.CurrentTask[req.GroupId].CondiIds, // CondiIds: userTask.CurrentTask[req.GroupId].CondiIds,
}) // })
}
}
}
} else { } else {
rsp.Code = code rsp.Code = code
this.sendMsg(session, WorldtaskBattleFinish, rsp) this.sendMsg(session, WorldtaskBattleFinish, rsp)