package parkour import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) // 参数校验 func (this *apiComp) SginOverCheck(session comm.IUserSession, req *pb.ParkourSginOverReq) (errdata *pb.ErrorData) { return } // /获取自己的排行榜信息 func (this *apiComp) SginOver(session comm.IUserSession, req *pb.ParkourSginOverReq) (errdata *pb.ErrorData) { var ( info *pb.DBParkour conf *cfg.GameQualifyingData lvconf *cfg.GameBuzkashiLvData rating int32 atno []*pb.UserAtno err error ) if errdata = this.SginOverCheck(session, req); errdata != nil { return } if info, err = this.module.parkourComp.queryinfo(session.GetUserId()); err != nil && err != mgo.MongodbNil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } if conf, err = this.module.configure.getActiveRewardById(info.Dan); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } if lvconf, err = this.module.configure.getGameBuzkashiLv(req.Scores); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } info.Integral += conf.WinValue if errdata, atno = this.module.DispenseAtno(session, conf.MatewinReward, true); err != nil { return } rating = lvconf.Num info.Weekintegral += lvconf.Point if err = this.module.parkourComp.Change(info.User.Uid, map[string]interface{}{ "integral": info.Integral, "weekintegral": info.Weekintegral, "dan": info.Dan, "state": 0, "roomid": "", "roompath": "", }); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } session.SendMsg(string(this.module.GetType()), "sginover", &pb.ParkourSginOverResp{ Maxlcoins: req.Maxlcoins, Integral: info.Integral, Weekintegral: info.Weekintegral, Rating: rating, Award: atno, }) go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "ParkourSginOverReq", atno) }) return }