Exemple #1
0
        protected override decimal GetPointsForScore(PublisherGame publisherGame, decimal?criticScore, LeagueWideValues leagueWideValues)
        {
            if (criticScore.HasValue)
            {
                decimal fantasyPoints      = 0m;
                decimal criticPointsOver90 = (criticScore.Value - 90);
                if (criticPointsOver90 > 0)
                {
                    fantasyPoints += criticPointsOver90;
                }

                decimal criticPointsOver70 = (criticScore.Value - 70);
                fantasyPoints += criticPointsOver70;

                if (publisherGame.CounterPick)
                {
                    fantasyPoints *= -1;
                }

                return(fantasyPoints);
            }

            if (publisherGame.CounterPick)
            {
                return(leagueWideValues.AverageCounterPickPoints);
            }

            return(leagueWideValues.AverageStandardGamePoints);
        }
    public FormerPublisherGame ToDomain(MasterGameYear?masterGame)
    {
        PublisherGame domain = new PublisherGame(PublisherID, PublisherGameID, GameName, Timestamp, CounterPick,
                                                 ManualCriticScore, ManualWillNotRelease, FantasyPoints, masterGame, 0, DraftPosition, OverallDraftPosition, BidAmount, AcquiredInTradeID);

        return(new FormerPublisherGame(domain, RemovedTimestamp, RemovedNote));
    }
Exemple #3
0
        public async Task <Maybe <PublisherGame> > GetPublisherGame(Guid publisherGameID)
        {
            var query = new
            {
                publisherGameID
            };

            using (var connection = new MySqlConnection(_connectionString))
            {
                PublisherGameEntity gameEntity = await connection.QueryFirstOrDefaultAsync <PublisherGameEntity>(
                    "select * from tblpublishergame where tblpublishergame.PublisherGameID = @publisherGameID;",
                    query);

                if (gameEntity is null)
                {
                    return(Maybe <PublisherGame> .None);
                }

                var publisher = await GetPublisher(gameEntity.PublisherID);

                if (publisher.HasNoValue)
                {
                    throw new Exception($"Publisher cannot be found: {gameEntity.PublisherID}");
                }

                Maybe <MasterGameYear> masterGame = null;
                if (gameEntity.MasterGameID.HasValue)
                {
                    masterGame = await GetMasterGameYear(gameEntity.MasterGameID.Value, publisher.Value.Year);
                }

                PublisherGame publisherGame = gameEntity.ToDomain(masterGame, publisher.Value.Year);
                return(publisherGame);
            }
        }
        public PublisherGame ToDomain(Maybe <MasterGameYear> masterGame)
        {
            Instant       instant = LocalDateTime.FromDateTime(Timestamp).InZoneStrictly(DateTimeZone.Utc).ToInstant();
            PublisherGame domain  = new PublisherGame(PublisherID, PublisherGameID, GameName, instant, CounterPick, ManualCriticScore, FantasyPoints, masterGame, DraftPosition, OverallDraftPosition);

            return(domain);
        }
