Esempio n. 1
0
        public MasterGame ToDomain(IEnumerable <MasterSubGame> subGames, EligibilityLevel eligibilityLevel)
        {
            LocalDate?releaseDate = null;

            if (ReleaseDate.HasValue)
            {
                releaseDate = LocalDate.FromDateTime(ReleaseDate.Value);
            }

            LocalDate?sortableEstimatedReleaseDate = null;

            if (SortableEstimatedReleaseDate.HasValue)
            {
                sortableEstimatedReleaseDate = LocalDate.FromDateTime(SortableEstimatedReleaseDate.Value);
            }

            Instant?firstCriticScoreTimestamp = null;

            if (FirstCriticScoreTimestamp.HasValue)
            {
                firstCriticScoreTimestamp = Instant.FromDateTimeUtc(FirstCriticScoreTimestamp.Value);
            }

            var addedTimestamp      = LocalDateTime.FromDateTime(AddedTimestamp).InZoneStrictly(DateTimeZone.Utc).ToInstant();
            var eligibilitySettings = new EligibilitySettings(eligibilityLevel, YearlyInstallment, EarlyAccess, FreeToPlay, ReleasedInternationally, ExpansionPack, UnannouncedGame);

            return(new MasterGame(MasterGameID, GameName, EstimatedReleaseDate, sortableEstimatedReleaseDate, releaseDate, OpenCriticID, CriticScore, LocalDate.FromDateTime(MinimumReleaseDate),
                                  eligibilitySettings, subGames.ToList(), BoxartFileName, firstCriticScoreTimestamp, DoNotRefreshDate, DoNotRefreshAnything, EligibilityChanged, addedTimestamp));
        }
Esempio n. 2
0
        public MasterGameYear ToDomain(IEnumerable <MasterSubGame> subGames, EligibilityLevel eligibilityLevel, int year)
        {
            LocalDate?releaseDate = null;

            if (ReleaseDate.HasValue)
            {
                releaseDate = LocalDate.FromDateTime(ReleaseDate.Value);
            }

            LocalDate?sortableEstimatedReleaseDate = null;

            if (SortableEstimatedReleaseDate.HasValue)
            {
                sortableEstimatedReleaseDate = LocalDate.FromDateTime(SortableEstimatedReleaseDate.Value);
            }

            Instant?firstCriticScoreTimestamp = null;

            if (FirstCriticScoreTimestamp.HasValue)
            {
                firstCriticScoreTimestamp = Instant.FromDateTimeUtc(FirstCriticScoreTimestamp.Value);
            }

            var addedTimestamp      = LocalDateTime.FromDateTime(AddedTimestamp).InZoneStrictly(DateTimeZone.Utc).ToInstant();
            var eligibilitySettings = new EligibilitySettings(eligibilityLevel, YearlyInstallment, EarlyAccess, FreeToPlay, ReleasedInternationally, ExpansionPack, UnannouncedGame);

            var masterGame = new MasterGame(MasterGameID, GameName, EstimatedReleaseDate, sortableEstimatedReleaseDate, releaseDate,
                                            OpenCriticID, CriticScore, LocalDate.FromDateTime(MinimumReleaseDate), eligibilitySettings, subGames.ToList(), BoxartFileName, firstCriticScoreTimestamp,
                                            false, false, EligibilityChanged, addedTimestamp);

            return(new MasterGameYear(masterGame, year, PercentStandardGame, PercentCounterPick, EligiblePercentStandardGame, EligiblePercentCounterPick,
                                      NumberOfBids, TotalBidAmount, BidPercentile, AverageDraftPosition, AverageWinningBid, HypeFactor, DateAdjustedHypeFactor, LinearRegressionHypeFactor));
        }
Esempio n. 3
0
 public PossibleRoyaleMasterGameViewModel(MasterGameYear masterGame, IClock clock, RoyaleYearQuarter yearQuarter, bool alreadyOwned)
 {
     MasterGame           = new MasterGameYearViewModel(masterGame, clock);
     WillReleaseInQuarter = masterGame.WillReleaseInQuarter(yearQuarter.YearQuarter);
     IsEligible           = !EligibilitySettings.GetRoyaleEligibilitySettings().GameIsEligible(masterGame.MasterGame).Any();
     AlreadyOwned         = alreadyOwned;
     Cost = masterGame.GetRoyaleGameCost();
 }
