Ejemplo n.º 1
0
        private IReadOnlyList <ClaimError> GetMasterGameErrors(LeagueYear leagueYear, MasterGame masterGame, int year, bool counterPick, bool dropping, Instant?nextBidTime)
        {
            List <ClaimError> claimErrors = new List <ClaimError>();

            if (!dropping)
            {
                var overriddenEligibility = leagueYear.GetOverriddenEligibility(masterGame);
                if (overriddenEligibility.HasValue)
                {
                    if (!overriddenEligibility.Value)
                    {
                        claimErrors.Add(new ClaimError("That game has been specifically banned by your league.", false));
                    }
                }
                else
                {
                    //Normal eligibility (not manually set)
                    var eligibilityErrors = leagueYear.Options.AllowedEligibilitySettings.GameIsEligible(masterGame);
                    claimErrors.AddRange(eligibilityErrors);
                }
            }

            bool released = masterGame.IsReleased(_clock.GetCurrentInstant());

            if (released)
            {
                claimErrors.Add(new ClaimError("That game has already been released.", true));
            }

            if (nextBidTime.HasValue)
            {
                bool releaseBeforeNextBids = masterGame.IsReleased(nextBidTime.Value);
                if (releaseBeforeNextBids)
                {
                    claimErrors.Add(new ClaimError("That game will release before bids are processed.", true));
                }
            }

            if (released && masterGame.ReleaseDate.HasValue && masterGame.ReleaseDate.Value.Year < year)
            {
                claimErrors.Add(new ClaimError($"That game was released prior to the start of {year}.", false));
            }

            if (!dropping)
            {
                if (!released && masterGame.MinimumReleaseDate.Year > year && !counterPick)
                {
                    claimErrors.Add(new ClaimError($"That game is not scheduled to be released in {year}.", true));
                }
            }

            bool hasScore = masterGame.CriticScore.HasValue;

            if (hasScore)
            {
                claimErrors.Add(new ClaimError("That game already has a score.", true));
            }

            return(claimErrors);
        }
