Simplify match rating return value choice

Ensure it is ordered Partial->DeferredErrors->Deferred->Match
This commit is contained in:
Kurt 2022-02-06 16:14:46 -08:00
parent b8394516d2
commit c7ed55ab54
2 changed files with 21 additions and 8 deletions

View file

@ -57,16 +57,22 @@ public sealed record EncounterSlot8a : EncounterSlot, IAlpha
public override EncounterMatchRating GetMatchRating(PKM pkm)
{
if (pkm is IAlpha a && a.IsAlpha != IsAlpha)
return EncounterMatchRating.DeferredErrors;
if (Gender is not Gender.Random && pkm.Gender != (int)Gender)
return EncounterMatchRating.PartialMatch;
var result = GetMatchRatingInternal(pkm);
var orig = base.GetMatchRating(pkm);
return result > orig ? result : orig;
}
private EncounterMatchRating GetMatchRatingInternal(PKM pkm)
{
if (pkm is IAlpha a && a.IsAlpha != IsAlpha)
return EncounterMatchRating.DeferredErrors;
if (FlawlessIVCount is not 0 && pkm.FlawlessIVCount < FlawlessIVCount)
return EncounterMatchRating.DeferredErrors;
var result = GetAlphaMoveCompatibility(pkm);
var orig = base.GetMatchRating(pkm);
return result > orig ? result : orig;
return GetAlphaMoveCompatibility(pkm);
}
private EncounterMatchRating GetAlphaMoveCompatibility(PKM pkm)

View file

@ -93,15 +93,22 @@ public sealed record EncounterStatic8a(GameVersion Version) : EncounterStatic(Ve
}
public override EncounterMatchRating GetMatchRating(PKM pkm)
{
if (!IsForcedMasteryCorrect(pkm))
return EncounterMatchRating.PartialMatch;
var result = GetMatchRatingInternal(pkm);
var orig = base.GetMatchRating(pkm);
return result > orig ? result : orig;
}
private EncounterMatchRating GetMatchRatingInternal(PKM pkm)
{
if (Shiny != Shiny.Random && !Shiny.IsValid(pkm))
return EncounterMatchRating.DeferredErrors;
if (Gift && pkm.Ball != Ball)
return EncounterMatchRating.DeferredErrors;
if (!IsForcedMasteryCorrect(pkm))
return EncounterMatchRating.PartialMatch;
var orig = base.GetMatchRating(pkm);
if (orig is not EncounterMatchRating.Match)
return orig;