public DropResult CanConditionallyDropGame(PickupBid request, LeagueYear leagueYear, Publisher publisher, Instant?nextBidTime) { List <ClaimError> dropErrors = new List <ClaimError>(); var basicErrors = GetBasicErrors(leagueYear.League, publisher); dropErrors.AddRange(basicErrors); var currentDate = _clock.GetToday(); var dateOfPotentialAcquisition = currentDate; if (nextBidTime.HasValue) { dateOfPotentialAcquisition = nextBidTime.Value.ToEasternDate(); } if (request.ConditionalDropPublisherGame?.MasterGame is null) { throw new Exception($"Invalid conditional drop for bid: {request.BidID}"); } var masterGameErrors = GetGenericSlotMasterGameErrors(leagueYear, request.ConditionalDropPublisherGame.MasterGame.MasterGame, leagueYear.Year, true, currentDate, dateOfPotentialAcquisition, false, false, false); dropErrors.AddRange(masterGameErrors); //Drop limits var publisherGame = publisher.GetPublisherGameByPublisherGameID(request.ConditionalDropPublisherGame.PublisherGameID); if (publisherGame is null) { return(new DropResult(Result.Failure("Cannot drop a game that you do not have"))); } if (dropErrors.Any()) { return(new DropResult(Result.Failure("Game is no longer eligible for dropping."))); } bool gameWasDrafted = publisherGame.OverallDraftPosition.HasValue; if (!gameWasDrafted && leagueYear.Options.DropOnlyDraftGames) { return(new DropResult(Result.Failure("You can only drop games that you drafted due to your league settings."))); } var otherPublishers = leagueYear.GetAllPublishersExcept(publisher); bool gameWasCounterPicked = otherPublishers .SelectMany(x => x.PublisherGames) .Where(x => x.CounterPick) .ContainsGame(request.ConditionalDropPublisherGame.MasterGame.MasterGame); if (gameWasCounterPicked && leagueYear.Options.CounterPicksBlockDrops) { return(new DropResult(Result.Failure("You cannot drop that game because it was counter picked."))); } bool gameWillRelease = publisherGame.WillRelease(); var dropResult = publisher.CanDropGame(gameWillRelease, leagueYear.Options); return(new DropResult(dropResult)); }
public DropResult CanDropGame(DropRequest request, LeagueYear leagueYear, Publisher publisher) { List <ClaimError> dropErrors = new List <ClaimError>(); var basicErrors = GetBasicErrors(leagueYear.League, publisher); dropErrors.AddRange(basicErrors); var currentDate = _clock.GetToday(); var masterGameErrors = GetGenericSlotMasterGameErrors(leagueYear, request.MasterGame, leagueYear.Year, true, currentDate, currentDate, false, false, false); dropErrors.AddRange(masterGameErrors); //Drop limits var publisherGame = publisher.GetPublisherGame(request.MasterGame); if (publisherGame is null) { return(new DropResult(Result.Failure("Cannot drop a game that you do not have"))); } if (dropErrors.Any()) { return(new DropResult(Result.Failure("Game is no longer eligible for dropping."))); } bool gameWasDrafted = publisherGame.OverallDraftPosition.HasValue; if (!gameWasDrafted && leagueYear.Options.DropOnlyDraftGames) { return(new DropResult(Result.Failure("You can only drop games that you drafted due to your league settings."))); } var otherPublishers = leagueYear.GetAllPublishersExcept(publisher); bool gameWasCounterPicked = otherPublishers .SelectMany(x => x.PublisherGames) .Where(x => x.CounterPick) .ContainsGame(request.MasterGame); if (gameWasCounterPicked && leagueYear.Options.CounterPicksBlockDrops) { return(new DropResult(Result.Failure("You cannot drop that game because it was counter picked."))); } bool gameWillRelease = publisherGame.WillRelease(); var dropResult = publisher.CanDropGame(gameWillRelease, leagueYear.Options); return(new DropResult(dropResult)); }
public DropResult CanDropGame(DropRequest request, IEnumerable <SupportedYear> supportedYears, LeagueYear leagueYear, Publisher publisher, IEnumerable <Publisher> otherPublishers) { List <ClaimError> dropErrors = new List <ClaimError>(); var basicErrors = GetBasicErrors(request.Publisher.LeagueYear.League, publisher, supportedYears); dropErrors.AddRange(basicErrors); var masterGameErrors = GetMasterGameErrors(leagueYear, request.MasterGame, leagueYear.Year, false, true, null); dropErrors.AddRange(masterGameErrors); //Drop limits var publisherGame = publisher.GetPublisherGame(request.MasterGame); if (publisherGame.HasNoValue) { return(new DropResult(Result.Failure("Cannot drop a game that you do not have"), false)); } bool gameWillRelease = publisherGame.Value.WillRelease(); if (dropErrors.Any()) { return(new DropResult(Result.Failure("Game is no longer eligible for dropping."), !gameWillRelease)); } bool gameWasDrafted = publisherGame.Value.OverallDraftPosition.HasValue; if (!gameWasDrafted && leagueYear.Options.DropOnlyDraftGames) { return(new DropResult(Result.Failure("You can only drop games that you drafted due to your league settings."), false)); } bool gameWasCounterPicked = otherPublishers .SelectMany(x => x.PublisherGames) .Where(x => x.CounterPick) .ContainsGame(request.MasterGame); if (gameWasCounterPicked && leagueYear.Options.CounterPicksBlockDrops) { return(new DropResult(Result.Failure("You cannot drop that game because it was counter picked."), false)); } var dropResult = publisher.CanDropGame(gameWillRelease); return(new DropResult(dropResult, !gameWillRelease)); }