package practice import ( "go_dreamfactory/comm" "go_dreamfactory/pb" ) // 参数校验 func (this *apiComp) UnLockCheck(session comm.IUserSession, req *pb.PracticeUnLockReq) (errdata *pb.ErrorData) { return } // /练功请求 解锁木桩 func (this *apiComp) UnLock(session comm.IUserSession, req *pb.PracticeUnLockReq) (errdata *pb.ErrorData) { var ( err error room *pb.DBPracticeRoom pillar *pb.DBPracticePillar filed string tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) ) if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } switch req.Index { case 1: pillar = room.Pillar1 filed = "pillar1" break case 2: pillar = room.Pillar2 filed = "pillar2" break case 3: pillar = room.Pillar3 filed = "pillar3" break case 4: pillar = room.Pillarf filed = "pillarf" break } if pillar.Isunlock != 1 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } pillar.Isunlock = 2 if room.Pillarf.Isunlock == 0 { room.Pillarf.Isunlock = 2 } if pillarconfigure, err := this.module.configure.getGamePandamasMz(req.Index); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } else { if errdata = this.module.DispenseRes(session, pillarconfigure.PhotoGuideUnlocking, true); errdata != nil { return } } this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{ filed: pillar, "pillarf": room.Pillarf, }) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype152, 1)) session.SendMsg(string(this.module.GetType()), "unlock", &pb.PracticeUnLockResp{Info: room}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.ModuleBuried.TriggerBuried(session, tasks...) }) return }