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} if req.CondiId != 0 { if code = this.moduleRtask.CheckCondi(session.GetUserId(), req.CondiId); code != pb.ErrorCode_Success { rsp.Flag = false return } } else if req.GroupId != 0 { // 获取当前玩家 rtask := this.moduleRtask.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.moduleRtask.modelRtask.Change(rtask.Uid, update) } else { this.moduleRtask.TriggerTask(session.GetUserId(), &comm.TaskParam{ TT: comm.TaskType(req.RtaskType), Params: req.Params, }) rsp.Flag = true } if err := session.SendMsg(string(this.moduleRtask.GetType()), "rtest", rsp); err != nil { code = pb.ErrorCode_SystemError } return }