mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Use evo history to check visitation
Previously, the history shared Gen8 for Gen8a/Gen8b; now they're distinct. Add "HasVisited" for other gens
This commit is contained in:
parent
ac17c7d4a3
commit
19b4a26cd7
24 changed files with 62 additions and 106 deletions
|
@ -150,58 +150,6 @@ public static partial class Legal
|
|||
_ => -1,
|
||||
};
|
||||
|
||||
internal static bool HasVisitedSWSH(this PKM pk, EvoCriteria[] evos)
|
||||
{
|
||||
if (pk.SWSH)
|
||||
return true;
|
||||
if (pk.IsUntraded)
|
||||
return false;
|
||||
if (pk.BDSP && pk.Species is (int)Species.Spinda or (int)Species.Nincada)
|
||||
return false;
|
||||
|
||||
var pt = PersonalTable.SWSH;
|
||||
foreach (var evo in evos)
|
||||
{
|
||||
if (pt.IsPresentInGame(evo.Species, evo.Form))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool HasVisitedBDSP(this PKM pk, EvoCriteria[] evos)
|
||||
{
|
||||
if (pk.BDSP)
|
||||
return true;
|
||||
if (pk.IsUntraded)
|
||||
return false;
|
||||
if (pk.Species is (int)Species.Spinda or (int)Species.Nincada)
|
||||
return false;
|
||||
|
||||
var pt = PersonalTable.BDSP;
|
||||
foreach (var evo in evos)
|
||||
{
|
||||
if (pt.IsPresentInGame(evo.Species, evo.Form))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool HasVisitedLA(this PKM pk, EvoCriteria[] evos)
|
||||
{
|
||||
if (pk.LA)
|
||||
return true;
|
||||
if (pk.IsUntraded)
|
||||
return false;
|
||||
|
||||
var pt = PersonalTable.LA;
|
||||
foreach (var evo in evos)
|
||||
{
|
||||
if (pt.IsPresentInGame(evo.Species, evo.Form))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the relearn moves should be wiped.
|
||||
/// </summary>
|
||||
|
|
|
@ -23,7 +23,16 @@ public class EvolutionHistory
|
|||
public EvoCriteria[] Gen8a = NONE;
|
||||
public EvoCriteria[] Gen8b = NONE;
|
||||
|
||||
public bool HasVisitedGen1 => Gen1.Length != 0;
|
||||
public bool HasVisitedGen2 => Gen2.Length != 0;
|
||||
public bool HasVisitedGen3 => Gen3.Length != 0;
|
||||
public bool HasVisitedGen4 => Gen4.Length != 0;
|
||||
public bool HasVisitedGen5 => Gen5.Length != 0;
|
||||
public bool HasVisitedGen6 => Gen6.Length != 0;
|
||||
public bool HasVisitedGen7 => Gen7.Length != 0;
|
||||
public bool HasVisitedSWSH => Gen8.Length != 0;
|
||||
|
||||
public bool HasVisitedLGPE => Gen7b.Length != 0;
|
||||
public bool HasVisitedPLA => Gen8a.Length != 0;
|
||||
public bool HasVisitedBDSP => Gen8b.Length != 0;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public sealed class LearnGroup1 : ILearnGroup
|
|||
_ => enc.Generation == 1 ? LearnGroup2.Instance : null,
|
||||
};
|
||||
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen1.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen1;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history, IEncounterTemplate enc,
|
||||
MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -14,10 +14,10 @@ public sealed class LearnGroup2 : ILearnGroup
|
|||
{
|
||||
EntityContext.Gen2 when enc.Generation == 1 => LearnGroup1.Instance,
|
||||
EntityContext.Gen1 => null,
|
||||
_ => enc.Generation != 1 && !pk.Korean && history.Gen1.Length != 0 ? LearnGroup1.Instance : null,
|
||||
_ => enc.Generation != 1 && !pk.Korean && history.HasVisitedGen1 ? LearnGroup1.Instance : null,
|
||||
};
|
||||
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen2.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen2;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history, IEncounterTemplate enc,
|
||||
MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -11,7 +11,7 @@ public sealed class LearnGroup3 : ILearnGroup
|
|||
private const int Generation = 3;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null; // Gen3 is the end of the line!
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen3.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen3;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history, IEncounterTemplate enc,
|
||||
MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -11,7 +11,7 @@ public sealed class LearnGroup4 : ILearnGroup
|
|||
private const int Generation = 4;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => enc.Generation is Generation ? null : LearnGroup3.Instance;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen4.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen4;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history,
|
||||
IEncounterTemplate enc, MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -11,7 +11,7 @@ public sealed class LearnGroup5 : ILearnGroup
|
|||
private const int Generation = 5;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => enc.Generation is Generation ? null : LearnGroup4.Instance;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen5.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen5;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history,
|
||||
IEncounterTemplate enc, MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -11,7 +11,7 @@ public sealed class LearnGroup6 : ILearnGroup
|
|||
private const int Generation = 6;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => enc.Generation is Generation ? null : LearnGroup5.Instance;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen6.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen6;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history, IEncounterTemplate enc,
|
||||
MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -13,12 +13,12 @@ public sealed class LearnGroup7 : ILearnGroup
|
|||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => enc.Generation switch
|
||||
{
|
||||
Generation => null,
|
||||
1 => history.Gen1.Length != 0 ? LearnGroup1.Instance : null,
|
||||
<= 2 => history.Gen2.Length != 0 ? LearnGroup2.Instance : null,
|
||||
_ => history.Gen6.Length != 0 ? LearnGroup6.Instance : null,
|
||||
1 => history.HasVisitedGen1 ? LearnGroup1.Instance : null,
|
||||
<= 2 => history.HasVisitedGen2 ? LearnGroup2.Instance : null,
|
||||
_ => history.HasVisitedGen6 ? LearnGroup6.Instance : null,
|
||||
};
|
||||
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen7.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen7;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history, IEncounterTemplate enc,
|
||||
MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -11,7 +11,7 @@ public sealed class LearnGroup7b : ILearnGroup
|
|||
private const int Generation = 7;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen7b.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedLGPE;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history,
|
||||
IEncounterTemplate enc, MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -16,12 +16,12 @@ public sealed class LearnGroup8 : ILearnGroup
|
|||
return null;
|
||||
if (option == LearnOption.Current && pk.IsOriginalMovesetDeleted())
|
||||
return null;
|
||||
if (history.Gen7b.Length != 0)
|
||||
if (history.HasVisitedLGPE)
|
||||
return LearnGroup7b.Instance;
|
||||
return LearnGroup7.Instance;
|
||||
}
|
||||
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen8.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedSWSH;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history,
|
||||
IEncounterTemplate enc, MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -11,7 +11,7 @@ public sealed class LearnGroup8a : ILearnGroup
|
|||
private const int Generation = 8;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen8a.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedPLA;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history,
|
||||
IEncounterTemplate enc, MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -11,7 +11,7 @@ public sealed class LearnGroup8b : ILearnGroup
|
|||
private const int Generation = 8;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.Gen8b.Length != 0;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedBDSP;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<int> current, PKM pk, EvolutionHistory history,
|
||||
IEncounterTemplate enc, MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current)
|
||||
|
|
|
@ -186,7 +186,7 @@ internal static class EvolutionRestrictions
|
|||
if (pk.HasOriginalMetLocation || (pk.Format == 4 && gen == 3) || pk.VC || pk.Species == (int)Sylveon)
|
||||
lvl = Math.Max(pk.Met_Level + 1, lvl);
|
||||
|
||||
if (pk.HasVisitedLA(evos.Gen8a)) // No Level Up required, and different levels than mainline SW/SH.
|
||||
if (evos.HasVisitedPLA) // No Level Up required, and different levels than mainline SW/SH.
|
||||
{
|
||||
var la = MinLevelEvolutionWithMove_8LA[index];
|
||||
if (la <= lvl)
|
||||
|
|
|
@ -70,7 +70,7 @@ public sealed class AbilityVerifier : Verifier
|
|||
if (format >= 8) // Ability Patch
|
||||
{
|
||||
var evos = data.Info.EvoChainsAllGens;
|
||||
if (pk.AbilityNumber == 4 && IsAccessibleAbilityPatch(pk, evos))
|
||||
if (pk.AbilityNumber == 4 && IsAccessibleAbilityPatch(evos))
|
||||
{
|
||||
if (CanAbilityPatch(format, abilities, pk.Species))
|
||||
return GetValid(LAbilityPatchUsed);
|
||||
|
@ -447,22 +447,22 @@ public sealed class AbilityVerifier : Verifier
|
|||
return VALID;
|
||||
}
|
||||
|
||||
private static bool IsAccessibleAbilityPatch(PKM pk, EvolutionHistory evosAll)
|
||||
private static bool IsAccessibleAbilityPatch(EvolutionHistory evosAll)
|
||||
{
|
||||
return pk.HasVisitedSWSH(evosAll.Gen8) || pk.HasVisitedBDSP(evosAll.Gen8b);
|
||||
return evosAll.HasVisitedSWSH || evosAll.HasVisitedBDSP;
|
||||
}
|
||||
|
||||
private static bool IsAccessibleAbilityCapsule(PKM pk, EvolutionHistory evosAll)
|
||||
private static bool IsAccessibleAbilityCapsule(EvolutionHistory evosAll)
|
||||
{
|
||||
if (evosAll.Gen6.Length > 0 || evosAll.Gen7.Length > 0)
|
||||
if (evosAll.HasVisitedGen6 || evosAll.HasVisitedGen7)
|
||||
return true;
|
||||
return pk.HasVisitedSWSH(evosAll.Gen8) || pk.HasVisitedBDSP(evosAll.Gen8b);
|
||||
return evosAll.HasVisitedSWSH || evosAll.HasVisitedBDSP;
|
||||
}
|
||||
|
||||
// Ability Capsule can change between 1/2
|
||||
private static bool IsAbilityCapsuleModified(PKM pk, IReadOnlyList<int> abilities, AbilityPermission encounterAbility, EvolutionHistory evos)
|
||||
{
|
||||
if (!IsAccessibleAbilityCapsule(pk, evos))
|
||||
if (!IsAccessibleAbilityCapsule(evos))
|
||||
return false; // Not available.
|
||||
if (!CanAbilityCapsule(pk.Format, abilities))
|
||||
return false;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using static PKHeX.Core.ContestStatGranting;
|
||||
using static PKHeX.Core.ContestStatGranting;
|
||||
using static PKHeX.Core.ContestStatInfo;
|
||||
using static PKHeX.Core.LegalityCheckStrings;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public sealed class ContestStatVerifier : Verifier
|
|||
else if (correlation == CorrelateSheen)
|
||||
{
|
||||
bool gen3 = data.Info.Generation == 3;
|
||||
bool bdsp = pk.HasVisitedBDSP(data.Info.EvoChainsAllGens.Gen8b);
|
||||
bool bdsp = data.Info.EvoChainsAllGens.HasVisitedBDSP;
|
||||
var method = gen3 ? ContestStatGrantingSheen.Gen3 :
|
||||
bdsp ? ContestStatGrantingSheen.Gen8b : ContestStatGrantingSheen.Gen4;
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ public sealed class FormVerifier : Verifier
|
|||
> 9_999 => GetInvalid(LFormArgumentHigh),
|
||||
_ => GetValid(LFormArgumentValid),
|
||||
},
|
||||
Stantler when pk is PA8 || pk.HasVisitedLA(data.Info.EvoChainsAllGens.Gen8a) => arg switch
|
||||
Stantler when pk is PA8 || data.Info.EvoChainsAllGens.HasVisitedPLA => arg switch
|
||||
{
|
||||
not 0 when pk.IsEgg => GetInvalid(LFormArgumentNotAllowed),
|
||||
not 0 when pk.CurrentLevel < 31 => GetInvalid(LFormArgumentHigh),
|
||||
|
|
|
@ -100,7 +100,7 @@ public sealed class LegendsArceusVerifier : Verifier
|
|||
LoadPurchasedMoves(pa, purchased);
|
||||
|
||||
// If it can be leveled up in other games, level it up in other games.
|
||||
if (pa.HasVisitedSWSH(h.Gen8) || pa.HasVisitedBDSP(h.Gen8b))
|
||||
if (h.HasVisitedSWSH || h.HasVisitedBDSP)
|
||||
return count;
|
||||
|
||||
// Level up to current level
|
||||
|
|
|
@ -28,7 +28,7 @@ public sealed class MemoryVerifier : Verifier
|
|||
private static bool ShouldHaveNoMemory(LegalityAnalysis data, PKM pk)
|
||||
{
|
||||
if (pk.BDSP || pk.LA)
|
||||
return !pk.HasVisitedSWSH(data.Info.EvoChainsAllGens.Gen8);
|
||||
return !data.Info.EvoChainsAllGens.HasVisitedSWSH;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -270,8 +270,8 @@ public sealed class MemoryVerifier : Verifier
|
|||
case 7 when pk.GG: // LGPE does not set memories.
|
||||
case 8 when pk.GO_HOME: // HOME does not set memories.
|
||||
case 8 when pk.Met_Location == Locations.HOME8: // HOME does not set memories.
|
||||
case 8 when pk.BDSP && !pk.HasVisitedSWSH(evos.Gen8): // BDSP does not set memories.
|
||||
case 8 when pk.LA && !pk.HasVisitedSWSH(evos.Gen8): // LA does not set memories.
|
||||
case 8 when pk.BDSP && !evos.HasVisitedSWSH: // BDSP does not set memories.
|
||||
case 8 when pk.LA && !evos.HasVisitedSWSH: // LA does not set memories.
|
||||
return false;
|
||||
|
||||
// Eggs cannot have memories
|
||||
|
|
|
@ -59,10 +59,10 @@ public static class ContestStatInfo
|
|||
3 => pk.Format < 6 ? CorrelateSheen : Mixed,
|
||||
4 => pk.Format < 6 ? CorrelateSheen : Mixed,
|
||||
|
||||
5 => pk.Format < 6 ? None : !pk.HasVisitedBDSP(h.Gen8b) ? NoSheen : Mixed, // ORAS Contests
|
||||
6 => !pk.AO && pk.IsUntraded ? None : !pk.HasVisitedBDSP(h.Gen8b) ? NoSheen : Mixed,
|
||||
5 => pk.Format < 6 ? None : !h.HasVisitedBDSP ? NoSheen : Mixed, // ORAS Contests
|
||||
6 => !pk.AO && pk.IsUntraded ? None : !h.HasVisitedBDSP ? NoSheen : Mixed,
|
||||
|
||||
_ => pk.HasVisitedBDSP(h.Gen8b) ? CorrelateSheen : None, // BDSP Contests
|
||||
_ => h.HasVisitedBDSP ? CorrelateSheen : None, // BDSP Contests
|
||||
};
|
||||
|
||||
public static int CalculateMaximumSheen(IContestStats s, int nature, IContestStats initial, bool pokeBlock3)
|
||||
|
|
|
@ -571,7 +571,7 @@ public sealed class MiscVerifier : Verifier
|
|||
private void VerifyPLAStats(LegalityAnalysis data, PA8 pa8)
|
||||
{
|
||||
VerifyAbsoluteSizes(data, pa8);
|
||||
if (!pa8.HasVisitedSWSH(data.Info.EvoChainsAllGens.Gen8))
|
||||
if (!data.Info.EvoChainsAllGens.HasVisitedSWSH)
|
||||
{
|
||||
var affix = pa8.AffixedRibbon;
|
||||
if (affix != -1) // None
|
||||
|
@ -602,7 +602,7 @@ public sealed class MiscVerifier : Verifier
|
|||
|
||||
private void VerifyBDSPStats(LegalityAnalysis data, PB8 pb8)
|
||||
{
|
||||
if (!pb8.HasVisitedSWSH(data.Info.EvoChainsAllGens.Gen8))
|
||||
if (!data.Info.EvoChainsAllGens.HasVisitedSWSH)
|
||||
{
|
||||
var affix = pb8.AffixedRibbon;
|
||||
if (affix != -1) // None
|
||||
|
|
|
@ -133,7 +133,7 @@ public sealed class RibbonVerifier : Verifier
|
|||
var iterate = GetInvalidRibbons4Any(pk, evos, s4, gen);
|
||||
if (!inhabited4)
|
||||
{
|
||||
if (pk.HasVisitedBDSP(evos.Gen8b)) // Allow Sinnoh Champion. ILCA reused the Gen4 ribbon for the remake.
|
||||
if (evos.HasVisitedBDSP) // Allow Sinnoh Champion. ILCA reused the Gen4 ribbon for the remake.
|
||||
iterate = iterate.Concat(GetInvalidRibbonsNoneSkipIndex(s4.RibbonBitsOnly(), s4.RibbonNamesOnly(), 1));
|
||||
else
|
||||
iterate = iterate.Concat(GetInvalidRibbonsNone(s4.RibbonBitsOnly(), s4.RibbonNamesOnly()));
|
||||
|
@ -148,7 +148,7 @@ public sealed class RibbonVerifier : Verifier
|
|||
var iterate = inhabited6
|
||||
? GetInvalidRibbons6Any(pk, s6, gen, enc)
|
||||
: pk.Format >= 8
|
||||
? GetInvalidRibbons6AnyG8(pk, s6, evos)
|
||||
? GetInvalidRibbons6AnyG8(s6, evos)
|
||||
: GetInvalidRibbonsNone(s6.RibbonBits(), s6.RibbonNamesBool());
|
||||
foreach (var z in iterate)
|
||||
yield return z;
|
||||
|
@ -192,14 +192,14 @@ public sealed class RibbonVerifier : Verifier
|
|||
private static bool IsRibbonValidEffort(PKM pk, EvolutionHistory evos, int gen) => gen switch
|
||||
{
|
||||
5 when pk.Format == 5 => false,
|
||||
8 when !pk.HasVisitedSWSH(evos.Gen8) && !pk.HasVisitedBDSP(evos.Gen8b) => false,
|
||||
8 when !evos.HasVisitedSWSH && !evos.HasVisitedBDSP => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
private static bool IsRibbonValidBestFriend(PKM pk, EvolutionHistory evos, int gen) => gen switch
|
||||
{
|
||||
< 7 when pk is { IsUntraded: true } and IAffection { OT_Affection: < 255 } => false, // Gen6/7 uses affection. Can't lower it on OT!
|
||||
8 when !pk.HasVisitedSWSH(evos.Gen8) && !pk.HasVisitedBDSP(evos.Gen8b) => false, // Gen8+ replaced with Max Friendship.
|
||||
8 when !evos.HasVisitedSWSH && !evos.HasVisitedBDSP => false, // Gen8+ replaced with Max Friendship.
|
||||
_ => true,
|
||||
};
|
||||
|
||||
|
@ -224,7 +224,7 @@ public sealed class RibbonVerifier : Verifier
|
|||
if (s4.RibbonFootprint && !CanHaveFootprintRibbon(pk, evos, gen))
|
||||
yield return new RibbonResult(nameof(s4.RibbonFootprint));
|
||||
|
||||
bool visitBDSP = pk.HasVisitedBDSP(evos.Gen8b);
|
||||
bool visitBDSP = evos.HasVisitedBDSP;
|
||||
bool gen34 = gen is 3 or 4;
|
||||
bool not6 = pk.Format < 6 || gen is > 6 or < 3;
|
||||
bool noDaily = !gen34 && not6 && !visitBDSP;
|
||||
|
@ -297,9 +297,9 @@ public sealed class RibbonVerifier : Verifier
|
|||
yield return result;
|
||||
}
|
||||
|
||||
private static IEnumerable<RibbonResult> GetInvalidRibbons6AnyG8(PKM pk, IRibbonSetCommon6 s6, EvolutionHistory evos)
|
||||
private static IEnumerable<RibbonResult> GetInvalidRibbons6AnyG8(IRibbonSetCommon6 s6, EvolutionHistory evos)
|
||||
{
|
||||
if (!pk.HasVisitedBDSP(evos.Gen8b))
|
||||
if (!evos.HasVisitedBDSP)
|
||||
{
|
||||
var none = GetInvalidRibbonsNone(s6.RibbonBits(), s6.RibbonNamesBool());
|
||||
foreach (var x in none)
|
||||
|
@ -429,9 +429,9 @@ public sealed class RibbonVerifier : Verifier
|
|||
|
||||
private static IEnumerable<RibbonResult> GetInvalidRibbons8Any(PKM pk, IRibbonSetCommon8 s8, IEncounterTemplate enc, EvolutionHistory evos)
|
||||
{
|
||||
bool swsh = pk.HasVisitedSWSH(evos.Gen8);
|
||||
bool bdsp = pk.HasVisitedBDSP(evos.Gen8b);
|
||||
bool pla = pk.HasVisitedLA(evos.Gen8a);
|
||||
bool swsh = evos.HasVisitedSWSH;
|
||||
bool bdsp = evos.HasVisitedBDSP;
|
||||
bool pla = evos.HasVisitedPLA;
|
||||
|
||||
if (!swsh && !bdsp)
|
||||
{
|
||||
|
@ -490,7 +490,7 @@ public sealed class RibbonVerifier : Verifier
|
|||
bool exist = enc.Generation switch
|
||||
{
|
||||
< 8 => pk is IBattleVersion { BattleVersion: (int)GameVersion.SW or (int)GameVersion.SH },
|
||||
_ => pk.HasVisitedSWSH(evos.Gen8),
|
||||
_ => evos.HasVisitedSWSH,
|
||||
};
|
||||
if (!exist)
|
||||
return false;
|
||||
|
@ -499,7 +499,7 @@ public sealed class RibbonVerifier : Verifier
|
|||
var species = pk.Species;
|
||||
if (species > Legal.MaxSpeciesID_8_R2)
|
||||
return false;
|
||||
|
||||
|
||||
// Series 13 rule-set was the first time Ranked Battles allowed the use of Mythical Pokémon.
|
||||
if (Legal.Legends.Contains(species))
|
||||
{
|
||||
|
@ -608,10 +608,9 @@ public sealed class RibbonVerifier : Verifier
|
|||
return true;
|
||||
|
||||
// Gen8-BDSP: Variable by species Footprint
|
||||
var bdspEvos = evos.Gen8b;
|
||||
if (pk.HasVisitedBDSP(bdspEvos))
|
||||
if (evos.HasVisitedBDSP)
|
||||
{
|
||||
if (bdspEvos.Any(z => PersonalTable.BDSP.IsPresentInGame(z.Species, z.Form) && !HasFootprintBDSP[z.Species]))
|
||||
if (Array.Exists(evos.Gen8b, z => !HasFootprintBDSP[z.Species]))
|
||||
return true; // no footprint
|
||||
if (pk.CurrentLevel - pk.Met_Level >= 30)
|
||||
return true; // traveled well
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace PKHeX.Core;
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Interface that exposes a <see cref="BattleVersion"/> for allowing a Pokémon into ranked battles if it originated from a prior game.
|
||||
|
@ -16,7 +16,7 @@ public static class BattleVersionExtensions
|
|||
public static bool IsBattleVersionValid<T>(this T pk, EvolutionHistory h) where T : PKM, IBattleVersion => pk.BattleVersion switch
|
||||
{
|
||||
0 => true,
|
||||
(int)GameVersion.SW or (int)GameVersion.SH => !(pk.SWSH || pk.BDSP || pk.LA) && pk.HasVisitedSWSH(h.Gen8),
|
||||
(int)GameVersion.SW or (int)GameVersion.SH => !(pk.SWSH || pk.BDSP || pk.LA) && h.HasVisitedSWSH,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ public static partial class Extensions
|
|||
public static bool IsHyperTrainingAvailable(this IHyperTrain t, EvolutionHistory h) => t switch
|
||||
{
|
||||
// Check for game formats where training is unavailable:
|
||||
PA8 pa8 => h.Gen7.Length > 0 || pa8.HasVisitedSWSH(h.Gen8) || pa8.HasVisitedBDSP(h.Gen8b),
|
||||
PA8 => h.HasVisitedGen7 || h.HasVisitedSWSH || h.HasVisitedBDSP,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue