package practice import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "time" ) //参数校验 func (this *apiComp) LootCheck(session comm.IUserSession, req *pb.PracticeLootReq) (errdata *pb.ErrorData) { return } ///练功请求 蹭馆 func (this *apiComp) Loot(session comm.IUserSession, req *pb.PracticeLootReq) (errdata *pb.ErrorData) { var ( err error froom *pb.DBPracticeRoom room *pb.DBPracticeRoom pillarconfigure *cfg.GamePandamasMzData tconfigure *cfg.GamePandamasJxData pconfigure *cfg.GamePandamasJxData extra int32 = 0 ) if froom, err = this.module.modelPandata.queryUserMartialhall(req.Friend); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } 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 } if froom.Pillarf.Hero != "" { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } } if pillarconfigure, err = this.module.configure.getGamePandamasMz(froom.Pillarf.Lv); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } if errdata = this.module.ModuleHero.KungFuHero(session, req.Hero, true, req.Friend); errdata != nil { return } if req.Teacher != "" { if room.Knapsack[req.Teacher] == 1 { //已经被使用 errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } room.Knapsack[req.Teacher] = 1 if tconfigure, err = this.module.configure.getGamePandamasJx(req.Teacher); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } extra += tconfigure.Duration froom.Pillarf.Teacher = req.Teacher } if req.Prop != "" { if room.Knapsack[req.Prop] == 1 { //已经被使用 errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, Title: pb.ErrorCode_ReqParameterError.ToString(), } return } room.Knapsack[req.Prop] = 1 if pconfigure, err = this.module.configure.getGamePandamasJx(req.Teacher); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } extra += pconfigure.Duration froom.Pillarf.Prop = req.Prop } froom.Pillarf.Uid = session.GetUserId() froom.Pillarf.Hero = req.Hero froom.Pillarf.Start = configure.Now().Unix() if extra >= 0 { froom.Pillarf.End = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration))).Unix() froom.Pillarf.Expend = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration + extra))).Unix() } else { froom.Pillarf.End = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration + extra))).Unix() froom.Pillarf.Expend = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration))).Unix() } this.module.modelPandata.Change(req.Friend, map[string]interface{}{ "pillarf": froom.Pillarf, }) this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{ "knapsack": room.Knapsack, }) if _session, ok := this.module.GetUserSession(req.Friend); ok { _session.SendMsg(string(this.module.GetType()), "rommchange", &pb.PracticeRommChangePush{Info: froom}) if err = _session.Push(); err != nil { this.module.Errorln(err) } this.module.PutUserSession(_session) } else { this.module.PutUserSession(_session) } go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype184, 1)) session.SendMsg(string(this.module.GetType()), "loot", &pb.PracticeLootResp{Friend: req.Friend, Pillar: froom.Pillarf}) return }