From 010b7f72ea89a7207e3df1acb97270dac4d1c1d3 Mon Sep 17 00:00:00 2001 From: versx Date: Wed, 28 Oct 2020 23:23:54 -0700 Subject: [PATCH] Fix event Pokemon IV operator check (Thanks petap0w) (#43) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hopefully it works 🤷 😂 🎃 --- src/Data/Subscriptions/SubscriptionProcessor.cs | 5 +++-- src/Net/Webhooks/WebhookController.cs | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Data/Subscriptions/SubscriptionProcessor.cs b/src/Data/Subscriptions/SubscriptionProcessor.cs index c372f1cb..78585cf5 100644 --- a/src/Data/Subscriptions/SubscriptionProcessor.cs +++ b/src/Data/Subscriptions/SubscriptionProcessor.cs @@ -315,14 +315,15 @@ public async Task ProcessPvPSubscription(PokemonData pkmn) } matchesGreat = pkmn.GreatLeague != null && (pkmn.GreatLeague?.Exists(x => subscribedPokemon.League == PvPLeague.Great && - (x.CP ?? 0) >= 1400 && (x.CP ?? 0) <= 1500 && + (x.CP ?? 0) >= Strings.MinimumGreatLeagueCP && (x.CP ?? 0) <= Strings.MaximumGreatLeagueCP && (x.Rank ?? 4096) <= subscribedPokemon.MinimumRank && (x.Percentage ?? 0) * 100 >= subscribedPokemon.MinimumPercent) ?? false); matchesUltra = pkmn.UltraLeague != null && (pkmn.GreatLeague?.Exists(x => subscribedPokemon.League == PvPLeague.Ultra && - (x.CP ?? 0) >= 2400 && (x.CP ?? 0) <= 2500 && + (x.CP ?? 0) >= Strings.MinimumUltraLeagueCP && (x.CP ?? 0) <= Strings.MaximumUltraLeagueCP && (x.Rank ?? 4096) <= subscribedPokemon.MinimumRank && (x.Percentage ?? 0) * 100 >= subscribedPokemon.MinimumPercent) ?? false); + // Check if Pokemon IV stats match any relevant great or ultra league ranks, if not skip. if (!matchesGreat && !matchesUltra) continue; diff --git a/src/Net/Webhooks/WebhookController.cs b/src/Net/Webhooks/WebhookController.cs index 91ab1297..5aafbb3f 100644 --- a/src/Net/Webhooks/WebhookController.cs +++ b/src/Net/Webhooks/WebhookController.cs @@ -247,13 +247,13 @@ private void Http_PokemonReceived(object sender, DataReceivedEventArgs 0) { - //Skip Pokemon if no IV stats. + // Skip Pokemon if no IV stats. if (pkmn.IsMissingStats) return; var iv = PokemonData.GetIV(pkmn.Attack, pkmn.Defense, pkmn.Stamina); - //Skip Pokemon if IV is less than 90%, not 0%, and does not match any PvP league stats. - if ((iv < 90 && iv != 0) || !pkmn.MatchesGreatLeague || !pkmn.MatchesUltraLeague) + // Skip Pokemon if IV is greater than 0%, less than 90%, and does not match any PvP league stats. + if (iv > 0 && iv < 90 && !pkmn.MatchesGreatLeague && !pkmn.MatchesUltraLeague) return; } @@ -475,7 +475,7 @@ private void ProcessPokemon(PokemonData pkmn) if (alarm.Filters.Pokemon.IsPvpGreatLeague && !(pkmn.MatchesGreatLeague && pkmn.GreatLeague.Exists(x => Filters.MatchesPvPRank(x.Rank ?? 4096, alarm.Filters.Pokemon.MinimumRank, alarm.Filters.Pokemon.MaximumRank) - && x.CP >= 1400 && x.CP <= 1500))) + && x.CP >= Strings.MinimumGreatLeagueCP && x.CP <= Strings.MaximumGreatLeagueCP))) { skipGreat = true; } @@ -483,7 +483,7 @@ private void ProcessPokemon(PokemonData pkmn) if (alarm.Filters.Pokemon.IsPvpUltraLeague && !(pkmn.MatchesUltraLeague && pkmn.UltraLeague.Exists(x => Filters.MatchesPvPRank(x.Rank ?? 4096, alarm.Filters.Pokemon.MinimumRank, alarm.Filters.Pokemon.MaximumRank) - && x.CP >= 2400 && x.CP <= 2500))) + && x.CP >= Strings.MinimumUltraLeagueCP && x.CP <= Strings.MaximumUltraLeagueCP))) { skipUltra = true; }