public virtual Progress Create(League league) { var progress = new Progress { Played = league.Games.Count(g => g.Result != Constants.NotPlayed), Total = TotalGamesCalculator.Calculate(league.Players.Count(FakePlayersHelper.IsNotFake)) }; return progress; }
public League UpdateLeague(League league, int leagueId, string title, List<Game> newGames, List<string> players, string seasonNumber, string winner) { _gamesUpdater.UpdateGames(league.Games, newGames); league.Players = players; league.Progress = _progressFactory.Create(league); league.Winner = winner; return league; }
public League GetNewLeague(int leagueId, string title, List<Game> newGames, List<string> players, string seasonNumber, string winner) { League league = new League { Title = title, Players = players, Games = new List<Game>(), Winner = winner, }; foreach (var newGame in newGames) { var gameCopy = newGame.CreateDeepCopy(); if (newGame.Result != Constants.NotPlayed) gameCopy.PlayedDate = _timeProvider.GetCurrentTime(); league.Games.Add(gameCopy); } league.Progress = _progressFactory.Create(league); return league; }
private bool IsLeagueFinished(League haxballLeague) { return haxballLeague != null && haxballLeague.Progress.Played >= haxballLeague.Progress.Total; }