Skip to content

Commit

Permalink
Fix event Pokemon IV operator check (Thanks petap0w) (#43)
Browse files Browse the repository at this point in the history
Hopefully it works 🤷 😂 🎃
  • Loading branch information
versx authored Oct 29, 2020
1 parent cef3d96 commit 010b7f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/Data/Subscriptions/SubscriptionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions src/Net/Webhooks/WebhookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ private void Http_PokemonReceived(object sender, DataReceivedEventArgs<PokemonDa
// Check if Pokemon is in event Pokemon list
if (_config.EventPokemonIds.Contains(pkmn.Id) && _config.EventPokemonIds.Count > 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;
}

Expand Down Expand Up @@ -475,15 +475,15 @@ 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;
}

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;
}
Expand Down

0 comments on commit 010b7f7

Please sign in to comment.