Fix check order for Pressure/Hustle/Vital Spirit

what a silly set of conditions for it to matter -- we need to permit matching of boosted slots, then enforce that the boosting is valid for the slot, and disallow any other lead. If it couldn't be boosted, then ignore the slot.
https://projectpokemon.org/home/forums/topic/57375-pkhex-new-update-legality-errors-contribution-page/?do=findComment&comment=288731
This commit is contained in:
Kurt 2024-03-12 23:33:47 -05:00
parent 5b89b279d1
commit 7ac5da37b3
6 changed files with 37 additions and 8 deletions

View file

@ -75,7 +75,7 @@ public sealed record EncounterArea4 : IEncounterArea<EncounterSlot4>, IGroundTyp
{
if (slot.Species != species)
continue;
if (slot.LevelMax < levelMax)
if (slot.LevelMax <= levelMax)
continue;
levelMax = slot.LevelMax;
}

View file

@ -131,7 +131,10 @@ public sealed record EncounterSlot4(EncounterArea4 Parent, ushort Species, byte
{
// Must match level exactly.
if (!this.IsLevelWithinRange(pk.MetLevel))
return false;
{
if ((Type is not Grass || pk.MetLevel != PressureLevel) || ParseSettings.RNGFrameNotFound4 != Severity.Invalid)
return false; // Only allow Pressure Slots through if they'll be checked by the later Lead verification.
}
}
else
{

View file

@ -211,7 +211,7 @@ public static class MethodJ
return TryGetMatchNoSync(ctx, out result);
}
var syncProc = IsSyncPass(p0);
if (syncProc)
if (syncProc && !(enc.Type is Grass && enc.LevelMax < levelMin))
{
var ctx = new FrameCheckDetails<T>(enc, seed, levelMin, levelMax, format);
if (IsSlotValidRegular(ctx, out seed))
@ -278,6 +278,21 @@ public static class MethodJ
private static bool TryGetMatchNoSync<T>(in FrameCheckDetails<T> ctx, out LeadSeed result)
where T : IEncounterSlot4
{
if (ctx.Encounter.Type is Grass)
{
if (ctx.Encounter.LevelMax > ctx.LevelMin) // Must be boosted via Pressure/Hustle/Vital Spirit
{
if (IsSlotValidHustleVital(ctx, out var pressure))
{ result = new(pressure, PressureHustleSpirit); return true; }
result = default; return false;
}
if (ctx.Encounter.PressureLevel <= ctx.LevelMax) // Can be boosted, or not.
{
if (IsSlotValidHustleVital(ctx, out var pressure))
{ result = new(pressure, PressureHustleSpirit); return true; }
}
}
if (IsSlotValidRegular(ctx, out uint seed))
{ result = new(seed, None); return true; }
@ -293,8 +308,6 @@ public static class MethodJ
if (IsSlotValidStaticMagnet(ctx, out seed, out var lead))
{ result = new(seed, lead); return true; }
if (IsSlotValidHustleVital(ctx, out seed))
{ result = new(seed, PressureHustleSpirit); return true; }
if (IsSlotValidIntimidate(ctx, out seed))
{ result = new(seed, IntimidateKeenEyeFail); return true; }

View file

@ -169,7 +169,7 @@ public static class MethodK
if (depth != 4 && enc is EncounterSlot4 s && (s.IsBugContest || s.IsSafariHGSS))
return Recurse4x(enc, levelMin, levelMax, seed, nature, format, out result, ++depth);
}
else if (IsSyncPass(p0))
else if (IsSyncPass(p0) && !(enc.Type is Grass && enc.LevelMax < levelMin))
{
var ctx = new FrameCheckDetails<T>(enc, seed, levelMin, levelMax, format);
if (IsSlotValidRegular(ctx, out seed))
@ -300,6 +300,21 @@ public static class MethodK
private static bool TryGetMatchNoSync<T>(in FrameCheckDetails<T> ctx, out LeadSeed result)
where T : IEncounterSlot4
{
if (ctx.Encounter.Type is Grass)
{
if (ctx.Encounter.LevelMax < ctx.LevelMin) // Must be boosted via Pressure/Hustle/Vital Spirit
{
if (IsSlotValidHustleVital(ctx, out var pressure))
{ result = new(pressure, PressureHustleSpirit); return true; }
result = default; return false;
}
if (ctx.Encounter.PressureLevel <= ctx.LevelMax) // Can be boosted, or not.
{
if (IsSlotValidHustleVital(ctx, out var pressure))
{ result = new(pressure, PressureHustleSpirit); return true; }
}
}
if (IsSlotValidRegular(ctx, out uint seed))
{ result = new(seed, None); return true; }
@ -315,8 +330,6 @@ public static class MethodK
if (IsSlotValidStaticMagnet(ctx, out seed, out var sm))
{ result = new(seed, sm); return true; }
if (IsSlotValidHustleVital(ctx, out seed))
{ result = new(seed, PressureHustleSpirit); return true; }
if (IsSlotValidIntimidate(ctx, out seed))
{ result = new(seed, IntimidateKeenEyeFail); return true; }