Esempio n. 4
0
        public Lib.Domain.MasterGame ToDomain(EligibilityLevel eligibilityLevel, Instant timestamp, LocalDate tomorrow)
        {
            var eligibilitySettings = new EligibilitySettings(eligibilityLevel, YearlyInstallment, EarlyAccess, FreeToPlay, ReleasedInternationally, ExpansionPack, UnannouncedGame);

            Lib.Domain.MasterGame masterGame = new Lib.Domain.MasterGame(Guid.NewGuid(), GameName, EstimatedReleaseDate, SortableEstimatedReleaseDate,
                                                                         ReleaseDate, OpenCriticID, null, tomorrow,
                                                                         eligibilitySettings, BoxartFileName, null, false, false, timestamp);
            return(masterGame);
        }
 public EligibilitySettingsViewModel(EligibilitySettings eligibilitySettings, bool includeExamples)
 {
     EligibilityLevel        = new EligibilityLevelViewModel(eligibilitySettings.EligibilityLevel, includeExamples);
     YearlyInstallment       = eligibilitySettings.YearlyInstallment;
     EarlyAccess             = eligibilitySettings.EarlyAccess;
     FreeToPlay              = eligibilitySettings.FreeToPlay;
     ReleasedInternationally = eligibilitySettings.ReleasedInternationally;
     ExpansionPack           = eligibilitySettings.ExpansionPack;
 }
        public LeagueYear ToDomain(League league, EligibilityLevel maximumEligibilityLevel, IEnumerable <EligibilityOverride> eligibilityOverrides)
        {
            DraftSystem   draftSystem         = Lib.Enums.DraftSystem.FromValue(DraftSystem);
            PickupSystem  pickupSystem        = Lib.Enums.PickupSystem.FromValue(PickupSystem);
            ScoringSystem scoringSystem       = Lib.Domain.ScoringSystems.ScoringSystem.GetScoringSystem(ScoringSystem);
            var           eligibilitySettings = new EligibilitySettings(maximumEligibilityLevel, AllowYearlyInstallments, AllowEarlyAccess,
                                                                        AllowFreeToPlay, AllowReleasedInternationally, AllowExpansions);

            LeagueOptions options = new LeagueOptions(StandardGames, GamesToDraft, CounterPicks, FreeDroppableGames, WillNotReleaseDroppableGames, WillReleaseDroppableGames,
                                                      DropOnlyDraftGames, eligibilitySettings, draftSystem, pickupSystem, scoringSystem, league.PublicLeague);

            return(new LeagueYear(league, Year, options, Lib.Enums.PlayStatus.FromValue(PlayStatus), eligibilityOverrides));
        }
 public MasterGameViewModel(MasterSubGame masterSubGame, EligibilitySettings eligibilitySettings, IClock clock)
 {
     MasterGameID                 = masterSubGame.MasterGameID;
     GameName                     = masterSubGame.GameName;
     EstimatedReleaseDate         = masterSubGame.EstimatedReleaseDate;
     SortableEstimatedReleaseDate = masterSubGame.SortableEstimatedReleaseDate;
     ReleaseDate                  = masterSubGame.ReleaseDate;
     IsReleased                   = masterSubGame.IsReleased(clock.GetCurrentInstant());
     CriticScore                  = masterSubGame.CriticScore;
     AveragedScore                = false;
     EligibilitySettings          = new EligibilitySettingsViewModel(eligibilitySettings, false);
     OpenCriticID                 = masterSubGame.OpenCriticID;
     SubGames                     = null;
 }
        private static MasterGame CreateMasterGame(string guid, string name, string estimatedReleaseDate, LocalDate sortableEstimatedReleaseDate, LocalDate?releaseDate, int?openCriticID, decimal?criticScore,
                                                   LocalDate minimumReleaseDate, int eligibilityLevelID, bool yearlyInstallment, bool earlyAccess, bool freeToPlay, bool releasedInternationally, bool expansionPack,
                                                   string boxartFileName, string firstCriticScoreTimestamp, bool doNotRefreshDate, bool doNotRefreshAnything, string addedTimestamp)
        {
            EligibilityLevel eligibilityLevel = EligibilityLevelFactory.GetEligibilityLevels().Single(x => x.Level == eligibilityLevelID);

            var eligibilitySettings = new EligibilitySettings(eligibilityLevel, false, false, false, false, false, false);

            var game = new MasterGame(Guid.Parse(guid), name, estimatedReleaseDate, sortableEstimatedReleaseDate, releaseDate, openCriticID,
                                      criticScore, minimumReleaseDate, eligibilitySettings, boxartFileName,
                                      InstantPattern.ExtendedIso.Parse(firstCriticScoreTimestamp).GetValueOrThrow(), doNotRefreshDate, doNotRefreshAnything,
                                      InstantPattern.ExtendedIso.Parse(addedTimestamp).GetValueOrThrow());

            return(game);
        }