Exemple #5
0
        protected override decimal?GetPointsInternal(PublisherGame publisherGame, IClock clock, LeagueWideValues leagueWideValues)
        {
            if (publisherGame.MasterGame.HasNoValue)
            {
                return(null);
            }

            if (!publisherGame.WillRelease())
            {
                return(0m);
            }

            if (!publisherGame.MasterGame.Value.MasterGame.IsReleased(clock))
            {
                return(null);
            }

            decimal?possibleManualScore = publisherGame.ManualCriticScore;

            if (possibleManualScore.HasValue)
            {
                return(GetPointsForScore(publisherGame, possibleManualScore.Value, leagueWideValues));
            }

            decimal?possibleCriticScore = publisherGame.MasterGame.Value.MasterGame.CriticScore;

            if (!possibleCriticScore.HasValue)
            {
                return(0m);
            }

            return(GetPointsForScore(publisherGame, possibleCriticScore.Value, leagueWideValues));
        }
        private static BidProcessingResults GetProcessingResults(IEnumerable <PickupBid> successBids, IEnumerable <FailedPickupBid> failedBids, IEnumerable <Publisher> publishers, IClock clock)
        {
            List <Publisher>     updatedPublishers = publishers.ToList();
            List <PublisherGame> gamesToAdd        = new List <PublisherGame>();
            List <LeagueAction>  leagueActions     = new List <LeagueAction>();

            foreach (var successBid in successBids)
            {
                PublisherGame newPublisherGame = new PublisherGame(successBid.Publisher.PublisherID, Guid.NewGuid(), successBid.MasterGame.GameName, clock.GetCurrentInstant(),
                                                                   false, null, null, new MasterGameYear(successBid.MasterGame, successBid.Publisher.LeagueYear.Year), null, null);
                gamesToAdd.Add(newPublisherGame);
                var affectedPublisher = updatedPublishers.Single(x => x.PublisherID == successBid.Publisher.PublisherID);
                affectedPublisher.AcquireGame(newPublisherGame, successBid.BidAmount);

                LeagueAction leagueAction = new LeagueAction(successBid, clock.GetCurrentInstant());
                leagueActions.Add(leagueAction);
            }

            foreach (var failedBid in failedBids)
            {
                LeagueAction leagueAction = new LeagueAction(failedBid, clock.GetCurrentInstant());
                leagueActions.Add(leagueAction);
            }

            var simpleFailedBids = failedBids.Select(x => x.PickupBid);

            BidProcessingResults bidProcessingResults = new BidProcessingResults(successBids, simpleFailedBids, leagueActions, updatedPublishers, gamesToAdd);

            return(bidProcessingResults);
        }
    public void DropGameForPublisher(Publisher publisherToEdit, PublisherGame publisherGame, LeagueOptions leagueOptions)
    {
        if (publisherGame.WillRelease())
        {
            if (leagueOptions.WillReleaseDroppableGames == -1 || leagueOptions.WillReleaseDroppableGames > publisherToEdit.WillReleaseGamesDropped)
            {
                UpdatePublisher(publisherToEdit, null, publisherGame, 0, DropType.WillRelease);
                return;
            }
            if (leagueOptions.FreeDroppableGames == -1 || leagueOptions.FreeDroppableGames > publisherToEdit.FreeGamesDropped)
            {
                UpdatePublisher(publisherToEdit, null, publisherGame, 0, DropType.Free);
                return;
            }
            throw new Exception("Publisher cannot drop any more 'Will Release' games");
        }

        if (leagueOptions.WillNotReleaseDroppableGames == -1 || leagueOptions.WillNotReleaseDroppableGames > publisherToEdit.WillNotReleaseGamesDropped)
        {
            UpdatePublisher(publisherToEdit, null, publisherGame, 0, DropType.WillNotRelease);
            return;
        }
        if (leagueOptions.FreeDroppableGames == -1 || leagueOptions.FreeDroppableGames > publisherToEdit.FreeGamesDropped)
        {
            UpdatePublisher(publisherToEdit, null, publisherGame, 0, DropType.Free);
            return;
        }
        throw new Exception("Publisher cannot drop any more 'Will Not Release' games");
    }
Exemple #8
0
        public async Task <ClaimResult> ClaimGame(ClaimGameDomainRequest request, bool managerAction, bool draft, IReadOnlyList <Publisher> publishersForYear)
        {
            Maybe <MasterGameYear> masterGameYear = Maybe <MasterGameYear> .None;

            if (request.MasterGame.HasValue)
            {
                masterGameYear = new MasterGameYear(request.MasterGame.Value, request.Publisher.LeagueYear.Year);
            }

            PublisherGame playerGame = new PublisherGame(request.Publisher.PublisherID, Guid.NewGuid(), request.GameName, _clock.GetCurrentInstant(), request.CounterPick, null, null,
                                                         masterGameYear, request.DraftPosition, request.OverallDraftPosition);

            var supportedYears = await _fantasyCriticRepo.GetSupportedYears();

            LeagueYear leagueYear = request.Publisher.LeagueYear;

            ClaimResult claimResult = CanClaimGame(request, supportedYears, leagueYear, publishersForYear, null, false);

            if (!claimResult.Success)
            {
                return(claimResult);
            }

            LeagueAction leagueAction = new LeagueAction(request, _clock.GetCurrentInstant(), managerAction, draft, request.AutoDraft);
            await _fantasyCriticRepo.AddLeagueAction(leagueAction);

            await _fantasyCriticRepo.AddPublisherGame(playerGame);

            return(claimResult);
        }
