package arena import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) // 参数校验 func (this *apiComp) PlotCheck(session comm.IUserSession, req *pb.ArenaPlotReq) (errdata *pb.ErrorData) { return } // /获取自己的排行榜信息 func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (errdata *pb.ErrorData) { var ( npc *cfg.GameArenaChallengeNpcData info *pb.DBArenaUser record *pb.DBBattleRecord index int32 err error ) if errdata = this.PlotCheck(session, req); errdata != nil { return } if npc, err = this.module.configure.getChallengenpc(req.Pid); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), Message: err.Error(), } return } if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } this.module.modelArena.recoverTicket(session, info) if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.ModuleTools.GetGlobalConf().ArenaTicketCos}, true); errdata != nil { return } go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "ArenaPlotReq", this.module.ModuleTools.GetGlobalConf().ArenaTicketCos) // 消耗资源 }) if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{ Rulesid: npc.BattleReadyID, Ptype: pb.PlayType_arena, Format: req.Battle, Mformat: []int32{npc.MonsterformatId[index]}, }); errdata != nil { return } if err = this.module.modelArena.updateArenaUserInfo(info); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), Message: err.Error(), } return } session.SendMsg(string(this.module.GetType()), "plot", &pb.ArenaPlotResp{ Pid: req.Pid, Info: &pb.BattleInfo{ Id: record.Id, Title: record.Title, Rulesid: npc.BattleReadyID, Btype: record.Btype, Ptype: record.Ptype, RedCompId: record.RedCompId, Redflist: record.Redflist, BlueCompId: record.BlueCompId, Buleflist: record.Buleflist, Tasks: record.Tasks, }, }) return }