Esempio n. 9
0
        public PossibleMasterGameYear GetPossibleMasterGameYear(MasterGameYear masterGame, HashSet <MasterGame> publisherStandardMasterGames, HashSet <MasterGame> myPublisherMasterGames,
                                                                EligibilitySettings eligibilitySettings)
        {
            var  eligibilityErrors = eligibilitySettings.GameIsEligible(masterGame.MasterGame);
            bool isEligible        = !eligibilityErrors.Any();
            bool taken             = publisherStandardMasterGames.Contains(masterGame.MasterGame);
            bool alreadyOwned      = myPublisherMasterGames.Contains(masterGame.MasterGame);
            bool isReleased        = masterGame.MasterGame.IsReleased(_clock.GetCurrentInstant());
            bool willRelease       = masterGame.WillRelease();
            bool hasScore          = masterGame.MasterGame.CriticScore.HasValue;

            PossibleMasterGameYear possibleMasterGame = new PossibleMasterGameYear(masterGame, taken, alreadyOwned, isEligible, isReleased, willRelease, hasScore);

            return(possibleMasterGame);
        }
        public void UnreleasedGameTest()
        {
            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);
            ScoringSystem standardScoring     = ScoringSystem.GetScoringSystem("Standard");
            var           eligibilitySettings = new EligibilitySettings(StandardEligibilityLevel, false, false, false, false, false);

            MasterGame masterGame = new MasterGame(Guid.NewGuid(), "", "", new LocalDate(2018, 10, 20), new LocalDate(2018, 10, 20), null, null, new LocalDate(2018, 1, 1), eligibilitySettings, "",
                                                   fakeClock.GetCurrentInstant(), false, false, fakeClock.GetCurrentInstant());
            PublisherGame testGame = new PublisherGame(Guid.NewGuid(), Guid.NewGuid(), "", pickupTime, false, null, null, new MasterGameYear(masterGame, 2018), null, null);

            decimal?fantasyPoints = testGame.CalculateFantasyPoints(standardScoring, fakeClock);

            Assert.AreEqual(null, fantasyPoints);
        }
Esempio n. 11
0
        public static List <LeagueYear> GetLeagueYears()
        {
            var leagues                   = GetLeagues();
            var eligibilityLevel          = EligibilityLevelFactory.GetEligibilityLevels().Single(x => x.Level == 0);
            List <LeagueYear> leagueYears = new List <LeagueYear>();

            foreach (var league in leagues)
            {
                var        eligibilitySettings  = new EligibilitySettings(eligibilityLevel, true, false, true, false, false);
                var        eligibilityOverrides = new List <EligibilityOverride>();
                LeagueYear year = new LeagueYear(league, 2019, new LeagueOptions(12, 6, 1, 2, -1, 0, false, eligibilitySettings, DraftSystem.Flexible,
                                                                                 PickupSystem.Budget, ScoringSystem.GetScoringSystem("Standard"), true), PlayStatus.DraftFinal, eligibilityOverrides);
                leagueYears.Add(year);
            }

            return(leagueYears);
        }
        public async Task <ClaimResult> PurchaseGame(RoyalePublisher publisher, MasterGameYear masterGame)
        {
            if (publisher.PublisherGames.Count >= MAX_GAMES)
            {
                return(new ClaimResult("Roster is full."));
            }
            if (publisher.PublisherGames.Select(x => x.MasterGame).Contains(masterGame))
            {
                return(new ClaimResult("Publisher already has that game."));
            }
            if (!masterGame.WillReleaseInQuarter(publisher.YearQuarter.YearQuarter))
            {
                return(new ClaimResult("Game will not release this quarter."));
            }
            if (masterGame.MasterGame.IsReleased(_clock.GetCurrentInstant()))
            {
                return(new ClaimResult("Game has been released."));
            }
            if (masterGame.MasterGame.CriticScore.HasValue)
            {
                return(new ClaimResult("Game has a score."));
            }

            var eligibilityErrors = EligibilitySettings.GetRoyaleEligibilitySettings().GameIsEligible(masterGame.MasterGame);

            if (eligibilityErrors.Any())
            {
                return(new ClaimResult("Game is not eligible under Royale rules."));
            }

            var currentBudget = publisher.Budget;
            var gameCost      = masterGame.GetRoyaleGameCost();

            if (currentBudget < gameCost)
            {
                return(new ClaimResult("Not enough budget."));
            }

            RoyalePublisherGame game = new RoyalePublisherGame(publisher.PublisherID, publisher.YearQuarter, masterGame, _clock.GetCurrentInstant(), gameCost, 0m, null);
            await _royaleRepo.PurchaseGame(game);

            return(new ClaimResult());
        }
