public RoyaleYearQuarter(SupportedYear year, YearQuarter yearQuarter, bool openForPlay, bool finished)
 {
     Year        = year;
     YearQuarter = yearQuarter;
     OpenForPlay = openForPlay;
     Finished    = finished;
 }
 public SupportedYearViewModel(SupportedYear domain)
 {
     Year            = domain.Year;
     OpenForCreation = domain.OpenForCreation;
     OpenForPlay     = domain.OpenForPlay;
     StartDate       = domain.StartDate.ToDateTimeUnspecified();
     Finished        = domain.Finished;
 }
 public PlayerWithPublisherViewModel(LeagueYear leagueYear, FantasyCriticUser user, Publisher publisher, IClock clock,
                                     LeagueOptions options, SystemWideValues systemWideValues, bool userIsInLeague, bool userIsInvitedToLeague,
                                     SupportedYear supportedYear, bool removable)
 {
     User                           = new PlayerViewModel(leagueYear.League, user, removable);
     Publisher                      = new PublisherViewModel(publisher, clock, userIsInLeague, userIsInvitedToLeague, systemWideValues, supportedYear.Finished);
     TotalFantasyPoints             = publisher.TotalFantasyPoints;
     SimpleProjectedFantasyPoints   = publisher.GetProjectedFantasyPoints(options, systemWideValues, supportedYear.Finished, true, clock);
     AdvancedProjectedFantasyPoints = publisher.GetProjectedFantasyPoints(options, systemWideValues, supportedYear.Finished, false, clock);
 }
Esempio n. 4
0
        public LeagueYearViewModel(LeagueYear leagueYear, SupportedYear supportedYear, IEnumerable <Publisher> publishers, FantasyCriticUser currentUser, Publisher userPublisher,
                                   IClock clock, PlayStatus playStatus, StartDraftResult startDraftResult, IEnumerable <FantasyCriticUser> users, Maybe <Publisher> nextDraftPublisher, DraftPhase draftPhase,
                                   IEnumerable <PublisherGame> availableCounterPicks, LeagueWideValues leagueWideValues)
        {
            LeagueID                = leagueYear.League.LeagueID;
            Year                    = leagueYear.Year;
            SupportedYear           = new SupportedYearViewModel(supportedYear);
            StandardGames           = leagueYear.Options.StandardGames;
            GamesToDraft            = leagueYear.Options.GamesToDraft;
            CounterPicks            = leagueYear.Options.CounterPicks;
            MaximumEligibilityLevel = new EligibilityLevelViewModel(leagueYear.Options.MaximumEligibilityLevel, false);
            DraftSystem             = leagueYear.Options.DraftSystem.Value;
            PickupSystem            = leagueYear.Options.PickupSystem.Value;
            ScoringSystem           = leagueYear.Options.ScoringSystem.Name;
            UnlinkedGameExists      = publishers.SelectMany(x => x.PublisherGames).Any(x => x.MasterGame.HasNoValue);
            Publishers              = publishers.OrderBy(x => x.DraftPosition).Select(x => new PublisherViewModel(x, clock, nextDraftPublisher)).ToList();
            Standings               = publishers.OrderByDescending(x => x.TotalFantasyPoints).Select(x => new StandingViewModel(x, leagueYear.Options.ScoringSystem, leagueWideValues)).ToList();

            if (!(userPublisher is null))
            {
                UserPublisher = new PublisherViewModel(userPublisher, clock);
            }

            List <PlayerWithPublisherViewModel> playerVMs = new List <PlayerWithPublisherViewModel>();
            bool allPublishersMade = true;

            foreach (var user in users)
            {
                var publisher = publishers.SingleOrDefault(x => x.User.UserID == user.UserID);
                if (publisher is null)
                {
                    playerVMs.Add(new PlayerWithPublisherViewModel(leagueYear, user));
                    allPublishersMade = false;
                }
                else
                {
                    playerVMs.Add(new PlayerWithPublisherViewModel(leagueYear, user, publisher, clock));
                }
            }

            bool readyToSetDraftOrder = false;

            if (allPublishersMade)
            {
                Players = playerVMs.OrderBy(x => x.Publisher.DraftPosition).ToList();
                readyToSetDraftOrder = true;
            }
            else
            {
                Players = playerVMs;
            }

            PlayStatus            = new PlayStatusViewModel(playStatus, readyToSetDraftOrder, startDraftResult.Ready, startDraftResult.Errors, draftPhase);
            AvailableCounterPicks = availableCounterPicks.Select(x => new PublisherGameViewModel(x, clock)).ToList();
        }
