Example #1
0
        public static RoundPlanning Random(int amountOfTeams, int amountOfEvents, int amountOfRegularEvents,
                                           List <SportsMatch> matchPool, int avgPlayersPerTeam, bool breakRound = false,
                                           List <Tuple <int, int> > predefinedMatchUps = null)
        {
            var round = new RoundPlanning(amountOfEvents);

            bool usePredefinedMatchUps = predefinedMatchUps != null;

            // Generate amountOfTeams/2 regular events.
            for (int i = 0; i < amountOfRegularEvents; i++)
            {
                // Use a predefined match-up if possible. Randomly generate one otherwise.
                (int t0, int t1) = usePredefinedMatchUps ?
                                   (predefinedMatchUps[i].Item1, predefinedMatchUps[i].Item2) :
                                   (Globals.Rand.Next(0, amountOfTeams), Globals.Rand.Next(0, amountOfTeams));

                round.Events[i] = Event.Random(t0, t1, matchPool, avgPlayersPerTeam, round.PlayersPerMatchType);
            }
            // Generate a break event if the amount of teams is odd.
            if (breakRound)
            {
                int t = Globals.Rand.Next(0, amountOfTeams);
                round.Events[amountOfEvents - 1] = new BreakEvent(t);
            }

            return(round);
        }
Example #2
0
        public RoundPlanning Clone()
        {
            RoundPlanning clone = new RoundPlanning(this.Events.Length);

            for (int i = 0; i < this.Events.Length; i++)
            {
                clone.Events[i] = this.Events[i].Clone();
            }

            foreach (KeyValuePair <SportsMatchCategory, int> pair in this.PlayersPerMatchType)
            {
                clone.PlayersPerMatchType[pair.Key] = pair.Value;
            }

            return(clone);
        }