Add display of pla static encounter seeds

Show single shiny roll slots for PLA too

Update MiscVerifier.cs
This commit is contained in:
Kurt 2024-02-23 21:16:32 -06:00
parent 43cd9300fb
commit 8206427d21
6 changed files with 46 additions and 13 deletions

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core;
/// <param name="AlphaType">0=Never, 1=Random, 2=Guaranteed</param>
/// <param name="FlawlessIVCount"></param>
public sealed record EncounterSlot8a(EncounterArea8a Parent, ushort Species, byte Form, byte LevelMin, byte LevelMax, byte AlphaType, byte FlawlessIVCount, Gender Gender)
: IEncounterable, IEncounterMatch, IEncounterConvertible<PA8>, IAlphaReadOnly, IMasteryInitialMoveShop8, IFlawlessIVCount
: IEncounterable, IEncounterMatch, IEncounterConvertible<PA8>, IAlphaReadOnly, IMasteryInitialMoveShop8, IFlawlessIVCount, ISeedCorrelation64<PKM>
{
public byte Generation => 8;
public EntityContext Context => EntityContext.Gen8a;
@ -233,4 +233,21 @@ public sealed record EncounterSlot8a(EncounterArea8a Parent, ushort Species, byt
return p.IsValidMasteredEncounter(moves, learn, mastery, level, alpha, allowAlphaPurchaseBug);
}
#endregion
public bool TryGetSeed(PKM pk, out ulong seed)
{
// Check if it matches any single-roll seed.
var pi = PersonalTable.LA[Species, Form];
var param = GetParams(pi) with { RollCount = 1 };
var solver = new XoroMachineSkip(pk.EncryptionConstant, pk.PID);
foreach (var s in solver)
{
if (!Overworld8aRNG.Verify(pk, s, param))
continue;
seed = s;
return true;
}
seed = default;
return false;
}
}

View file

@ -6,7 +6,9 @@ namespace PKHeX.Core;
/// Generation 8 Static Encounter
/// </summary>
public sealed record EncounterStatic8a
: IEncounterable, IEncounterMatch, IEncounterConvertible<PA8>, IAlphaReadOnly, IMasteryInitialMoveShop8, IScaledSizeReadOnly, IMoveset, IFlawlessIVCount, IFatefulEncounterReadOnly, IFixedGender
: IEncounterable, IEncounterMatch, IEncounterConvertible<PA8>, ISeedCorrelation64<PKM>,
IAlphaReadOnly, IMasteryInitialMoveShop8, IScaledSizeReadOnly,
IMoveset, IFlawlessIVCount, IFatefulEncounterReadOnly, IFixedGender
{
public byte Generation => 8;
public EntityContext Context => EntityContext.Gen8a;
@ -283,4 +285,20 @@ public sealed record EncounterStatic8a
return p.IsValidMasteredEncounter(moves, learn, mastery, level, alpha, allowAlphaPurchaseBug);
}
#endregion
public bool TryGetSeed(PKM pk, out ulong seed)
{
// Check if it matches any single-roll seed.
var param = GetParams();
var solver = new XoroMachineSkip(pk.EncryptionConstant, pk.PID);
foreach (var s in solver)
{
if (!Overworld8aRNG.Verify(pk, s, param, HasFixedHeight, HasFixedWeight))
continue;
seed = s;
return true;
}
seed = default;
return false;
}
}

View file

@ -201,7 +201,8 @@ public static class Overworld8aRNG
_ => Shiny.Never,
};
public static bool Verify(PKM pk, ulong seed, in OverworldParam8a para)
public static bool Verify(PKM pk, ulong seed, in OverworldParam8a para,
bool isFixedH = false, bool isFixedW = false)
{
var rand = new Xoroshiro128Plus(seed);
var ec = (uint)rand.NextInt();
@ -290,9 +291,9 @@ public static class Overworld8aRNG
if (pk is IScaledSize s)
{
if (s.HeightScalar != height)
if (!isFixedH && s.HeightScalar != height)
return false;
if (s.WeightScalar != weight)
if (!isFixedW && s.WeightScalar != weight)
return false;
}

View file

@ -52,7 +52,7 @@ public readonly struct PIDIV
#endif
public bool IsClassicMethod() => Type.IsClassicMethod();
public bool IsSeed64() => Type is PIDType.Raid8;
public bool IsSeed64() => Type is PIDType.Xoroshiro;
public PIDIV AsEncounteredVia(LeadSeed condition) => this with { Lead = condition.Lead, EncounterSeed = condition.Seed };
}

View file

@ -172,10 +172,10 @@ public enum PIDType : byte
Pokewalker,
/// <summary>
/// Generation 8 Raid PID
/// Generation 8 Xoroshiro correlation
/// </summary>
/// <remarks>Formulaic based on PID &amp; EC values from a 64bit-seed.</remarks>
Raid8,
Xoroshiro,
/// <summary>
/// Generation 8 Overworld Spawn PID

View file

@ -130,11 +130,8 @@ public sealed class MiscVerifier : Verifier
else if (enc is ISeedCorrelation64<PKM> s64)
{
if (s64.TryGetSeed(pk, out var seed))
data.Info.PIDIV = new PIDIV(PIDType.Raid8, seed);
}
else if (enc is IMasteryInitialMoveShop8 m)
{
if (!m.IsForcedMasteryCorrect(pk))
data.Info.PIDIV = new PIDIV(PIDType.Xoroshiro, seed);
if (enc is IMasteryInitialMoveShop8 m && !m.IsForcedMasteryCorrect(pk))
data.AddLine(GetInvalid(LEncMasteryInitial));
}