Exemple #9
0
    public PublisherGame ToDomain(MasterGameYear?masterGame)
    {
        PublisherGame domain = new PublisherGame(PublisherID, PublisherGameID, GameName, Timestamp, CounterPick,
                                                 ManualCriticScore, ManualWillNotRelease, FantasyPoints, masterGame, SlotNumber, DraftPosition, OverallDraftPosition, BidAmount, AcquiredInTradeID);

        return(domain);
    }
Exemple #10
0
 public AssociateGameDomainRequest(Publisher publisher, PublisherGame publisherGame, MasterGame masterGame, bool managerOverride)
 {
     Publisher       = publisher;
     PublisherGame   = publisherGame;
     MasterGame      = masterGame;
     ManagerOverride = managerOverride;
 }
 public AssociateGameDomainRequest(LeagueYear leagueYear, Publisher publisher, PublisherGame publisherGame, MasterGame masterGame, bool managerOverride)
 {
     LeagueYear      = leagueYear;
     Publisher       = publisher;
     PublisherGame   = publisherGame;
     MasterGame      = masterGame;
     ManagerOverride = managerOverride;
 }
Exemple #12
0
 public async Task ManuallyScoreGame(PublisherGame publisherGame, decimal?manualCriticScore)
 {
     using (var connection = new MySqlConnection(_connectionString))
     {
         await connection.ExecuteAsync("update tblpublishergame SET ManualCriticScore = @manualCriticScore where PublisherGameID = @publisherGameID;",
                                       new { publisherGameID = publisherGame.PublisherGameID, manualCriticScore });
     }
 }
Exemple #13
0
        public decimal GetProjectedPointsForGame(PublisherGame publisherGame, LeagueWideValues leagueWideValues)
        {
            if (publisherGame.FantasyPoints.HasValue)
            {
                return(publisherGame.FantasyPoints.Value);
            }

            return(GetPointsForScore(publisherGame, null, leagueWideValues));
        }
Exemple #14
0
        public async Task AddPublisherGame(Publisher publisher, PublisherGame publisherGame)
        {
            PublisherGameEntity entity = new PublisherGameEntity(publisher, publisherGame);

            using (var connection = new MySqlConnection(_connectionString))
            {
                await connection.ExecuteAsync(
                    "insert into tblpublishergame (PublisherGameID,PublisherID,GameName,Timestamp,CounterPick,ManualCriticScore,FantasyPoints,MasterGameID,DraftPosition,OverallDraftPosition) VALUES " +
                    "(@PublisherGameID,@PublisherID,@GameName,@Timestamp,@CounterPick,@ManualCriticScore,@FantasyPoints,@MasterGameID,@DraftPosition,@OverallDraftPosition);",
                    entity);
            }
        }
