package practice import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 func (this *apiComp) UpgradeCheck(session comm.IUserSession, req *pb.PracticeUpgradeReq) (errdata *pb.ErrorData) { return } ///练功请求 蹭馆 func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.PracticeUpgradeReq) (errdata *pb.ErrorData) { var ( err error room *pb.DBPracticeRoom pillarconfigure *cfg.GamePandamasMzData pillar *pb.DBPracticePillar filed string ) 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.Hero != "" { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } if pillarconfigure, err = this.module.configure.getGamePandamasMz(pillar.Lv); err != nil || len(pillarconfigure.UpLvConsume) == 0 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_PracticePillarMaxLv, Title: pb.ErrorCode_PracticePillarMaxLv.ToString(), } return } if errdata = this.module.ConsumeRes(session, pillarconfigure.UpLvConsume, true); errdata != nil { return } pillar.Lv++ if room.Pillarf.Lv < pillar.Lv { room.Pillarf.Lv = pillar.Lv } switch pillar.Lv { case 2: this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100002") break case 3: this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100003") break case 4: this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100004") break case 5: this.module.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100005") break } this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{ filed: pillar, "pillarf": room.Pillarf, }) session.SendMsg(string(this.module.GetType()), "upgrade", &pb.PracticeUpgradeResp{Index: req.Index, Lv: pillar.Lv}) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "PracticeUpgradeReq", pillarconfigure.UpLvConsume) }) return }