public static IReadOnlyList <ClaimError> GetClaimErrorsForSlot(PublisherSlot publisherSlot, MasterGameWithEligibilityFactors eligibilityFactors)
    {
        //This function returns a list of errors if a game is not eligible in THIS slot
        if (publisherSlot.CounterPick)
        {
            return(new List <ClaimError>());
        }

        if (eligibilityFactors.GameIsSpecificallyAllowed)
        {
            return(new List <ClaimError>());
        }

        if (eligibilityFactors.GameIsSpecificallyBanned)
        {
            return(new List <ClaimError>()
            {
                new ClaimError("That game has been specifically banned by your league.", false)
            });
        }

        if (publisherSlot.SpecialGameSlot is null)
        {
            var baseEligibilityResult = eligibilityFactors.CheckGameAgainstTags(eligibilityFactors.Options.LeagueTags, new List <LeagueTagStatus>());
            return(baseEligibilityResult);
        }

        //This is a special slot
        var tagsForSlot = publisherSlot.SpecialGameSlot.Tags.Select(x => new LeagueTagStatus(x, TagStatus.Required));
        var specialEligibilityResult = eligibilityFactors.CheckGameAgainstTags(eligibilityFactors.Options.LeagueTags, tagsForSlot);

        return(specialEligibilityResult);
    }
Esempio n. 2
0
    public MasterGameWithEligibilityFactors?GetEligibilityFactorsForSlot(PublisherSlot publisherSlot)
    {
        if (publisherSlot.PublisherGame is null || publisherSlot.PublisherGame.MasterGame is null)
        {
            return(null);
        }

        var  masterGame          = publisherSlot.PublisherGame.MasterGame.MasterGame;
        bool?eligibilityOverride = GetOverriddenEligibility(masterGame);
        IReadOnlyList <MasterGameTag> tagOverrides = GetOverriddenTags(masterGame);
        var acquisitionDate = publisherSlot.PublisherGame.Timestamp.ToEasternDate();

        return(new MasterGameWithEligibilityFactors(publisherSlot.PublisherGame.MasterGame.MasterGame, Options, eligibilityOverride, tagOverrides, acquisitionDate));
    }
    public void Under60ScoreTest()
    {
        Instant pickupTime = InstantPattern.ExtendedIso.Parse("2018-01-02T12:34:24Z").GetValueOrThrow();
        Instant nowTime    = InstantPattern.ExtendedIso.Parse("2018-08-02T12:34:24Z").GetValueOrThrow();
        IClock  fakeClock  = new FakeClock(nowTime);
        var     fakeToday  = fakeClock.GetToday();

        MasterGame masterGame = new MasterGame(Guid.NewGuid(), "", "",
                                               new LocalDate(2018, 4, 20), new LocalDate(2018, 4, 20), null, null, null, new LocalDate(2018, 4, 20),
                                               null, null, 55, "", "", "", fakeClock.GetCurrentInstant(), false, false, false, false,
                                               fakeClock.GetCurrentInstant(), new List <MasterSubGame>(), new List <MasterGameTag>());

        PublisherGame testGame      = new PublisherGame(Guid.NewGuid(), Guid.NewGuid(), "", pickupTime, false, null, false, null, new MasterGameYear(masterGame, 2018), 1, null, null, null, null);
        PublisherSlot testSlot      = new PublisherSlot(1, 1, false, null, testGame);
        decimal?      fantasyPoints = testSlot.GetFantasyPoints(true, _scoringSystem, fakeToday);

        Assert.AreEqual(-12.5m, fantasyPoints);
    }
Esempio n. 4
0
    public PublisherSlotViewModel(PublisherSlot slot, LocalDate currentDate, LeagueYear leagueYear,
                                  SystemWideValues systemWideValues, IReadOnlySet <Guid> counterPickedPublisherGameIDs)
    {
        SlotNumber        = slot.SlotNumber;
        OverallSlotNumber = slot.OverallSlotNumber;
        CounterPick       = slot.CounterPick;

        if (slot.SpecialGameSlot is not null)
        {
            SpecialSlot = new SpecialGameSlotViewModel(slot.SpecialGameSlot);
        }

        if (slot.PublisherGame is not null)
        {
            PublisherGame = new PublisherGameViewModel(slot.PublisherGame, currentDate, counterPickedPublisherGameIDs.Contains(slot.PublisherGame.PublisherGameID), leagueYear.Options.CounterPicksBlockDrops);
        }

        EligibilityErrors     = slot.GetClaimErrorsForSlot(leagueYear).Select(x => x.Error).ToList();
        GameMeetsSlotCriteria = !EligibilityErrors.Any();

        ProjectedFantasyPoints = slot.GetProjectedFantasyPoints(leagueYear.Options.ScoringSystem, systemWideValues,
                                                                leagueYear.StandardGamesTaken, leagueYear.TotalNumberOfStandardGames);
    }