Ejemplo n.º 2
0
    public MasterGameViewModel(MasterGame masterGame, LocalDate currentDate, bool error = false, int numberOutstandingCorrections = 0)
    {
        MasterGameID             = masterGame.MasterGameID;
        GameName                 = masterGame.GameName;
        EstimatedReleaseDate     = masterGame.EstimatedReleaseDate;
        MinimumReleaseDate       = masterGame.MinimumReleaseDate;
        MaximumReleaseDate       = masterGame.GetDefiniteMaximumReleaseDate();
        EarlyAccessReleaseDate   = masterGame.EarlyAccessReleaseDate;
        InternationalReleaseDate = masterGame.InternationalReleaseDate;
        AnnouncementDate         = masterGame.AnnouncementDate;
        ReleaseDate              = masterGame.ReleaseDate;

        IsReleased = masterGame.IsReleased(currentDate);

        DoNotRefreshDate     = masterGame.DoNotRefreshDate;
        DoNotRefreshAnything = masterGame.DoNotRefreshAnything;
        EligibilityChanged   = masterGame.EligibilityChanged;
        DelayContention      = masterGame.DelayContention;

        CriticScore        = masterGame.CriticScore;
        AveragedScore      = masterGame.AveragedScore;
        Notes              = masterGame.Notes;
        OpenCriticID       = masterGame.OpenCriticID;
        GGToken            = masterGame.GGToken;
        SubGames           = masterGame.SubGames.Select(x => new MasterGameViewModel(x, currentDate)).ToList();
        Tags               = masterGame.Tags.Select(x => x.Name).ToList();
        BoxartFileName     = masterGame.BoxartFileName;
        GGCoverArtFileName = masterGame.GGCoverArtFileName;
        AddedTimestamp     = masterGame.AddedTimestamp;

        Error = error;
        NumberOutstandingCorrections = numberOutstandingCorrections;
    }
        private IReadOnlyList <ClaimError> GetMasterGameErrors(LeagueOptions yearOptions, MasterGame masterGame, int year, bool counterPick)
        {
            List <ClaimError> claimErrors = new List <ClaimError>();

            bool eligible = masterGame.IsEligible(yearOptions.MaximumEligibilityLevel);

            if (!eligible)
            {
                claimErrors.Add(new ClaimError("That game is not eligible under this league's settings.", true));
            }

            bool earlyAccessEligible = (!masterGame.EarlyAccess || yearOptions.AllowEarlyAccess);

            if (!earlyAccessEligible)
            {
                claimErrors.Add(new ClaimError("That game is not eligible under this league's early access settings.", true));
            }

            bool yearlyInstallmentEligible = (!masterGame.YearlyInstallment || yearOptions.AllowYearlyInstallments);

            if (!yearlyInstallmentEligible)
            {
                claimErrors.Add(new ClaimError("That game is not eligible under this league's yearly installment settings.", true));
            }

            bool released = masterGame.IsReleased(_clock);

            if (released)
            {
                claimErrors.Add(new ClaimError("That game has already been released.", true));
            }

            if (masterGame.ReleaseDate.HasValue)
            {
                if (released && masterGame.ReleaseDate.Value.Year < year)
                {
                    claimErrors.Add(new ClaimError($"That game was released prior to the start of {year}.", false));
                }
                else if (!released && masterGame.ReleaseDate.Value.Year > year && !counterPick)
                {
                    claimErrors.Add(new ClaimError($"That game is not scheduled to be released in {year}.", true));
                }
            }

            bool hasScore = masterGame.CriticScore.HasValue;

            if (hasScore)
            {
                claimErrors.Add(new ClaimError("That game already has a score.", true));
            }

            return(claimErrors);
        }
    public MinimalPublisherViewModel(LeagueYear leagueYear, Publisher publisher, LocalDate currentDate, bool userIsInLeague,
                                     bool outstandingInvite, SystemWideValues systemWideValues)
    {
        PublisherID   = publisher.PublisherID;
        LeagueID      = leagueYear.League.LeagueID;
        UserID        = publisher.User.Id;
        PublisherName = publisher.PublisherName;
        PublisherIcon = publisher.PublisherIcon;
        LeagueName    = leagueYear.League.LeagueName;
        PlayerName    = publisher.User.UserName;
        Year          = leagueYear.Year;
        DraftPosition = publisher.DraftPosition;
        AutoDraft     = publisher.AutoDraft;

        AverageCriticScore   = publisher.AverageCriticScore;
        TotalFantasyPoints   = publisher.GetTotalFantasyPoints(leagueYear.SupportedYear, leagueYear.Options);
        TotalProjectedPoints = publisher.GetProjectedFantasyPoints(leagueYear, systemWideValues, currentDate);
        Budget = publisher.Budget;

        UserIsInLeague    = userIsInLeague;
        PublicLeague      = leagueYear.Options.PublicLeague;
        OutstandingInvite = outstandingInvite;

        var dateToCheck = currentDate;

        if (leagueYear.SupportedYear.Finished)
        {
            dateToCheck = new LocalDate(Year, 12, 31);
        }

        GamesReleased = publisher.PublisherGames
                        .Where(x => !x.CounterPick)
                        .Where(x => x.MasterGame is not null)
                        .Count(x => x.MasterGame !.MasterGame.IsReleased(dateToCheck));
        var allWillRelease = publisher.PublisherGames
                             .Where(x => !x.CounterPick)
                             .Where(x => x.MasterGame is not null)
                             .Count(x => x.WillRelease());

        GamesWillRelease = allWillRelease - GamesReleased;

        FreeGamesDropped             = publisher.FreeGamesDropped;
        WillNotReleaseGamesDropped   = publisher.WillNotReleaseGamesDropped;
        WillReleaseGamesDropped      = publisher.WillReleaseGamesDropped;
        FreeDroppableGames           = leagueYear.Options.FreeDroppableGames;
        WillNotReleaseDroppableGames = leagueYear.Options.WillNotReleaseDroppableGames;
        WillReleaseDroppableGames    = leagueYear.Options.WillReleaseDroppableGames;
    }
 public MasterGameViewModel(MasterGame masterGame, IClock clock)
 {
     MasterGameID                 = masterGame.MasterGameID;
     GameName                     = masterGame.GameName;
     EstimatedReleaseDate         = masterGame.EstimatedReleaseDate;
     SortableEstimatedReleaseDate = masterGame.GetDefiniteSortableEstimatedReleaseDate();
     ReleaseDate                  = masterGame.ReleaseDate;
     IsReleased                   = masterGame.IsReleased(clock.GetCurrentInstant());
     CriticScore                  = masterGame.CriticScore;
     AveragedScore                = masterGame.AveragedScore;
     EligibilitySettings          = new EligibilitySettingsViewModel(masterGame.EligibilitySettings, false);
     OpenCriticID                 = masterGame.OpenCriticID;
     SubGames                     = masterGame.SubGames.Select(x => new MasterGameViewModel(x, masterGame.EligibilitySettings, clock)).ToList();
     BoxartFileName               = masterGame.BoxartFileName;
     AddedTimestamp               = masterGame.AddedTimestamp;
 }
