public async Task <Result> SellGame(RoyalePublisher publisher, RoyalePublisherGame publisherGame) { var currentDate = _clock.GetToday(); if (publisherGame.MasterGame.MasterGame.IsReleased(currentDate)) { return(Result.Failure("That game has already been released.")); } if (publisherGame.MasterGame.MasterGame.CriticScore.HasValue) { return(Result.Failure("That game already has a score.")); } if (!publisher.PublisherGames.Contains(publisherGame)) { return(Result.Failure("You don't have that game.")); } var masterGameTags = await _masterGameRepo.GetMasterGameTags(); var currentlyInEligible = publisherGame.CalculateIsCurrentlyIneligible(masterGameTags); await _royaleRepo.SellGame(publisherGame, currentlyInEligible); return(Result.Success()); }
public RoyalePublisherGameEntity(RoyalePublisherGame domainPublisherGame) { PublisherID = domainPublisherGame.PublisherID; MasterGameID = domainPublisherGame.MasterGame.MasterGame.MasterGameID; Timestamp = domainPublisherGame.Timestamp.ToDateTimeUtc(); AmountSpent = domainPublisherGame.AmountSpent; AdvertisingMoney = domainPublisherGame.AdvertisingMoney; FantasyPoints = domainPublisherGame.FantasyPoints; }
public RoyalePublisherGameViewModel(RoyalePublisherGame domain, IClock clock) { PublisherID = domain.PublisherID; YearQuarter = new RoyaleYearQuarterViewModel(domain.YearQuarter); MasterGame = new MasterGameYearViewModel(domain.MasterGame, clock); Locked = domain.IsLocked(clock); Timestamp = domain.Timestamp; AmountSpent = domain.AmountSpent; AdvertisingMoney = domain.AdvertisingMoney; FantasyPoints = domain.FantasyPoints; }
public async Task <ClaimResult> PurchaseGame(RoyalePublisher publisher, MasterGameYear masterGame) { if (publisher.PublisherGames.Count >= MAX_GAMES) { return(new ClaimResult("Roster is full.", null)); } if (publisher.PublisherGames.Select(x => x.MasterGame).Contains(masterGame)) { return(new ClaimResult("Publisher already has that game.", null)); } if (!masterGame.WillReleaseInQuarter(publisher.YearQuarter.YearQuarter)) { return(new ClaimResult("Game will not release this quarter.", null)); } var now = _clock.GetCurrentInstant(); var currentDate = now.ToEasternDate(); if (masterGame.MasterGame.IsReleased(currentDate)) { return(new ClaimResult("Game has been released.", null)); } if (masterGame.MasterGame.CriticScore.HasValue) { return(new ClaimResult("Game has a score.", null)); } var masterGameTags = await _masterGameRepo.GetMasterGameTags(); var eligibilityErrors = LeagueTagExtensions.GetRoyaleClaimErrors(masterGameTags, masterGame.MasterGame, currentDate); if (eligibilityErrors.Any()) { return(new ClaimResult("Game is not eligible under Royale rules.", null)); } var currentBudget = publisher.Budget; var gameCost = masterGame.GetRoyaleGameCost(); if (currentBudget < gameCost) { return(new ClaimResult("Not enough budget.", null)); } RoyalePublisherGame game = new RoyalePublisherGame(publisher.PublisherID, publisher.YearQuarter, masterGame, now, gameCost, 0m, null); await _royaleRepo.PurchaseGame(game); var nextSlot = publisher.PublisherGames.Count; return(new ClaimResult(nextSlot)); }
public RoyalePublisherGameViewModel(RoyalePublisherGame domain, LocalDate currentDate, IEnumerable <MasterGameTag> allMasterGameTags) { PublisherID = domain.PublisherID; YearQuarter = new RoyaleYearQuarterViewModel(domain.YearQuarter); MasterGame = new MasterGameYearViewModel(domain.MasterGame, currentDate); Locked = domain.IsLocked(currentDate, allMasterGameTags); Timestamp = domain.Timestamp; AmountSpent = domain.AmountSpent; AdvertisingMoney = domain.AdvertisingMoney; FantasyPoints = domain.FantasyPoints; CurrentlyIneligible = domain.CalculateIsCurrentlyIneligible(allMasterGameTags); RefundAmount = AmountSpent; if (!CurrentlyIneligible) { RefundAmount /= 2; } }
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()); }
public async Task <Result> SellGame(RoyalePublisher publisher, RoyalePublisherGame publisherGame) { if (publisherGame.MasterGame.MasterGame.IsReleased(_clock.GetCurrentInstant())) { return(Result.Fail("That game has already been released.")); } if (publisherGame.MasterGame.MasterGame.CriticScore.HasValue) { return(Result.Fail("That game already has a score.")); } if (!publisher.PublisherGames.Contains(publisherGame)) { return(Result.Fail("You don't have that game.")); } await _royaleRepo.SellGame(publisherGame); return(Result.Ok()); }
public async Task <Result> SetAdvertisingMoney(RoyalePublisher publisher, RoyalePublisherGame publisherGame, decimal advertisingMoney) { var currentDate = _clock.GetToday(); if (publisherGame.MasterGame.MasterGame.IsReleased(currentDate)) { return(Result.Failure("That game has already been released.")); } if (publisherGame.MasterGame.MasterGame.CriticScore.HasValue) { return(Result.Failure("That game already has a score.")); } if (!publisher.PublisherGames.Contains(publisherGame)) { return(Result.Failure("You don't have that game.")); } decimal newDollarsToSpend = advertisingMoney - publisherGame.AdvertisingMoney; if (publisher.Budget < newDollarsToSpend) { return(Result.Failure("You don't have enough money.")); } if (advertisingMoney < 0m) { return(Result.Failure("You can't allocate negative dollars in advertising money.")); } if (advertisingMoney > 10m) { return(Result.Failure("You can't allocate more than 10 dollars in advertising money.")); } await _royaleRepo.SetAdvertisingMoney(publisherGame, advertisingMoney); return(Result.Success()); }
public Task SetAdvertisingMoney(RoyalePublisherGame publisherGame, decimal advertisingMoney) { throw new NotImplementedException(); }
public Task SellGame(RoyalePublisherGame publisherGame) { throw new NotImplementedException(); }
public Task PurchaseGame(RoyalePublisherGame game) { throw new NotImplementedException(); }