void ListMatches(List<Team> TeamsBeforeBye) { if (TeamsBeforeBye.Count % 2 != 0) { TeamsBeforeBye.Add(new Team() {Name = "Bye"}); } int matchAmmount = (TeamsBeforeBye.Count - 1); int halfSize = TeamsBeforeBye.Count / 2; List<Team> teams = new List<Team>(); teams.AddRange(TeamsBeforeBye); teams.RemoveAt(0); int teamsSize = teams.Count; for (int match = 0; match < matchAmmount; match++) { Console.WriteLine("Match {0}", (match + 1)); int teamIndex = match % teamsSize; Console.WriteLine("{0} vs {1}", teams[teamIndex], TeamsBeforeBye[0]); for (int index = 1; index < halfSize; index++) { int firstTeam = (match + index % teamsSize); int secondTeam = (match + teamsSize - index % teamsSize); Console.WriteLine("{0} vs {1}", teams[firstTeam], teams[secondTeam]); } } }
public void AutoGenerateMatches() { var matches = new List<Match>(); foreach (var item in GeneratedGroups) { if (item.Teams.Count % 2 != 0) { item.Teams.Add(new Team() { Name = "UnEven"+item.Name, Win = 0, Draw = 0, Loss = 0, Players = new List<Player>() }); } int numMatch = (item.Teams.Count - 1); int halfSize = item.Teams.Count / 2; List<Team> teams = new List<Team>(); teams.AddRange(item.Teams); // Copy all the elements. teams.RemoveAt(0); // To exclude the first team. int teamsSize = teams.Count; for (int match = 0; match < numMatch; match++) { string round = (match + 1).ToString(); int teamIdx = match % teamsSize; matches.Add(new Match() { Round = round, HomeTeam = teams[teamIdx], AwayTeam = item.Teams[0] }); for (int idx = 1; idx < halfSize; idx++) { int firstTeam = (match + idx) % teamsSize; int secondTeam = (match + teamsSize - idx) % teamsSize; matches.Add(new Match() { Round = round, HomeTeam = teams[firstTeam], AwayTeam = teams[secondTeam] }); } } } GeneratedMatches = matches; }
public List<Equipment> GetVisuals() { bool[] equip = new bool[9]; List<Equipment> equips = new List<Equipment>(); List<Equipment> Equipments = GetAllEquips(); for (int i = 0; i < 9; i++) { if (!equip[i]) { Equipment temp = new Equipment(); temp.Slot = (byte)i; temp.VisualID = 0; temp.Plus = 0; temp.Slvl = 0; temp.RequiredClass = 0; equips.Add(temp); } } foreach (Equipment i in Equipments) { if (i != null) { equips.RemoveAt(i.Slot); equips.Insert(i.Slot, i); equip[i.Slot] = true; } } return equips; }
/// <summary> /// Method to Get Months from System in Utility Class /// </summary> /// <returns>System.Collections.Generic.List</returns> public static List<string> GetMonths() { try { string[] months = System.Globalization.DateTimeFormatInfo.InvariantInfo.MonthNames; List<string> monthList = null; monthList = new List<string>(months); monthList.RemoveAt(12); return monthList; } catch (Exception) { throw; } }