package martialhall import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "google.golang.org/protobuf/proto" ) //参数校验 func (this *apiComp) UnLockCheck(session comm.IUserSession, req *pb.MartialhallUnLockReq) (code pb.ErrorCode) { return } ///练功请求 func (this *apiComp) UnLock(session comm.IUserSession, req *pb.MartialhallUnLockReq) (code pb.ErrorCode, data proto.Message) { var ( err error mart *pb.DBMartialhall mdata *cfg.GameKungfuUnlockData pillar *pb.DBPillar filed string ) if code = this.UnLockCheck(session, req); code != pb.ErrorCode_Success { return } if mart, err = this.module.modelMartialhall.queryUserMartialhall(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError return } if mdata, err = this.module.configure.getunlock(req.Pillar); err != nil { code = pb.ErrorCode_ConfigNoFound return } switch req.Pillar { case 1: pillar = mart.Pillar1 filed = "pillar1" break case 2: pillar = mart.Pillar2 filed = "pillar2" if !mart.Pillar1.Isunlock { code = pb.ErrorCode_MartialhallNoUnlocked return } break case 3: pillar = mart.Pillar3 filed = "pillar3" if !mart.Pillar1.Isunlock || !mart.Pillar2.Isunlock { code = pb.ErrorCode_MartialhallNoUnlocked return } break case 4: pillar = mart.Pillar4 filed = "pillar4" if !mart.Pillar1.Isunlock || !mart.Pillar2.Isunlock || !mart.Pillar3.Isunlock { code = pb.ErrorCode_MartialhallNoUnlocked return } break case 5: pillar = mart.Pillar5 filed = "pillar5" if !mart.Pillar1.Isunlock || !mart.Pillar2.Isunlock || !mart.Pillar3.Isunlock || !mart.Pillar4.Isunlock { code = pb.ErrorCode_MartialhallNoUnlocked return } break } if pillar.Isunlock { code = pb.ErrorCode_MartialhallUnlocked return } pillar.Isunlock = true if code = this.module.ConsumeRes(session, mdata.Consume, true); code != pb.ErrorCode_Success { return } this.module.modelMartialhall.Change(session.GetUserId(), map[string]interface{}{ filed: pillar, }) session.SendMsg(string(this.module.GetType()), "unlock", &pb.MartialhallUnLockResp{Issucc: true, Info: mart}) return }