go_dreamfactory/modules/rtask/api_tasktest.go
2023-05-29 17:16:52 +08:00

61 lines
1.5 KiB
Go

package rtask
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"strings"
"github.com/spf13/cast"
)
func (this *apiComp) RtestCheck(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode) {
return
}
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 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
}
rtaskIds := make([]int32, 0)
ids := strings.Split(req.RtaskIds, ",")
for _, id := range ids {
rtaskIds = append(rtaskIds, cast.ToInt32(id))
}
if v, ok := rtask.FrtaskIds[req.GroupId]; ok {
v.RtaskIds = rtaskIds
} else {
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
rtask.FrtaskIds[req.GroupId] = &pb.FrtaskIds{RtaskIds: rtaskIds}
}
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
}
if err := session.SendMsg(string(this.module.GetType()), "rtest", rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}