56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package worldtask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func (this *apiComp) TestCheck(session comm.IUserSession, req *pb.WorldtaskTestReq) (errdata *pb.ErrorData) {
|
|
if len(req.Params) < 1 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Test(session comm.IUserSession, req *pb.WorldtaskTestReq) (errdata *pb.ErrorData) {
|
|
if errdata = this.TestCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
rsp := &pb.WorldtaskTestResp{Flag: true, RtaskType: req.RtaskType}
|
|
// 校验
|
|
if req.CondiId != 0 {
|
|
condIds, err := this.module.ModuleBuried.CheckCondition(session.GetUserId(), req.CondiId)
|
|
if err == nil && len(condIds) > 0 {
|
|
rsp.Flag = true
|
|
}
|
|
// 触发
|
|
} else if req.RtaskType != 0 && len(req.Params) > 0 {
|
|
conds := []int32{}
|
|
switch len(req.Params) {
|
|
case 2:
|
|
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...))
|
|
|
|
rsp.Flag = true
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "test", rsp)
|
|
return
|
|
}
|