Filter out unobtainable encounters

Closes #2440
This commit is contained in:
Kurt
2019-11-16 21:55:38 -08:00
parent ac498fe643
commit d6aeaeb657
2 changed files with 13 additions and 2 deletions

View File

@@ -186,7 +186,13 @@ private IEnumerable<IEncounterable> SearchDatabase()
// return filtered results
var comparer = new ReferenceComparer<IEncounterable>();
return results.Distinct(comparer); // only distinct objects
results = results.Distinct(comparer); // only distinct objects
// when PK7->PK8 conversion is possible (and sprites in new size are available, remove this filter)
results = SAV is SAV8SWSH
? results.Where(z => !(z is IGeneration g) || g.Generation == 8)
: results.Where(z => !(z is IGeneration g) || g.Generation <= 7);
return results;
}
private class ReferenceComparer<T> : IEqualityComparer<T>

View File

@@ -192,7 +192,12 @@ private void ResetFilters(object sender, EventArgs e)
private void LoadDatabase()
{
RawDB = new List<MysteryGift>(EncounterEvent.GetAllEvents());
var db = EncounterEvent.GetAllEvents();
// when PK7->PK8 conversion is possible (and sprites in new size are available, remove this filter)
db = SAV is SAV8SWSH ? db.OfType<WC8>() : db.Where(z => !(z is WC8));
RawDB = new List<MysteryGift>(db);
foreach (var mg in RawDB)
mg.GiftUsed = false;
BeginInvoke(new MethodInvoker(delegate