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
This commit is contained in:
Kurt 2026-01-04 23:44:57 -06:00
parent 7621087e7e
commit 85abb48da3
4 changed files with 35 additions and 19 deletions

View File

@ -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<TSource>(ReadOnlySpan<ushort> 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);
}
}

View File

@ -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;

View File

@ -37,7 +37,7 @@ public static bool ShouldIterateForms(ushort species, byte form, byte generation
/// <summary>
/// Species that can change between their forms and get access to form-specific moves.
/// </summary>
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,

View File

@ -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>(T pk, int maxIndex, IPermitPlus perm
var index = permit.RecordPermitIndexes.IndexOf(move);
if (CanAnyEvoLearnMovePlus<PersonalTable9ZA, PersonalInfo9ZA, LearnSource9ZA>(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>(T pk, int maxIndex, IPermitPlus perm
return invalid;
}
private static bool CanAnyFormLearnMovePlusRotom<T>(T pk, ReadOnlySpan<EvoCriteria> evos, int index, ushort move)
private static bool CanAnyFormLearnMovePlus<T>(T pk, ReadOnlySpan<EvoCriteria> 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;