Add encounter static deferral oop

We've already been doing something similar for the deferral check; just
merge the logic into the base object
Closes #2489
This commit is contained in:
Kurt
2019-11-21 20:02:08 -08:00
parent 422b11bb42
commit b9e32c67a0
3 changed files with 20 additions and 10 deletions

View File

@@ -425,5 +425,14 @@ protected virtual bool IsMatchLevel(PKM pkm, int lvl)
return true;
}
public virtual bool IsMatchDeferred(PKM pkm)
{
if (pkm.FatefulEncounter != Fateful)
return true;
if (Ability == 4 && pkm.AbilityNumber != 4) // BW/2 Jellicent collision with wild surf slot, resolved by duplicating the encounter with any abil
return true;
return false;
}
}
}

View File

@@ -70,5 +70,15 @@ public override bool IsMatch(PKM pkm, int lvl)
return base.IsMatch(pkm, lvl);
}
public override bool IsMatchDeferred(PKM pkm)
{
if (base.IsMatchDeferred(pkm))
return true;
if (pkm is IGigantamax g && g.CanGigantamax != CanGigantamax)
return true;
return false;
}
}
}

View File

@@ -66,7 +66,7 @@ private static IEnumerable<EncounterStatic> GetMatchingStaticEncounters(PKM pkm,
if (!GetIsMatchStatic(pkm, e, lvl))
continue;
if (GetIsMatchDeferred(pkm, e))
if (e.IsMatchDeferred(pkm))
deferred.Add(e);
else
yield return e;
@@ -75,15 +75,6 @@ private static IEnumerable<EncounterStatic> GetMatchingStaticEncounters(PKM pkm,
yield return e;
}
private static bool GetIsMatchDeferred(PKM pkm, EncounterStatic e)
{
if (pkm.FatefulEncounter != e.Fateful)
return true;
if (e.Ability == 4 && pkm.AbilityNumber != 4) // BW/2 Jellicent collision with wild surf slot, resolved by duplicating the encounter with any abil
return true;
return false;
}
private static bool GetIsMatchStatic(PKM pkm, EncounterStatic e, int lvl)
{
if (!e.IsMatch(pkm, lvl))