Ejemplo n.º 6
0
    public decimal?GetFantasyPoints(ScoringSystem scoringSystem, bool counterPick, LocalDate currentDate)
    {
        if (!WillRelease())
        {
            return(0m);
        }

        if (!MasterGame.IsReleased(currentDate))
        {
            return(null);
        }

        if (MasterGame.CriticScore.HasValue)
        {
            return(scoringSystem.GetPointsForScore(MasterGame.CriticScore.Value, counterPick));
        }

        return(null);
    }
Ejemplo n.º 7
0
        public MasterGameViewModel(MasterGame masterGame, IClock clock)
        {
            MasterGameID             = masterGame.MasterGameID;
            GameName                 = masterGame.GameName;
            EstimatedReleaseDate     = masterGame.EstimatedReleaseDate;
            MinimumReleaseDate       = masterGame.MinimumReleaseDate;
            MaximumReleaseDate       = masterGame.GetDefiniteMaximumReleaseDate();
            EarlyAccessReleaseDate   = masterGame.EarlyAccessReleaseDate;
            InternationalReleaseDate = masterGame.InternationalReleaseDate;
            ReleaseDate              = masterGame.ReleaseDate;

            IsReleased     = masterGame.IsReleased(clock.GetCurrentInstant());
            CriticScore    = masterGame.CriticScore;
            AveragedScore  = masterGame.AveragedScore;
            Notes          = masterGame.Notes;
            OpenCriticID   = masterGame.OpenCriticID;
            SubGames       = masterGame.SubGames.Select(x => new MasterGameViewModel(x, clock)).ToList();
            Tags           = masterGame.Tags.Select(x => x.Name).ToList();
            BoxartFileName = masterGame.BoxartFileName;
            AddedTimestamp = masterGame.AddedTimestamp;
        }
