From 85abb48da348f228bb715f465fca0673a0e19863 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 4 Jan 2026 23:44:57 -0600 Subject: [PATCH] Misc tweaks for Hoopa-1 plus flags Merge handling with Rotom's handling Add logic for "Require" & "Set All" operations -- if the form isn't 0. https://projectpokemon.org/home/forums/topic/57375-pkhex-new-update-legality-errors-contribution-page/page/35/#findComment-298854 --- .../Applicators/PlusRecordApplicator.cs | 31 ++++++++++++------- .../Templates/GO/EncounterSlot7GO.cs | 3 +- PKHeX.Core/Legality/Tables/FormChangeUtil.cs | 2 +- .../Legality/Verifiers/LegendsZAVerifier.cs | 18 ++++++++--- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/PKHeX.Core/Editing/Applicators/PlusRecordApplicator.cs b/PKHeX.Core/Editing/Applicators/PlusRecordApplicator.cs index 6584c2106..a9255a380 100644 --- a/PKHeX.Core/Editing/Applicators/PlusRecordApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/PlusRecordApplicator.cs @@ -99,19 +99,26 @@ public void SetPlusFlags(IPermitPlus permit, PlusRecordApplicatorOption option, var indexes = permit.PlusMoveIndexes; foreach (var evo in evos) { - var (levelUp, plus) = source.GetLearnsetAndOther(evo.Species, evo.Form); - var set = seedOfMastery ? levelUp : plus; - var levels = set.GetAllLevels(); - var moves = set.GetAllMoves(); - for (int i = 0; i < levels.Length; i++) - { - if (evo.LevelMax < levels[i]) - break; + record.SetPlusFlagsNatural(indexes, evo, source, seedOfMastery); + if (evo.Form != 0 && evo.Species is (int)Species.Rotom or (int)Species.Hoopa) + record.SetPlusFlagsNatural(indexes, evo with { Form = 0 }, source, seedOfMastery); + } + } - var move = moves[i]; - var index = indexes.IndexOf(move); - record.SetMovePlusFlag(index); - } + private void SetPlusFlagsNatural(ReadOnlySpan indexes, EvoCriteria evo, TSource source, bool seedOfMastery) where TSource : ILearnSourceBonus + { + var (levelUp, plus) = source.GetLearnsetAndOther(evo.Species, evo.Form); + var set = seedOfMastery ? levelUp : plus; + var levels = set.GetAllLevels(); + var moves = set.GetAllMoves(); + for (int i = 0; i < levels.Length; i++) + { + if (evo.LevelMax < levels[i]) + break; + + var move = moves[i]; + var index = indexes.IndexOf(move); + record.SetMovePlusFlag(index); } } diff --git a/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs b/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs index a0698cdd7..7d73b3755 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs @@ -152,8 +152,7 @@ public bool IsWithinDistributionWindow(DateOnly date) public EncounterMatchRating GetMatchRating(PKM pk) { - var stamp = PogoDateRangeExtensions.GetTimeStamp(pk.MetYear + 2000, pk.MetMonth, pk.MetDay); - if (!this.IsWithinStartEnd(stamp)) + if (!IsWithinDistributionWindow(pk)) return EncounterMatchRating.DeferredErrors; if (!this.GetIVsValid(pk)) return EncounterMatchRating.Deferred; diff --git a/PKHeX.Core/Legality/Tables/FormChangeUtil.cs b/PKHeX.Core/Legality/Tables/FormChangeUtil.cs index c0a822e75..85857c5b8 100644 --- a/PKHeX.Core/Legality/Tables/FormChangeUtil.cs +++ b/PKHeX.Core/Legality/Tables/FormChangeUtil.cs @@ -37,7 +37,7 @@ public static bool ShouldIterateForms(ushort species, byte form, byte generation /// /// Species that can change between their forms and get access to form-specific moves. /// - private static bool IsFormChangeDifferentMoves(ushort species, byte generation) => species switch + public static bool IsFormChangeDifferentMoves(ushort species, byte generation) => species switch { (int)Species.Deoxys => generation >= 6, (int)Species.Giratina => generation >= 6, diff --git a/PKHeX.Core/Legality/Verifiers/LegendsZAVerifier.cs b/PKHeX.Core/Legality/Verifiers/LegendsZAVerifier.cs index 690ac23ba..46683d9c9 100644 --- a/PKHeX.Core/Legality/Verifiers/LegendsZAVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/LegendsZAVerifier.cs @@ -170,9 +170,16 @@ private void CheckFlagsPlus(LegalityAnalysis la, PA9 pk) la.AddLine(GetInvalid(PlusMoveCountInvalid)); // Check for all required indexes. - var (_, plus) = LearnSource9ZA.GetLearnsetAndPlus(pk.Species, pk.Form); + var species = pk.Species; + var form = pk.Form; + var (_, plus) = LearnSource9ZA.GetLearnsetAndPlus(species, form); var currentLevel = pk.CurrentLevel; CheckPlusMoveFlags(la, pk, permit, plus, currentLevel); + if (form != 0 && species is (int)Rotom or (int)Hoopa) + { + (_, plus) = LearnSource9ZA.GetLearnsetAndPlus(species, 0); + CheckPlusMoveFlags(la, pk, permit, plus, currentLevel); + } // Check for indexes set that cannot be set via TM or NPC. int max = permit.PlusCountUsed; @@ -262,7 +269,9 @@ private static ushort GetInvalidPlusMove(T pk, int maxIndex, IPermitPlus perm var index = permit.RecordPermitIndexes.IndexOf(move); if (CanAnyEvoLearnMovePlus(evos, index, move, PersonalTable.ZA, LearnSource9ZA.Instance)) continue; // OK - if (pk.Species is (int)Rotom && CanAnyFormLearnMovePlusRotom(pk, evos, index, move)) + + // Rotom and Hoopa, when changed forms, gain access to another form-specific move. + if (FormChangeUtil.IsFormChangeDifferentMoves(pk.Species, 9) && CanAnyFormLearnMovePlus(pk, evos, index, move)) continue; if (invalid != 0) // Multiple invalid moves @@ -272,11 +281,12 @@ private static ushort GetInvalidPlusMove(T pk, int maxIndex, IPermitPlus perm return invalid; } - private static bool CanAnyFormLearnMovePlusRotom(T pk, ReadOnlySpan evos, int index, ushort move) + private static bool CanAnyFormLearnMovePlus(T pk, ReadOnlySpan evos, int index, ushort move) where T : PKM, IPlusRecord { + var fc = pk.PersonalInfo.FormCount; var evo = evos[0]; - for (byte f = 0; f <= 5; f++) + for (byte f = 0; f <= fc; f++) { if (f == pk.Form) continue;