Esempio n. 5
0
    public decimal GetTotalFantasyPoints(SupportedYear year, LeagueOptions leagueOptions)
    {
        var emptyCounterPickSlotPoints = GetEmptyCounterPickSlotPoints(year, leagueOptions) ?? 0m;
        var score = PublisherGames.Sum(x => x.FantasyPoints);

        if (!score.HasValue)
        {
            return(emptyCounterPickSlotPoints);
        }

        return(score.Value + emptyCounterPickSlotPoints);
    }
Esempio n. 6
0
    public bool LeagueIsReadyToPlay(SupportedYear supportedYear, IEnumerable <Publisher> publishersInLeague, IEnumerable <FantasyCriticUser> activeUsers)
    {
        if (!LeagueIsReadyToSetDraftOrder(publishersInLeague, activeUsers))
        {
            return(false);
        }

        if (!supportedYear.OpenForPlay)
        {
            return(false);
        }

        return(true);
    }
Esempio n. 7
0
    public LeagueYear ToDomain(League league, SupportedYear year, IEnumerable <EligibilityOverride> eligibilityOverrides,
                               IEnumerable <TagOverride> tagOverrides, IEnumerable <LeagueTagStatus> leagueTags, IEnumerable <SpecialGameSlot> specialGameSlots,
                               FantasyCriticUser?winningUser, IEnumerable <Publisher> publishersInLeague)
    {
        DraftSystem    draftSystem    = Lib.Enums.DraftSystem.FromValue(DraftSystem);
        PickupSystem   pickupSystem   = Lib.Enums.PickupSystem.FromValue(PickupSystem);
        TradingSystem  tradingSystem  = Lib.Enums.TradingSystem.FromValue(TradingSystem);
        TiebreakSystem tiebreakSystem = Lib.Enums.TiebreakSystem.FromValue(TiebreakSystem);
        ScoringSystem  scoringSystem  = Lib.Domain.ScoringSystems.ScoringSystem.GetScoringSystem(ScoringSystem);

        AnnualDate counterPickDeadline = new AnnualDate(CounterPickDeadlineMonth, CounterPickDeadlineDay);

        LeagueOptions options = new LeagueOptions(StandardGames, GamesToDraft, CounterPicks, CounterPicksToDraft, FreeDroppableGames, WillNotReleaseDroppableGames, WillReleaseDroppableGames,
                                                  DropOnlyDraftGames, CounterPicksBlockDrops, MinimumBidAmount, leagueTags, specialGameSlots, draftSystem, pickupSystem, scoringSystem, tradingSystem, tiebreakSystem, counterPickDeadline);

        return(new LeagueYear(league, year, options, Lib.Enums.PlayStatus.FromValue(PlayStatus), eligibilityOverrides, tagOverrides, DraftStartedTimestamp, winningUser, publishersInLeague));
    }
