Revise alola champ ribbon check

This commit is contained in:
Kurt
2022-08-12 10:16:12 -07:00
parent 5f3516c3ce
commit 3cccb3a9cd

View File

@@ -166,8 +166,9 @@ private static IEnumerable<RibbonResult> GetInvalidRibbons(PKM pk, EvolutionHist
}
if (pk is IRibbonSetCommon7 s7)
{
bool inhabited7 = gen <= 7 && !pk.GG;
if (!inhabited7 && enc is not IRibbonSetCommon7 { RibbonChampionAlola: true })
bool inhabited7 = evos.HasVisitedGen7;
bool alolaValid = GetIsAlolaChampValid(s7, enc, inhabited7);
if (!alolaValid)
yield return new RibbonResult(nameof(s7.RibbonChampionAlola));
if (!inhabited7 || !IsAllowedBattleFrontier(pk.Species))
@@ -198,6 +199,18 @@ private static IEnumerable<RibbonResult> GetInvalidRibbons(PKM pk, EvolutionHist
}
}
private static bool GetIsAlolaChampValid(IRibbonSetCommon7 s7, IEncounterTemplate enc, bool inhabited7)
{
// If the encounter comes with the ribbon, it must have the ribbon.
if (enc is IRibbonSetCommon7 { RibbonChampionAlola: true })
return s7.RibbonChampionAlola;
// If it has visited, it can be either state.
if (inhabited7)
return true;
// If it has not visited, it must not have it.
return !s7.RibbonChampionAlola;
}
private static bool IsRibbonValidEffort(PKM pk, EvolutionHistory evos, int gen) => gen switch
{
5 when pk.Format == 5 => false,