Ejemplo n.º 8
0
    public PublisherViewModel(LeagueYear leagueYear, Publisher publisher, LocalDate currentDate, Publisher?nextDraftPublisher,
                              bool userIsInLeague, bool outstandingInvite, SystemWideValues systemWideValues, IReadOnlySet <Guid> counterPickedPublisherGameIDs)
    {
        PublisherID   = publisher.PublisherID;
        LeagueID      = leagueYear.League.LeagueID;
        UserID        = publisher.User.Id;
        PublisherName = publisher.PublisherName;
        PublisherIcon = publisher.PublisherIcon;
        LeagueName    = leagueYear.League.LeagueName;
        PlayerName    = publisher.User.UserName;
        Year          = leagueYear.Year;
        DraftPosition = publisher.DraftPosition;
        AutoDraft     = publisher.AutoDraft;

        Games = publisher.PublisherGames
                .OrderBy(x => x.Timestamp)
                .Select(x => new PublisherGameViewModel(x, currentDate, counterPickedPublisherGameIDs.Contains(x.PublisherGameID), leagueYear.Options.CounterPicksBlockDrops))
                .ToList();
        FormerGames = publisher.FormerPublisherGames
                      .OrderBy(x => x.PublisherGame.Timestamp)
                      .Select(x => new PublisherGameViewModel(x, currentDate))
                      .ToList();
        GameSlots = publisher.GetPublisherSlots(leagueYear.Options)
                    .Select(x => new PublisherSlotViewModel(x, currentDate, leagueYear, systemWideValues, counterPickedPublisherGameIDs))
                    .ToList();

        AverageCriticScore   = publisher.AverageCriticScore;
        TotalFantasyPoints   = publisher.GetTotalFantasyPoints(leagueYear.SupportedYear, leagueYear.Options);
        TotalProjectedPoints = publisher.GetProjectedFantasyPoints(leagueYear, systemWideValues, currentDate);
        Budget = publisher.Budget;

        if (nextDraftPublisher is not null && nextDraftPublisher.PublisherID == publisher.PublisherID)
        {
            NextToDraft = true;
        }

        UserIsInLeague    = userIsInLeague;
        PublicLeague      = leagueYear.Options.PublicLeague;
        OutstandingInvite = outstandingInvite;

        var dateToCheck = currentDate;

        if (leagueYear.SupportedYear.Finished)
        {
            dateToCheck = new LocalDate(Year, 12, 31);
        }

        GamesReleased = publisher.PublisherGames
                        .Where(x => !x.CounterPick)
                        .Where(x => x.MasterGame is not null)
                        .Count(x => x.MasterGame !.MasterGame.IsReleased(dateToCheck));
        var allWillRelease = publisher.PublisherGames
                             .Where(x => !x.CounterPick)
                             .Where(x => x.MasterGame is not null)
                             .Count(x => x.WillRelease());

        GamesWillRelease = allWillRelease - GamesReleased;

        FreeGamesDropped             = publisher.FreeGamesDropped;
        WillNotReleaseGamesDropped   = publisher.WillNotReleaseGamesDropped;
        WillReleaseGamesDropped      = publisher.WillReleaseGamesDropped;
        FreeDroppableGames           = leagueYear.Options.FreeDroppableGames;
        WillNotReleaseDroppableGames = leagueYear.Options.WillNotReleaseDroppableGames;
        WillReleaseDroppableGames    = leagueYear.Options.WillReleaseDroppableGames;
    }
    private IReadOnlyList <ClaimError> GetGenericSlotMasterGameErrors(LeagueYear leagueYear, MasterGame masterGame, int year, bool dropping,
                                                                      LocalDate currentDate, LocalDate dateOfPotentialAcquisition, bool counterPick, bool counterPickedGameIsManualWillNotRelease, bool drafting)
    {
        MasterGameWithEligibilityFactors eligibilityFactors = leagueYear.GetEligibilityFactorsForMasterGame(masterGame, dateOfPotentialAcquisition);
        List <ClaimError> claimErrors = new List <ClaimError>();

        bool manuallyEligible = eligibilityFactors.OverridenEligibility.HasValue && eligibilityFactors.OverridenEligibility.Value;
        bool released         = masterGame.IsReleased(currentDate);

        if (released)
        {
            claimErrors.Add(new ClaimError("That game has already been released.", true));
        }

        if (currentDate != dateOfPotentialAcquisition)
        {
            bool releaseBeforeNextBids = masterGame.IsReleased(dateOfPotentialAcquisition);
            if (releaseBeforeNextBids)
            {
                if (!dropping)
                {
                    claimErrors.Add(new ClaimError("That game will release before bids are processed.", true));
                }
                else
                {
                    claimErrors.Add(new ClaimError("That game will release before drops are processed.", true));
                }
            }
        }

        if (released && masterGame.ReleaseDate.HasValue && masterGame.ReleaseDate.Value.Year < year)
        {
            claimErrors.Add(new ClaimError($"That game was released prior to the start of {year}.", false));
        }

        bool willRelease = masterGame.MinimumReleaseDate.Year == year && !counterPickedGameIsManualWillNotRelease;

        if (!dropping && !released && !willRelease && !manuallyEligible)
        {
            claimErrors.Add(new ClaimError($"That game is not scheduled to be released in {year}.", true));
        }

        if (counterPick && !drafting)
        {
            if (masterGame.DelayContention)
            {
                claimErrors.Add(new ClaimError("That game is in 'delay contention', and therefore cannot be counter picked.", false));
            }

            bool confirmedWillRelease   = masterGame.ReleaseDate.HasValue && masterGame.ReleaseDate.Value.Year == year;
            bool acquiringAfterDeadline = dateOfPotentialAcquisition >= leagueYear.CounterPickDeadline;
            if (!confirmedWillRelease && acquiringAfterDeadline && willRelease)
            {
                claimErrors.Add(new ClaimError($"That game does not have a confirmed release date in {year}, and the 'counter pick deadline' has already passed (or will have by the time bids process).", false));
            }
        }

        bool hasScore = masterGame.CriticScore.HasValue;

        if (hasScore && !manuallyEligible)
        {
            claimErrors.Add(new ClaimError("That game already has a score.", true));
        }

        return(claimErrors);
    }