public List <string> PrintGames() { if (currentTour == 0) { throw new ArgumentException("There are no sortitions yet!"); } List <Player> pls = players.ToList(); List <string> res = new List <string>(); List <int> usedids = new List <int>(); string sgame; Game game; foreach (Player p in pls) { if (!usedids.Contains(p.ID)) { game = p.Games[currentTour - 1]; if (game.OpponentId == -1) { continue; } int index = Sortitions.FindPlayerIndex(pls, game.OpponentId); sgame = $"{res.Count + 1} {p.Surname} {p.Name} - {pls[index].Surname} {pls[index].Name}"; usedids.Add(p.ID); usedids.Add(pls[index].ID); res.Add(sgame); } } return(res); }
private void MakeSortition() { UpdatePoints(); List <Player> players = new List <Player>(); // Вызов жеребьевки switch (System) { case TournamentSystem.Circle: players = Sortitions.CircleSystem(this.players.ToList()); break; case TournamentSystem.MakMagon: players = Sortitions.MakmagonSystem(this.players.ToList(), CurrentTour + 1); break; } // Случай, когда неозможно провести жеребьевку if (players is null) { throw new ArgumentException("Неозможно провести жеребьевку!"); } this.players.Clear(); foreach (Player p in players) { this.players.Add(p); } }
private void SortPlayers(List <Player> players) { players.Sort(); this.players.Clear(); int place = 1; foreach (Player p in players) { p.Place = place; place++; } int id; int index; foreach (Player p in players) { foreach (Game g in p.Games) { id = g.OpponentId; if (id != -1) { index = Sortitions.FindPlayerIndex(players, id); g.Opponent = players[index].Place; } } this.players.Add(p); } }
private void UpdatePoints() { List <Player> players = this.players.ToList(); if (currentTour > 0) { // Изменяем игровые очки Game game; foreach (Player p in players) { game = p.Games[CurrentTour - 1]; if (game.Result == GameResult.Win || game.Result == GameResult.WinByAbsence) { p.Points += 1; } else if (game.Result == GameResult.Draw) { p.Points += 0.5; } } // Изменяем коэффициенты Бухгольца и бергера foreach (Player p in players) { game = p.Games[CurrentTour - 1]; if (game.OpponentId != -1) { // индекс и очки противника int index = Sortitions.FindPlayerIndex(players, game.OpponentId); double points = players[index].Points; if (game.Result == GameResult.Win || game.Result == GameResult.WinByAbsence) { p.Buhgolz += points; p.Berger += points; } else if (game.Result == GameResult.Draw) { p.Buhgolz += points / 2; p.Berger += points / 2; } else if (game.Result == GameResult.Defeat || game.Result == GameResult.DefeatByAbsence) { p.Buhgolz += points; } } } } SortPlayers(players); }
static void Main(string[] args) { List <Player> players = new List <Player>(); Sortitions.MakmagonSystem(players, 1); TestEnum en = TestEnum.X; foreach (var val in Enum.GetNames(typeof(TestEnum))) { Console.WriteLine(val); } Type enumType = typeof(TestEnum); foreach (string enumName in enumType.GetEnumNames()) { Console.WriteLine(enumName); Console.WriteLine(enumType.GetMember(enumName)[0].GetCustomAttribute <DescriptionAttribute>().Description); } }