Skip to content

Commit

Permalink
Fix ability filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu098vm committed Mar 20, 2024
1 parent e0dbf47 commit 76ee3f7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
6 changes: 3 additions & 3 deletions TeraFinder.Core/Classes/TeraDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public bool IsFilterMatch(TeraDetails res)
if (TeraType != res.TeraType)
return false;

if (AbilityNumber != 0)
if (AbilityNumber != -1)
if (AbilityNumber != res.AbilityNumber)
return false;

Expand Down Expand Up @@ -382,7 +382,7 @@ public bool IsECMatch(uint res) =>
!(AltEC && res % 100 != 0);

public bool IsAbilityMatch(int res) =>
AbilityNumber == 0 || AbilityNumber == res;
AbilityNumber == -1 || AbilityNumber == res;

public bool IsNatureMatch(Nature res) =>
Nature is Nature.Random || Nature == res;
Expand Down Expand Up @@ -427,7 +427,7 @@ public bool IsFilterNull()
return false;
if (!(TeraType == -1))
return false;
if (!(AbilityNumber == 0))
if (!(AbilityNumber == -1))
return false;
if (Nature is not Nature.Random)
return false;
Expand Down
1 change: 1 addition & 0 deletions TeraFinder.Plugins/Forms/CalculatorForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions TeraFinder.Plugins/Forms/CalculatorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,20 @@ private byte GetStars()
return result;
}

private Gender GetGender()
private int GetAbilityNumber() => cmbAbility.SelectedIndex switch
{
return cmbGender.SelectedIndex switch
{
1 => Gender.Male,
2 => Gender.Female,
_ => Gender.Random,
};
}
1 => 0,
2 => 2,
3 => 4,
_ => -1,
};

private Gender GetGender() => cmbGender.SelectedIndex switch
{
1 => Gender.Male,
2 => Gender.Female,
_ => Gender.Random,
};

private async void btnApply_Click(object sender, EventArgs e)
{
Expand Down Expand Up @@ -445,6 +450,7 @@ private void CreateFilter()
var stars = GetStars();
var entity = GetSpeciesFormIndex();
var teraType = (sbyte)(cmbTeraType.SelectedIndex - 1);
var ability = GetAbilityNumber();
var gender = GetGender();

var encounterFilter = entity.species > 0 || stars > 0;
Expand Down Expand Up @@ -473,7 +479,7 @@ private void CreateFilter()
Species = entity.species,
Form = entity.form,
TeraType = teraType,
AbilityNumber = cmbAbility.SelectedIndex == 3 ? 4 : cmbAbility.SelectedIndex,
AbilityNumber = ability,
Nature = (Nature)cmbNature.SelectedIndex,
Gender = gender,
Shiny = (TeraShiny)cmbShiny.SelectedIndex,
Expand Down

0 comments on commit 76ee3f7

Please sign in to comment.