Esempio n. 13
0
 public EditLeagueYearParameters(FantasyCriticUser manager, Guid leagueID, int year, int standardGames, int gamesToDraft, int counterPicks,
                                 int freeDroppableGames, int willNotReleaseDroppableGames, int willReleaseDroppableGames, bool dropOnlyDraftGames, EligibilityLevel maximumEligibilityLevel, bool allowYearlyInstallments,
                                 bool allowEarlyAccess, bool allowFreeToPlay, bool allowReleasedInternationally, bool allowExpansions, DraftSystem draftSystem,
                                 PickupSystem pickupSystem, ScoringSystem scoringSystem, bool publicLeague)
 {
     Manager                      = manager;
     LeagueID                     = leagueID;
     Year                         = year;
     StandardGames                = standardGames;
     GamesToDraft                 = gamesToDraft;
     CounterPicks                 = counterPicks;
     FreeDroppableGames           = freeDroppableGames;
     WillNotReleaseDroppableGames = willNotReleaseDroppableGames;
     WillReleaseDroppableGames    = willReleaseDroppableGames;
     DropOnlyDraftGames           = dropOnlyDraftGames;
     AllowedEligibilitySettings   = new EligibilitySettings(maximumEligibilityLevel, allowYearlyInstallments, allowEarlyAccess, allowFreeToPlay,
                                                            allowReleasedInternationally, allowExpansions);
     DraftSystem   = draftSystem;
     PickupSystem  = pickupSystem;
     ScoringSystem = scoringSystem;
     PublicLeague  = publicLeague;
 }
        public async Task <ActionResult <List <PossibleRoyaleMasterGameViewModel> > > PossibleMasterGames(string gameName, Guid publisherID)
        {
            Maybe <RoyalePublisher> publisher = await _royaleService.GetPublisher(publisherID);

            if (publisher.HasNoValue)
            {
                return(NotFound());
            }

            var yearQuarter = await _royaleService.GetYearQuarter(publisher.Value.YearQuarter.YearQuarter.Year, publisher.Value.YearQuarter.YearQuarter.Quarter);

            if (yearQuarter.HasNoValue)
            {
                return(BadRequest());
            }

            var masterGames = await _royaleService.GetMasterGamesForYearQuarter(yearQuarter.Value.YearQuarter);

            if (!string.IsNullOrWhiteSpace(gameName))
            {
                masterGames = MasterGameSearching.SearchMasterGameYears(gameName, masterGames);
            }
            else
            {
                masterGames = masterGames
                              .Where(x => x.WillReleaseInQuarter(yearQuarter.Value.YearQuarter))
                              .Where(x => !x.MasterGame.IsReleased(_clock.GetCurrentInstant()))
                              .Where(x => !EligibilitySettings.GetRoyaleEligibilitySettings().GameIsEligible(x.MasterGame).Any())
                              .Take(100)
                              .ToList();
            }

            var viewModels = masterGames.Select(masterGame =>
                                                new PossibleRoyaleMasterGameViewModel(masterGame, _clock, yearQuarter.Value, publisher.Value.PublisherGames.Any(y =>
                                                                                                                                                                y.MasterGame.MasterGame.Equals(masterGame.MasterGame)))).ToList();

            return(viewModels);
        }
Esempio n. 15
0
 public LeagueCreationParameters(FantasyCriticUser manager, string leagueName, int standardGames, int gamesToDraft, int counterPicks,
                                 int freeDroppableGames, int willNotReleaseDroppableGames, int willReleaseDroppableGames, bool dropOnlyDraftGames, int initialYear, EligibilityLevel maximumEligibilityLevel,
                                 bool allowYearlyInstallments, bool allowEarlyAccess, bool allowFreeToPlay, bool allowReleasedInternationally,
                                 bool allowExpansions, bool allowUnannouncedGames, DraftSystem draftSystem, PickupSystem pickupSystem, ScoringSystem scoringSystem, bool publicLeague, bool testLeague)
 {
     Manager                      = manager;
     LeagueName                   = leagueName;
     StandardGames                = standardGames;
     GamesToDraft                 = gamesToDraft;
     CounterPicks                 = counterPicks;
     FreeDroppableGames           = freeDroppableGames;
     WillNotReleaseDroppableGames = willNotReleaseDroppableGames;
     WillReleaseDroppableGames    = willReleaseDroppableGames;
     DropOnlyDraftGames           = dropOnlyDraftGames;
     InitialYear                  = initialYear;
     AllowedEligibilitySettings   = new EligibilitySettings(maximumEligibilityLevel, allowYearlyInstallments, allowEarlyAccess,
                                                            allowFreeToPlay, allowReleasedInternationally, allowExpansions, allowUnannouncedGames);
     DraftSystem   = draftSystem;
     PickupSystem  = pickupSystem;
     ScoringSystem = scoringSystem;
     PublicLeague  = publicLeague;
     TestLeague    = testLeague;
 }
        public EligibilitySettings ToDomain(EligibilityLevel eligibilityLevel)
        {
            var eligibilitySettings = new EligibilitySettings(eligibilityLevel, YearlyInstallment, EarlyAccess, FreeToPlay, ReleasedInternationally, ExpansionPack, UnannouncedGame);

            return(eligibilitySettings);
        }