Exemple #15
0
 public async Task AssociatePublisherGame(Publisher publisher, PublisherGame publisherGame, MasterGame masterGame)
 {
     using (var connection = new MySqlConnection(_connectionString))
     {
         await connection.ExecuteAsync("update tblpublishergame set MasterGameID = @masterGameID where PublisherGameID = @publisherGameID",
                                       new
         {
             masterGameID    = masterGame.MasterGameID,
             publisherGameID = publisherGame.PublisherGameID
         });
     }
 }
        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");

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

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

            Assert.AreEqual(null, fantasyPoints);
        }
        public static bool ContainsGame(this IEnumerable <PublisherGame> games, PublisherGame game)
        {
            bool containsGame;

            if (game.MasterGame.HasValue)
            {
                containsGame = games.Any(x => x.MasterGame.HasValue && game.MasterGame.Value.MasterGame.MasterGameID == x.MasterGame.Value.MasterGame.MasterGameID);
            }
            else
            {
                containsGame = games.Any(x => x.GameName == game.GameName);
            }

            return(containsGame);
        }
        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);
        }
        public PublisherGameEntity(PublisherGame publisherGame)
        {
            PublisherGameID   = publisherGame.PublisherGameID;
            PublisherID       = publisherGame.PublisherID;
            GameName          = publisherGame.GameName;
            Timestamp         = publisherGame.Timestamp.ToDateTimeUtc();
            CounterPick       = publisherGame.CounterPick;
            ManualCriticScore = publisherGame.ManualCriticScore;
            FantasyPoints     = publisherGame.FantasyPoints;

            DraftPosition        = publisherGame.DraftPosition;
            OverallDraftPosition = publisherGame.OverallDraftPosition;
            if (publisherGame.MasterGame.HasValue)
            {
                MasterGameID = publisherGame.MasterGame.Value.MasterGame.MasterGameID;
            }
        }
    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);
    }
        public void Under70ScoreTest()
        {
            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");

            MasterGame masterGame = new MasterGame(Guid.NewGuid(), "", "",
                                                   new LocalDate(2018, 4, 20), new LocalDate(2018, 4, 20), null, null, new LocalDate(2018, 4, 20),
                                                   null, 65.8559m, "", "", fakeClock.GetCurrentInstant(), 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), null, null);

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

            Assert.AreEqual(-4.1441m, fantasyPoints);
        }
        public void ManualScoreTest()
        {
            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 diminishingScoring = ScoringSystem.GetScoringSystem("Diminishing");

            MasterGame masterGame = new MasterGame(Guid.NewGuid(), "", "",
                                                   new LocalDate(2018, 7, 13), new LocalDate(2018, 7, 13), null, null, new LocalDate(2018, 7, 13),
                                                   null, 84.8095m, "", "", fakeClock.GetCurrentInstant(), false, false, false,
                                                   fakeClock.GetCurrentInstant(), new List <MasterSubGame>(), new List <MasterGameTag>());

            PublisherGame testGame = new PublisherGame(Guid.NewGuid(), Guid.NewGuid(), "", pickupTime, false, 83.8095m, false, null, new MasterGameYear(masterGame, 2018), null, null);

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

            Assert.AreEqual(13.8095m, fantasyPoints);
        }
        public async Task <DropResult> MakeDropRequest(Publisher publisher, PublisherGame publisherGame)
        {
            if (publisherGame.CounterPick)
            {
                return(new DropResult(Result.Failure("You can't drop a counterpick."), false));
            }

            if (publisherGame.MasterGame.HasNoValue)
            {
                return(new DropResult(Result.Failure("You can't drop a game that is not linked to a master game. Please see the FAQ section on dropping games."), false));
            }

            MasterGame masterGame = publisherGame.MasterGame.Value.MasterGame;
            IReadOnlyList <DropRequest> dropRequests = await _fantasyCriticRepo.GetActiveDropRequests(publisher);

            bool alreadyDropping = dropRequests.Select(x => x.MasterGame.MasterGameID).Contains(masterGame.MasterGameID);

            if (alreadyDropping)
            {
                return(new DropResult(Result.Failure("You cannot have two active drop requests for the same game."), false));
            }

            DropRequest dropRequest    = new DropRequest(Guid.NewGuid(), publisher, publisher.LeagueYear, masterGame, _clock.GetCurrentInstant(), null);
            var         supportedYears = await _fantasyCriticRepo.GetSupportedYears();

            var publishersInLeague = await _fantasyCriticRepo.GetPublishersInLeagueForYear(publisher.LeagueYear);

            var otherPublishers = publishersInLeague.Except(new List <Publisher>()
            {
                publisher
            });

            var dropResult = CanDropGame(dropRequest, supportedYears, publisher.LeagueYear, publisher, otherPublishers);

            if (dropResult.Result.IsFailure)
            {
                return(dropResult);
            }

            await _fantasyCriticRepo.CreateDropRequest(dropRequest);

            return(dropResult);
        }
        public async Task <ClaimResult> ClaimGame(ClaimGameDomainRequest request)
        {
            PublisherGame playerGame = new PublisherGame(Guid.NewGuid(), request.GameName, _clock.GetCurrentInstant(), request.CounterPick, null, null,
                                                         new MasterGameYear(request.MasterGame.Value, request.Publisher.Year), request.DraftPosition, request.OverallDraftPosition, request.Publisher.Year);

            ClaimResult claimResult = await CanClaimGame(request);

            if (!claimResult.Success)
            {
                return(claimResult);
            }

            LeagueAction leagueAction = new LeagueAction(request, _clock.GetCurrentInstant());
            await _fantasyCriticRepo.AddLeagueAction(leagueAction);

            await _fantasyCriticRepo.AddPublisherGame(request.Publisher, playerGame);

            return(claimResult);
        }
