mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-22 20:13:06 +00:00
Flag invalid mystry mew seeds, like channel
This commit is contained in:
parent
acdb9f12b3
commit
c6f12515c6
2 changed files with 50 additions and 8 deletions
|
@ -48,15 +48,25 @@ public sealed class EncounterGenerator3 : IEncounterGenerator
|
||||||
}
|
}
|
||||||
if (e is not EncounterSlot3 slot)
|
if (e is not EncounterSlot3 slot)
|
||||||
{
|
{
|
||||||
if (e is WC3 { TID16: 40122 } channel)
|
if (e is WC3 wc3)
|
||||||
{
|
{
|
||||||
var chk = ChannelJirachi.GetPossible(info.PIDIV.OriginSeed);
|
if (wc3.TID16 == 40122) // CHANNEL Jirachi
|
||||||
if (chk.Pattern is not ChannelJirachiRandomResult.None)
|
{
|
||||||
info.PIDIV = info.PIDIV.AsEncounteredVia(new(chk.Seed, LeadRequired.None));
|
var chk = ChannelJirachi.GetPossible(info.PIDIV.OriginSeed);
|
||||||
else
|
if (chk.Pattern is not ChannelJirachiRandomResult.None)
|
||||||
info.ManualFlag = EncounterYieldFlag.InvalidPIDIV;
|
info.PIDIV = info.PIDIV.AsEncounteredVia(new(chk.Seed, LeadRequired.None));
|
||||||
yield return channel;
|
else
|
||||||
yield break;
|
info.ManualFlag = EncounterYieldFlag.InvalidPIDIV;
|
||||||
|
yield return wc3;
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
if (wc3.TID16 == 06930) // MYSTRY Mew
|
||||||
|
{
|
||||||
|
if (!MystryMew.IsValidSeed(info.PIDIV.OriginSeed))
|
||||||
|
info.ManualFlag = EncounterYieldFlag.InvalidPIDIV;
|
||||||
|
yield return wc3;
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
yield return e;
|
yield return e;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -54,6 +54,13 @@ public static class MystryMew
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the seed is a known seed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seed">Origin seed (for the PID/IV)</param>
|
||||||
|
/// <returns>True if the seed is known.</returns>
|
||||||
|
public static bool IsValidSeed(uint seed) => GetSeedIndex(seed) != -1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the seed is a known seed.
|
/// Checks if the seed is a known seed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -72,4 +79,29 @@ public static class MystryMew
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the index and subindex of the seed in the known seed list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seed">Origin seed (for the PID/IV)</param>
|
||||||
|
/// <returns>Tuple of indexes; -1 if not found.</returns>
|
||||||
|
public static (int Index, int SubIndex) GetSeedIndexes(uint seed)
|
||||||
|
{
|
||||||
|
var seeds = Seeds;
|
||||||
|
if (seed <= ushort.MaxValue)
|
||||||
|
{
|
||||||
|
var index = seeds.BinarySearch((ushort)seed);
|
||||||
|
return (index, -1);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
seed = LCRNG.Prev5(seed);
|
||||||
|
if (seed <= ushort.MaxValue)
|
||||||
|
{
|
||||||
|
var index = seeds.BinarySearch((ushort)seed);
|
||||||
|
return (index, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (-1, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue