Fix pattern matching comparison

Wish I had an analyzer to catch this (missing parens) similar to boolean logic

#3271 - resolves the traded egg recognition issue
This commit is contained in:
Kurt
2021-10-13 20:05:19 -07:00
parent 2661085e65
commit 4b263bf9bb
9 changed files with 9 additions and 9 deletions

View File

@@ -473,7 +473,7 @@ public enum AreaSlotType8 : byte
public static class AreaSlotType8Extensions
{
public static bool CanCrossover(this AreaSlotType8 type) => type is not HiddenMain or HiddenMain2 or OnlyFishing;
public static bool CanCrossover(this AreaSlotType8 type) => type is not (HiddenMain or HiddenMain2 or OnlyFishing);
public static bool CanEncounterViaFishing(this AreaSlotType8 type, AreaWeather8 weather) => type is OnlyFishing || weather.HasFlag(Fishing);
public static bool CanEncounterViaCurry(this AreaSlotType8 type) => type is HiddenMain or HiddenMain2;
}

View File

@@ -54,7 +54,7 @@ protected override bool IsMatchEggLocation(PKM pkm)
// Unhatched:
if (eggloc != EggLocation)
return false;
if (pk4.Met_Location is not 0 or Locations.LinkTrade4)
if (pk4.Met_Location is not (0 or Locations.LinkTrade4))
return false;
return true;
}

View File

@@ -40,7 +40,7 @@ protected override bool IsMatchEggLocation(PKM pkm)
// Unhatched:
if (eggloc != EggLocation)
return false;
if (pkm.Met_Location is not 0 or Locations.LinkTrade5)
if (pkm.Met_Location is not (0 or Locations.LinkTrade5))
return false;
return true;
}

View File

@@ -42,7 +42,7 @@ protected override bool IsMatchEggLocation(PKM pkm)
// Unhatched:
if (eggloc != EggLocation)
return false;
if (pkm.Met_Location is not 0 or Locations.LinkTrade6)
if (pkm.Met_Location is not (0 or Locations.LinkTrade6))
return false;
return true;
}

View File

@@ -35,7 +35,7 @@ protected override bool IsMatchEggLocation(PKM pkm)
// Unhatched:
if (eggloc != EggLocation)
return false;
if (pkm.Met_Location is not 0 or Locations.LinkTrade6)
if (pkm.Met_Location is not (0 or Locations.LinkTrade6))
return false;
return true;
}

View File

@@ -556,6 +556,6 @@ public enum TimeCapsuleEvaluation
public static class TimeCapsuleEvlautationExtensions
{
public static bool WasTimeCapsuleTransferred(this TimeCapsuleEvaluation eval) => eval is not TimeCapsuleEvaluation.Indeterminate or TimeCapsuleEvaluation.NotTransferred or TimeCapsuleEvaluation.BadCatchRate;
public static bool WasTimeCapsuleTransferred(this TimeCapsuleEvaluation eval) => eval is not (TimeCapsuleEvaluation.Indeterminate or TimeCapsuleEvaluation.NotTransferred or TimeCapsuleEvaluation.BadCatchRate);
}
}

View File

@@ -518,7 +518,7 @@ private static bool CanHaveRibbonWinning(PKM pkm, IEncounterTemplate enc, int ge
if (enc.LevelMin <= 50)
return true;
return enc is not EncounterStaticShadow or WC3;
return enc is not (EncounterStaticShadow or WC3);
}
private static bool CanHaveRibbonVictory(PKM pkm, int gen)

View File

@@ -163,7 +163,7 @@ private bool SearchIntermediate(PKM pk)
private bool SearchComplex(PKM pk)
{
if (SearchEgg != null && !FilterResultEgg(pk)) return false;
if (Level is not null or 0 && !SearchUtil.SatisfiesFilterLevel(pk, SearchLevel, (int) Level)) return false;
if (Level is not (null or 0) && !SearchUtil.SatisfiesFilterLevel(pk, SearchLevel, (int) Level)) return false;
if (SearchLegal != null && new LegalityAnalysis(pk).Valid != SearchLegal) return false;
if (BatchFilters.Length != 0 && !SearchUtil.SatisfiesFilterBatchInstruction(pk, BatchFilters)) return false;

View File

@@ -51,7 +51,7 @@ public SAV1(byte[] data, GameVersion versionOverride = GameVersion.Any) : base(d
private void Initialize(GameVersion versionOverride)
{
// see if RBY can be differentiated
if (Starter != 0 && versionOverride is not GameVersion.RB or GameVersion.YW)
if (Starter != 0 && versionOverride is not (GameVersion.RB or GameVersion.YW))
Version = Yellow ? GameVersion.YW : GameVersion.RB;
Box = Data.Length;