Exemple #25
0
    public PublisherGameViewModel(PublisherGame publisherGame, LocalDate currentDate, bool counterPicked, bool counterPicksBlockDrops)
    {
        PublisherGameID = publisherGame.PublisherGameID;
        GameName        = publisherGame.GameName;

        Timestamp     = publisherGame.Timestamp.ToDateTimeUtc();
        CounterPick   = publisherGame.CounterPick;
        FantasyPoints = publisherGame.FantasyPoints;

        Linked = publisherGame.MasterGame is not null;
        if (Linked)
        {
            GameName             = publisherGame.MasterGame !.MasterGame.GameName;
            EstimatedReleaseDate = publisherGame.MasterGame.MasterGame.EstimatedReleaseDate;
            if (publisherGame.MasterGame.MasterGame.ReleaseDate.HasValue)
            {
                ReleaseDate = publisherGame.MasterGame.MasterGame.ReleaseDate.Value.ToDateTimeUnspecified();
            }

            CriticScore = publisherGame.MasterGame.MasterGame.CriticScore;
            Released    = publisherGame.MasterGame.MasterGame.IsReleased(currentDate);
            if (publisherGame.MasterGame is not null)
            {
                MasterGame = new MasterGameYearViewModel(publisherGame.MasterGame, currentDate);
            }
        }

        if (publisherGame.ManualCriticScore.HasValue)
        {
            CriticScore       = publisherGame.ManualCriticScore;
            ManualCriticScore = true;
        }

        WillRelease          = publisherGame.WillRelease();
        ManualWillNotRelease = publisherGame.ManualWillNotRelease;
        OverallDraftPosition = publisherGame.OverallDraftPosition;
        BidAmount            = publisherGame.BidAmount;
        AcquiredInTradeID    = publisherGame.AcquiredInTradeID;
        SlotNumber           = publisherGame.SlotNumber;
        CounterPicked        = counterPicked;
        DropBlocked          = counterPicked && counterPicksBlockDrops;
    }
Exemple #26
0
    public PublisherGameEntity(PublisherGame publisherGame)
    {
        PublisherGameID      = publisherGame.PublisherGameID;
        PublisherID          = publisherGame.PublisherID;
        GameName             = publisherGame.GameName;
        Timestamp            = publisherGame.Timestamp;
        CounterPick          = publisherGame.CounterPick;
        ManualCriticScore    = publisherGame.ManualCriticScore;
        ManualWillNotRelease = publisherGame.ManualWillNotRelease;
        FantasyPoints        = publisherGame.FantasyPoints;

        SlotNumber           = publisherGame.SlotNumber;
        DraftPosition        = publisherGame.DraftPosition;
        OverallDraftPosition = publisherGame.OverallDraftPosition;
        if (publisherGame.MasterGame is not null)
        {
            MasterGameID = publisherGame.MasterGame.MasterGame.MasterGameID;
        }

        BidAmount         = publisherGame.BidAmount;
        AcquiredInTradeID = publisherGame.AcquiredInTradeID;
    }
        public PublisherGameViewModel(PublisherGame publisherGame, IClock clock, ScoringSystem scoringSystem, SystemWideValues systemWideValues)
        {
            PublisherGameID = publisherGame.PublisherGameID;
            GameName        = publisherGame.GameName;

            Timestamp     = publisherGame.Timestamp.ToDateTimeUtc();
            CounterPick   = publisherGame.CounterPick;
            FantasyPoints = publisherGame.FantasyPoints;
            SimpleProjectedFantasyPoints   = publisherGame.GetProjectedOrRealFantasyPoints(scoringSystem, systemWideValues, true, clock);
            AdvancedProjectedFantasyPoints = publisherGame.GetProjectedOrRealFantasyPoints(scoringSystem, systemWideValues, false, clock);

            Linked = publisherGame.MasterGame.HasValue;
            if (Linked)
            {
                GameName             = publisherGame.MasterGame.Value.MasterGame.GameName;
                EstimatedReleaseDate = publisherGame.MasterGame.Value.MasterGame.EstimatedReleaseDate;
                if (publisherGame.MasterGame.Value.MasterGame.ReleaseDate.HasValue)
                {
                    ReleaseDate = publisherGame.MasterGame.Value.MasterGame.ReleaseDate.Value.ToDateTimeUnspecified();
                }

                CriticScore = publisherGame.MasterGame.Value.MasterGame.CriticScore;
                Released    = publisherGame.MasterGame.Value.MasterGame.IsReleased(clock.GetCurrentInstant());
                if (publisherGame.MasterGame.HasValue)
                {
                    MasterGame = new MasterGameYearViewModel(publisherGame.MasterGame.Value, clock);
                }
            }

            if (publisherGame.ManualCriticScore.HasValue)
            {
                CriticScore       = publisherGame.ManualCriticScore;
                ManualCriticScore = true;
            }

            WillRelease          = publisherGame.WillRelease();
            ManualWillNotRelease = publisherGame.ManualWillNotRelease;
        }