Esempio n. 8
0
    public LeagueYear(League league, SupportedYear year, LeagueOptions options, PlayStatus playStatus,
                      IEnumerable <EligibilityOverride> eligibilityOverrides, IEnumerable <TagOverride> tagOverrides,
                      Instant?draftStartedTimestamp, FantasyCriticUser?winningUser, IEnumerable <Publisher> publishers)
    {
        League                          = league;
        SupportedYear                   = year;
        Options                         = options;
        PlayStatus                      = playStatus;
        EligibilityOverrides            = eligibilityOverrides.ToList();
        _eligibilityOverridesDictionary = EligibilityOverrides.ToDictionary(x => x.MasterGame);
        TagOverrides                    = tagOverrides.ToList();
        _tagOverridesDictionary         = TagOverrides.ToDictionary(x => x.MasterGame);
        DraftStartedTimestamp           = draftStartedTimestamp;
        WinningUser                     = winningUser;

        _publisherDictionary = publishers.ToDictionary(x => x.PublisherID);
        _managerPublisher    = Publishers.SingleOrDefault(x => x.User.Id == league.LeagueManager.Id);
        StandardGamesTaken   = _publisherDictionary.Values.SelectMany(x => x.PublisherGames).Count(x => !x.CounterPick);
    }
Esempio n. 9
0
    public bool IsRelevantInYear(SupportedYear year)
    {
        if (MasterGame.AddedTimestamp.InUtc().Year > year.Year)
        {
            return(false);
        }

        if (MasterGame.ReleaseDate.HasValue && MasterGame.ReleaseDate.Value.Year < year.Year)
        {
            return(false);
        }

        if (DateAdjustedHypeFactor == 0)
        {
            return(false);
        }

        return(true);
    }
Esempio n. 10
0
    private decimal?GetEmptyCounterPickSlotPoints(SupportedYear year, LeagueOptions leagueOptions)
    {
        if (!SupportedYear.Year2022FeatureSupported(year.Year))
        {
            return(0m);
        }

        if (!year.Finished)
        {
            return(null);
        }

        var expectedNumberOfCounterPicks = leagueOptions.CounterPicks;
        var numberCounterPicks           = PublisherGames.Count(x => x.CounterPick);
        var emptySlots = expectedNumberOfCounterPicks - numberCounterPicks;
        var points     = emptySlots * -15m;

        return(points);
    }
Esempio n. 11
0
 public Task FinishYear(SupportedYear supportedYear)
 {
     return(_fantasyCriticRepo.FinishYear(supportedYear));
 }
Esempio n. 12
0
 public Task <IReadOnlyDictionary <LeagueYear, IReadOnlyList <DropRequest> > > GetActiveDropRequests(SupportedYear supportedYear)
 {
     return(_fantasyCriticRepo.GetActiveDropRequests(supportedYear.Year));
 }
Esempio n. 13
0
 public Task <IReadOnlyDictionary <LeagueYear, IReadOnlyList <PickupBid> > > GetActiveAcquistitionBids(SupportedYear supportedYear)
 {
     return(_fantasyCriticRepo.GetActivePickupBids(supportedYear.Year));
 }
 public RoyaleYearQuarter ToDomain(SupportedYear supportedYear)
 {
     return(new RoyaleYearQuarter(supportedYear, new YearQuarter(Year, Quarter), OpenForPlay, Finished));
 }
