package catchbugs import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) func (this *apiComp) PassLevelCheck(session comm.IUserSession, req *pb.CatchbugsPassLevelReq) (errdata *pb.ErrorData) { return } func (this *apiComp) PassLevel(session comm.IUserSession, req *pb.CatchbugsPassLevelReq) (errdata *pb.ErrorData) { var ( conf *cfg.GameCatchbugStageData info *pb.DBCatchBugs card int32 ok bool err error ) if errdata = this.PassLevelCheck(session, req); errdata != nil { return } if conf, err = this.module.configure.getGameCatchbugStage(req.Level); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Message: err.Error(), } return } if errdata = this.module.ConsumeRes(session, conf.Consume, true); err != nil { return } if info, err = this.module.model.getModel(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Message: err.Error(), } return } for _, v := range req.Card { if _, ok = info.Books[v]; !ok { card++ info.Books[v]++ } } info.Integral += conf.Points info.Accruedintegral += conf.Points this.module.model.Change(session.GetUserId(), map[string]interface{}{ "integral": info.Integral, "accruedintegral": info.Accruedintegral, }) session.SendMsg(string(this.module.GetType()), "passlevel", &pb.CatchbugsPassLevelResp{Level: req.Level, Integral: conf.Points, Card: card}) return }