Exemple #28
0
        public PublisherGameViewModel(PublisherGame publisherGame, IClock clock)
        {
            PublisherGameID = publisherGame.PublisherGameID;
            GameName        = publisherGame.GameName;
            Timestamp       = publisherGame.Timestamp.ToDateTimeUtc();

            CounterPick = publisherGame.CounterPick;

            FantasyPoints = publisherGame.FantasyPoints;

            Linked = publisherGame.MasterGame.HasValue;
            if (Linked)
            {
                GameName             = publisherGame.MasterGame.Value.MasterGame.GameName;
                EstimatedReleaseDate = publisherGame.MasterGame.Value.MasterGame.EstimatedReleaseDate;
                if (publisherGame.MasterGame.Value.MasterGame.ReleaseDate.HasValue)
                {
                    ReleaseDate = publisherGame.MasterGame.Value.MasterGame.ReleaseDate.Value.ToDateTimeUnspecified();
                }

                CriticScore  = publisherGame.MasterGame.Value.MasterGame.CriticScore;
                Released     = publisherGame.MasterGame.Value.MasterGame.IsReleased(clock);
                MasterGameID = publisherGame.MasterGame.Value.MasterGame.MasterGameID;

                if (publisherGame.ManualCriticScore.HasValue)
                {
                    CriticScore       = publisherGame.ManualCriticScore;
                    ManualCriticScore = true;
                }

                PercentStandardGame  = publisherGame.MasterGame.Value.PercentStandardGame;
                PercentCounterPick   = publisherGame.MasterGame.Value.PercentCounterPick;
                AverageDraftPosition = publisherGame.MasterGame.Value.AverageDraftPosition;
            }

            WillRelease = publisherGame.WillRelease();
        }
        private async Task ProcessSuccessfulAndFailedBids(IEnumerable <PickupBid> successBids, IEnumerable <FailedPickupBid> failedBids)
        {
            foreach (var successBid in successBids)
            {
                await _fantasyCriticRepo.MarkBidStatus(successBid, true);

                PublisherGame newPublisherGame = new PublisherGame(Guid.NewGuid(), successBid.MasterGame.GameName, _clock.GetCurrentInstant(), false, null, null,
                                                                   new MasterGameYear(successBid.MasterGame, successBid.Publisher.Year), null, null, successBid.Publisher.Year);
                await _fantasyCriticRepo.AddPublisherGame(successBid.Publisher, newPublisherGame);

                await _fantasyCriticRepo.SpendBudget(successBid.Publisher, successBid.BidAmount);

                LeagueAction leagueAction = new LeagueAction(successBid, _clock.GetCurrentInstant());
                await _fantasyCriticRepo.AddLeagueAction(leagueAction);
            }

            foreach (var failedBid in failedBids)
            {
                await _fantasyCriticRepo.MarkBidStatus(failedBid.PickupBid, false);

                LeagueAction leagueAction = new LeagueAction(failedBid, _clock.GetCurrentInstant());
                await _fantasyCriticRepo.AddLeagueAction(leagueAction);
            }
        }
Exemple #30
0
 public PublisherSlot GetWithReplacedGame(PublisherGame newPublisherGame)
 {
     return(new PublisherSlot(SlotNumber, OverallSlotNumber, CounterPick, SpecialGameSlot, newPublisherGame));
 }