Esempio n. 15
0
        public LeagueYearViewModel(LeagueYear leagueYear, SupportedYear supportedYear, IEnumerable <Publisher> publishers, Maybe <Publisher> userPublisher,
                                   IClock clock, PlayStatus playStatus, StartDraftResult startDraftResult, IEnumerable <FantasyCriticUser> activeUsers, Maybe <Publisher> nextDraftPublisher, DraftPhase draftPhase,
                                   IEnumerable <PublisherGame> availableCounterPicks, LeagueOptions options, SystemWideValues systemWideValues, IEnumerable <LeagueInvite> invitedPlayers,
                                   bool userIsInLeague, bool userIsInvitedToLeague, bool userIsManager, Maybe <FantasyCriticUser> accessingUser)
        {
            LeagueID            = leagueYear.League.LeagueID;
            Year                = leagueYear.Year;
            SupportedYear       = new SupportedYearViewModel(supportedYear);
            StandardGames       = leagueYear.Options.StandardGames;
            GamesToDraft        = leagueYear.Options.GamesToDraft;
            CounterPicks        = leagueYear.Options.CounterPicks;
            EligibilitySettings = new EligibilitySettingsViewModel(leagueYear.Options.AllowedEligibilitySettings, false);
            DraftSystem         = leagueYear.Options.DraftSystem.Value;
            PickupSystem        = leagueYear.Options.PickupSystem.Value;
            ScoringSystem       = leagueYear.Options.ScoringSystem.Name;
            UnlinkedGameExists  = publishers.SelectMany(x => x.PublisherGames).Any(x => x.MasterGame.HasNoValue);
            UserIsActive        = activeUsers.Any(x => x.UserID == accessingUser.Unwrap(y => y.UserID));
            Publishers          = publishers
                                  .OrderBy(x => x.DraftPosition)
                                  .Select(x => new PublisherViewModel(x, clock, nextDraftPublisher, userIsInLeague, userIsInvitedToLeague, systemWideValues, supportedYear.Finished))
                                  .ToList();

            if (userPublisher.HasValue)
            {
                UserPublisher = new PublisherViewModel(userPublisher.Value, clock, userIsInLeague, userIsInvitedToLeague, systemWideValues, supportedYear.Finished);
            }

            List <PlayerWithPublisherViewModel> playerVMs = new List <PlayerWithPublisherViewModel>();
            bool allPublishersMade = true;

            foreach (var user in activeUsers)
            {
                var publisher = publishers.SingleOrDefault(x => x.User.UserID == user.UserID);
                if (publisher is null)
                {
                    playerVMs.Add(new PlayerWithPublisherViewModel(leagueYear, user, false));
                    allPublishersMade = false;
                }
                else
                {
                    playerVMs.Add(new PlayerWithPublisherViewModel(leagueYear, user, publisher, clock, options, systemWideValues,
                                                                   userIsInLeague, userIsInvitedToLeague, supportedYear, false));
                }
            }

            foreach (var invitedPlayer in invitedPlayers)
            {
                allPublishersMade = false;

                if (invitedPlayer.User.HasValue)
                {
                    playerVMs.Add(new PlayerWithPublisherViewModel(invitedPlayer.InviteID, invitedPlayer.User.Value.DisplayName));
                }
                else
                {
                    if (accessingUser.HasValue)
                    {
                        if (userIsManager || string.Equals(invitedPlayer.EmailAddress, accessingUser.Value.EmailAddress, StringComparison.OrdinalIgnoreCase))
                        {
                            playerVMs.Add(new PlayerWithPublisherViewModel(invitedPlayer.InviteID, invitedPlayer.EmailAddress));
                        }
                        else
                        {
                            playerVMs.Add(new PlayerWithPublisherViewModel(invitedPlayer.InviteID, "<Email Address Hidden>"));
                        }
                    }
                    else
                    {
                        playerVMs.Add(new PlayerWithPublisherViewModel(invitedPlayer.InviteID, "<Email Address Hidden>"));
                    }
                }
            }

            bool readyToSetDraftOrder = false;

            if (allPublishersMade)
            {
                Players = playerVMs.OrderBy(x => x.Publisher.DraftPosition).ToList();
                readyToSetDraftOrder = true;
            }
            else
            {
                Players = playerVMs;
            }

            PlayStatus            = new PlayStatusViewModel(playStatus, readyToSetDraftOrder, startDraftResult.Ready, startDraftResult.Errors, draftPhase);
            AvailableCounterPicks = availableCounterPicks
                                    .Select(x => new PublisherGameViewModel(x, clock, leagueYear.Options.ScoringSystem, systemWideValues))
                                    .OrderBy(x => x.GameName).ToList();
            EligibilityOverrides = leagueYear.EligibilityOverrides.Select(x => new EligibilityOverrideViewModel(x, clock)).ToList();
        }