Skip to content

Commit

Permalink
Check if each individual value contains instead of checking exact val…
Browse files Browse the repository at this point in the history
…ues incase of iv_list values having `\r` with one of the IVs which would cause a failed check. (#156)
  • Loading branch information
versx authored May 28, 2021
1 parent ba1030f commit de95284
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Data/Subscriptions/SubscriptionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ GeofenceItem GetGeofence(ulong guildId)
//var matchesCP = _whm.Filters.MatchesCpFilter(pkmn.CP, subscribedPokemon.MinimumCP);
matchesLvl = Filters.MatchesLvl(pkmn.Level, (uint)subscribedPokemon.MinimumLevel, (uint)subscribedPokemon.MaximumLevel);
matchesGender = Filters.MatchesGender(pkmn.Gender, subscribedPokemon.Gender);
matchesIVList = subscribedPokemon.IVList?.Contains($"{pkmn.Attack}/{pkmn.Defense}/{pkmn.Stamina}") ?? false;
matchesIVList = subscribedPokemon.IVList?.Exists(x => x.Contains($"{pkmn.Attack}/{pkmn.Defense}/{pkmn.Stamina}")) ?? false;

if (!(
(!subscribedPokemon.HasStats && matchesIV && matchesLvl && matchesGender) ||
Expand Down
18 changes: 16 additions & 2 deletions src/Net/Models/PokemonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,27 @@ public PokemonSize? Size
JsonIgnore,
Ignore
]
public bool MatchesGreatLeague => GreatLeague?.Exists(x => x.Rank <= MaximumRankPVP && x.CP >= Strings.MinimumGreatLeagueCP && x.CP <= Strings.MaximumGreatLeagueCP) ?? false;
public bool MatchesGreatLeague => GreatLeague?.Exists(x =>
// Check if stat rank is less than or equal to the max great league rank stat desired
x.Rank <= MaximumRankPVP &&
// Check if stat CP is greater than or equal to min great league CP
x.CP >= Strings.MinimumGreatLeagueCP &&
// Check if stat CP is less than or equal to max great league CP
x.CP <= Strings.MaximumGreatLeagueCP
) ?? false;

[
JsonIgnore,
Ignore
]
public bool MatchesUltraLeague => UltraLeague?.Exists(x => x.Rank <= MaximumRankPVP && x.CP >= Strings.MinimumUltraLeagueCP && x.CP <= Strings.MaximumUltraLeagueCP) ?? false;
public bool MatchesUltraLeague => UltraLeague?.Exists(x =>
// Check if stat rank is less than or equal to the max ultra league rank stat desired
x.Rank <= MaximumRankPVP &&
// Check if stat CP is greater than or equal to min ultra league CP
x.CP >= Strings.MinimumUltraLeagueCP &&
// Check if stat CP is less than or equal to max ultra league CP
x.CP <= Strings.MaximumUltraLeagueCP
) ?? false;


[
Expand Down

0 comments on commit de95284

Please sign in to comment.