mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 00:07:15 +00:00
pid encounter type mismatch: returns
Keeping the cryptic message for now :)
This commit is contained in:
parent
205cf481b0
commit
1af27516e6
6 changed files with 60 additions and 21 deletions
|
@ -4,7 +4,7 @@ namespace PKHeX.Core
|
|||
/// Encounter Slot found in <see cref="GameVersion.SWSH"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EncounterSlot"/>
|
||||
public sealed record EncounterSlot8 : EncounterSlot
|
||||
public sealed record EncounterSlot8 : EncounterSlot, IOverworldCorrelation8
|
||||
{
|
||||
public readonly AreaWeather8 Weather;
|
||||
public override string LongName => Weather == AreaWeather8.All ? wild : $"{wild} - {Weather.ToString().Replace("_", string.Empty)}";
|
||||
|
@ -14,5 +14,22 @@ namespace PKHeX.Core
|
|||
{
|
||||
Weather = weather;
|
||||
}
|
||||
|
||||
public bool HasOverworldCorrelation
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((Weather & AreaWeather8.Shaking_Trees) != 0)
|
||||
return false; // berry tree can have any 128bit seed from overworld
|
||||
if (!((EncounterArea8) Area).PermitCrossover)
|
||||
return false; // curry from hidden (not symbol) can have any 128bit seed from overworld
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOverworldCorrelationCorrect(PKM pk)
|
||||
{
|
||||
return Overworld8RNG.ValidateOverworldEncounter(pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace PKHeX.Core
|
|||
/// Generation 8 Static Encounter
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EncounterStatic"/>
|
||||
public record EncounterStatic8 : EncounterStatic, IDynamaxLevel, IGigantamax, IRelearn
|
||||
public record EncounterStatic8 : EncounterStatic, IDynamaxLevel, IGigantamax, IRelearn, IOverworldCorrelation8
|
||||
{
|
||||
public sealed override int Generation => 8;
|
||||
public bool ScriptedNoMarks { get; init; }
|
||||
|
@ -36,5 +36,28 @@ namespace PKHeX.Core
|
|||
return false;
|
||||
return base.IsMatchExact(pkm, evo);
|
||||
}
|
||||
|
||||
public bool HasOverworldCorrelation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Gift)
|
||||
return false; // gifts can have any 128bit seed from overworld
|
||||
if (ScriptedNoMarks)
|
||||
return false; // scripted encounters don't act as saved spawned overworld encounters
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOverworldCorrelationCorrect(PKM pk)
|
||||
{
|
||||
return Overworld8RNG.ValidateOverworldEncounter(pk, Shiny == Shiny.Random ? Shiny.FixedValue : Shiny, FlawlessIVCount);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IOverworldCorrelation8
|
||||
{
|
||||
bool HasOverworldCorrelation { get; }
|
||||
bool IsOverworldCorrelationCorrect(PKM pk);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ namespace PKHeX.Core
|
|||
{
|
||||
internal static class EncounterGenerator8
|
||||
{
|
||||
public static IEnumerable<IEncounterable> GetEncounters(PKM pkm, LegalInfo info)
|
||||
public static IEnumerable<IEncounterable> GetEncounters(PKM pkm)
|
||||
{
|
||||
var chain = EncounterOrigin.GetOriginChain(pkm);
|
||||
return pkm.Version switch
|
||||
{
|
||||
(int)GameVersion.GO => EncounterGenerator7.GetEncountersGO(pkm, chain),
|
||||
_ => GetEncountersMainline(pkm, chain, info)
|
||||
_ => GetEncountersMainline(pkm, chain)
|
||||
};
|
||||
}
|
||||
|
||||
private static IEnumerable<IEncounterable> GetEncountersMainline(PKM pkm, IReadOnlyList<EvoCriteria> chain, LegalInfo info)
|
||||
private static IEnumerable<IEncounterable> GetEncountersMainline(PKM pkm, IReadOnlyList<EvoCriteria> chain)
|
||||
{
|
||||
// Static Encounters can collide with wild encounters (close match); don't break if a Static Encounter is yielded.
|
||||
int ctr = 0;
|
||||
|
@ -45,6 +45,8 @@ namespace PKHeX.Core
|
|||
foreach (var z in GetValidStaticEncounter(pkm, chain))
|
||||
{
|
||||
var match = z.GetMatchRating(pkm);
|
||||
if (z is IOverworldCorrelation8 {HasOverworldCorrelation:true} s && !s.IsOverworldCorrelationCorrect(pkm))
|
||||
match = Deferred;
|
||||
switch (match)
|
||||
{
|
||||
case Match: yield return z; ++ctr; break;
|
||||
|
@ -53,12 +55,13 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
bool slotFrame = Overworld8RNG.ValidateOverworldEncounter(pkm);
|
||||
info.PIDIVMatches = slotFrame;
|
||||
// if (ctr != 0) yield break;
|
||||
foreach (var z in GetValidWildEncounters(pkm, chain))
|
||||
{
|
||||
var match = z.GetMatchRating(pkm);
|
||||
var slot = (EncounterSlot8)z;
|
||||
if (slot.HasOverworldCorrelation && !slot.IsOverworldCorrelationCorrect(pkm))
|
||||
match = Deferred;
|
||||
switch (match)
|
||||
{
|
||||
case Match: yield return z; ++ctr; break;
|
||||
|
@ -66,7 +69,6 @@ namespace PKHeX.Core
|
|||
case PartialMatch: partial ??= z; break;
|
||||
}
|
||||
}
|
||||
info.PIDIVMatches = true;
|
||||
|
||||
if (ctr != 0) yield break;
|
||||
foreach (var z in GetValidEncounterTrades(pkm, chain))
|
||||
|
@ -81,19 +83,10 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
if (deferred != null)
|
||||
{
|
||||
if (deferred is EncounterSlot8)
|
||||
info.PIDIVMatches = slotFrame;
|
||||
yield return deferred;
|
||||
info.PIDIVMatches = true;
|
||||
}
|
||||
|
||||
if (partial != null)
|
||||
{
|
||||
if (deferred is EncounterSlot8)
|
||||
info.PIDIVMatches = slotFrame;
|
||||
yield return partial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace PKHeX.Core
|
|||
5 => EncounterGenerator5.GetEncounters(pkm),
|
||||
6 => EncounterGenerator6.GetEncounters(pkm),
|
||||
7 => EncounterGenerator7.GetEncounters(pkm),
|
||||
8 => EncounterGenerator8.GetEncounters(pkm, info),
|
||||
8 => EncounterGenerator8.GetEncounters(pkm),
|
||||
_ => Array.Empty<IEncounterable>(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
{
|
||||
public static class Overworld8RNG
|
||||
{
|
||||
public static bool ValidateOverworldEncounter(PKM pk, Shiny shiny = Shiny.FixedValue, int flawless = 0)
|
||||
public static bool ValidateOverworldEncounter(PKM pk, Shiny shiny = Shiny.FixedValue, int flawless = -1)
|
||||
{
|
||||
var seed = GetOriginalSeed(pk);
|
||||
return ValidateOverworldEncounter(pk, seed, shiny, flawless);
|
||||
}
|
||||
|
||||
public static bool ValidateOverworldEncounter(PKM pk, uint seed, Shiny shiny = Shiny.FixedValue, int flawless = 0)
|
||||
public static bool ValidateOverworldEncounter(PKM pk, uint seed, Shiny shiny = Shiny.FixedValue, int flawless = -1)
|
||||
{
|
||||
// is the seed Xoroshiro determined, or just truncated state?
|
||||
if (seed == uint.MaxValue)
|
||||
|
@ -23,7 +23,7 @@
|
|||
if (!IsPIDValid(pk, pid, shiny))
|
||||
return false;
|
||||
|
||||
var actualCount = flawless == 0 ? GetIsMatchEnd(pk, xoro) : GetIsMatchEnd(pk, xoro, flawless, flawless);
|
||||
var actualCount = flawless == -1 ? GetIsMatchEnd(pk, xoro) : GetIsMatchEnd(pk, xoro, flawless, flawless);
|
||||
return actualCount != NoMatchIVs;
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,12 @@
|
|||
|
||||
private static int GetIsMatchEnd(PKM pk, Xoroshiro128Plus xoro, int start = 0, int end = 3)
|
||||
{
|
||||
bool skip1 = start == 0 && end == 3;
|
||||
for (int iv_count = start; iv_count <= end; iv_count++)
|
||||
{
|
||||
if (skip1 && iv_count == 1)
|
||||
continue;
|
||||
|
||||
var copy = xoro;
|
||||
int[] ivs = { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET };
|
||||
const int MAX = 31;
|
||||
|
|
|
@ -69,6 +69,8 @@ namespace PKHeX.Core
|
|||
if (!EncountersHOME.IsValidDateWC8(w.Species, date))
|
||||
data.AddLine(GetInvalid(LDateOutsideDistributionWindow));
|
||||
}
|
||||
else if (data.EncounterMatch is IOverworldCorrelation8 { HasOverworldCorrelation: true } z && !z.IsOverworldCorrelationCorrect(pkm))
|
||||
data.AddLine(GetInvalid(LPIDTypeMismatch));
|
||||
|
||||
VerifyMiscFatefulEncounter(data);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue