package exclusive import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 func (this *apiComp) AddExpCheck(session comm.IUserSession, req *pb.ExclusiveAddExpReq) (errdata *pb.ErrorData) { return } ///获取用户装备列表 func (this *apiComp) AddExp(session comm.IUserSession, req *pb.ExclusiveAddExpReq) (errdata *pb.ErrorData) { var ( info *pb.DB_Exclusive ranconf *cfg.GameExclusiveRankData lvconf *cfg.GameExclusiveUpgradeData confs map[string]*cfg.GameExclusiveItemData = make(map[string]*cfg.GameExclusiveItemData) conf *cfg.GameExclusiveItemData need []*cfg.Gameatn = make([]*cfg.Gameatn, 0) err error ) if info, err = this.module.model.getExclusivesById(session.GetUserId(), req.Oid); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Message: err.Error(), } return } if ranconf, err = this.module.configure.GetGameExclusiveRankData(info.CId, info.Step); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Message: err.Error(), } return } for k, n := range req.Items { if conf, err = this.module.configure.GetGameExclusiveItem(k); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Message: err.Error(), } return } confs[k] = conf need = append(need, &cfg.Gameatn{ A: comm.ItemType, T: k, N: n, }) for _, v := range conf.Needgold { need = append(need, &cfg.Gameatn{ A: v.A, T: v.T, N: v.N * n, }) } info.Exp += conf.Exp * n } for { if lvconf, err = this.module.configure.GetGameExclusiveUpgradeData(info.CId, info.Lv); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Message: err.Error(), } return } info.Property = make(map[int32]int32) for _, v := range lvconf.Attribute { info.Property[v.A] = v.N } if info.Lv >= ranconf.Lvmax { //当前阶段最大等级 info.Exp = lvconf.Needexp break } if lvconf.Needexp <= info.Exp { info.Lv++ info.Exp -= lvconf.Needexp } else { break } } if errdata = this.module.ConsumeRes(session, need, true); errdata != nil { return } if err = this.module.model.updateExclusive(session.GetUserId(), info); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Message: err.Error(), } return } this.module.equipmentsChangePush(session, []*pb.DB_Exclusive{info}) session.SendMsg(string(this.module.GetType()), "addexp", &pb.ExclusiveAddExpResp{Exclusives: info}) return }