Beispiel #1
0
 // Load tournament state from disk
 bool LoadTournamentState(string stateFile = "")
 {
     if (stateFile != "")
     {
         this.stateFile = stateFile;
     }
     tournamentState = new TournamentState();
     if (tournamentState.LoadState(this.stateFile))
     {
         message        = "Tournament state loaded from " + this.stateFile;
         tournamentID   = tournamentState.tournamentID;
         tournamentType = tournamentState.tournamentType;
         vesselCount    = tournamentState.vesselCount;
         teamCount      = tournamentState.teamCount;
         teamsPerHeat   = tournamentState.teamsPerHeat;
         vesselsPerTeam = tournamentState.vesselsPerTeam;
         fullTeams      = tournamentState.fullTeams;
         numberOfRounds = tournamentState.rounds.Count;
         numberOfHeats  = numberOfRounds > 0 ? tournamentState.rounds[0].Count : 0;
         heatsRemaining = tournamentState.rounds.Select(r => r.Value.Count).Sum() - tournamentState.completed.Select(c => c.Value.Count).Sum();
     }
     else
     {
         message = "Failed to load tournament state.";
     }
     Debug.Log("[BDATournament]: " + message);
     // if (BDACompetitionMode.Instance != null)
     //     BDACompetitionMode.Instance.competitionStatus.Add(message);
     tournamentStatus = heatsRemaining > 0 ? TournamentStatus.Stopped : TournamentStatus.Completed;
     return(true);
 }
Beispiel #2
0
 public void SetupTournament(string folder, int rounds, int vesselsPerHeat = 0, int teamsPerHeat = 0, int vesselsPerTeam = 0, int numberOfTeams = 0, string stateFile = "")
 {
     if (stateFile != "")
     {
         this.stateFile = stateFile;
     }
     tournamentState = new TournamentState();
     if (numberOfTeams == 0) // FFA
     {
         if (!tournamentState.Generate(folder, rounds, vesselsPerHeat))
         {
             return;
         }
     }
     else // Folders or random teams
     {
         if (!tournamentState.Generate(folder, rounds, teamsPerHeat, vesselsPerTeam, numberOfTeams))
         {
             return;
         }
     }
     tournamentID        = tournamentState.tournamentID;
     tournamentType      = tournamentState.tournamentType;
     vesselCount         = tournamentState.vesselCount;
     teamCount           = tournamentState.teamCount;
     this.teamsPerHeat   = tournamentState.teamsPerHeat;
     this.vesselsPerTeam = tournamentState.vesselsPerTeam;
     fullTeams           = tournamentState.fullTeams;
     numberOfRounds      = tournamentState.rounds.Count;
     numberOfHeats       = numberOfRounds > 0 ? tournamentState.rounds[0].Count : 0;
     heatsRemaining      = tournamentState.rounds.Select(r => r.Value.Count).Sum() - tournamentState.completed.Select(c => c.Value.Count).Sum();
     tournamentStatus    = heatsRemaining > 0 ? TournamentStatus.Stopped : TournamentStatus.Completed;
     message             = "Tournament generated for " + vesselCount + " craft found in AutoSpawn" + (folder == "" ? "" : "/" + folder);
     BDACompetitionMode.Instance.competitionStatus.Add(message);
     Debug.Log("[BDATournament]: " + message);
     SaveTournamentState();
 }