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 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" break case 3: pillar = mart.Pillar3 filed = "pillar3" break case 4: pillar = mart.Pillar4 filed = "pillar4" break case 5: pillar = mart.Pillar5 filed = "pillar5" 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.MartialhallUpgradeResp{Info: mart}) return }