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 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); }