diff --git a/PKHeX.Core/Legality/RNG/PIDGenerator.cs b/PKHeX.Core/Legality/RNG/PIDGenerator.cs index 814895788..6e7cf9313 100644 --- a/PKHeX.Core/Legality/RNG/PIDGenerator.cs +++ b/PKHeX.Core/Legality/RNG/PIDGenerator.cs @@ -266,7 +266,7 @@ public static uint GetPokeWalkerPID(int TID, int SID, uint nature, int gender, i public static void SetValuesFromSeedMG5Shiny(PKM pk, uint seed) { var gv = seed >> 24; - var av = seed & 1; + var av = seed & 1; // arbitrary choice pk.PID = GetMG5ShinyPID(gv, av, pk.TID, pk.SID); SetRandomIVs(pk); } @@ -377,8 +377,6 @@ private static void SetRandomWildPID5(PKM pk, int nature, int ability, int gende seed ^= 1; } - if (seed % 25 != nature) - continue; if (((seed >> 16) & 1) != ability) continue; diff --git a/Tests/PKHeX.Core.Tests/Simulator/GeneratorTests.cs b/Tests/PKHeX.Core.Tests/Simulator/GeneratorTests.cs index 2ff121b00..29f4dcbfb 100644 --- a/Tests/PKHeX.Core.Tests/Simulator/GeneratorTests.cs +++ b/Tests/PKHeX.Core.Tests/Simulator/GeneratorTests.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using FluentAssertions; using PKHeX.Core; using Xunit; @@ -7,6 +8,12 @@ namespace PKHeX.Tests.Simulator { public class GeneratorTests { + static GeneratorTests() + { + if (!EncounterEvent.Initialized) + EncounterEvent.RefreshMGDB(); + } + public static IEnumerable PokemonGenerationTestData() { for (int i = 1; i <= 807; i++) @@ -33,5 +40,30 @@ public void PokemonGenerationReturnsLegalPokemon(int species) count++; } } + + [Fact] + public void CanGenerateMG5Case() + { + const Species spec = Species.Haxorus; + var pk = new PK5 {Species = (int) spec}; + var ez = EncounterMovesetGenerator.GenerateEncounters(pk, null, GameVersion.W2).OfType().FirstOrDefault(); + ez.Should().NotBeNull("Shiny Haxorus stationary encounter exists for B2/W2"); + + var criteria = new EncounterCriteria(); + var tr = new SimpleTrainerInfo + { + TID = 57600, + SID = 62446, + }; + for (var nature = Nature.Hardy; nature <= Nature.Quirky; nature++) + { + criteria.Nature = nature; + var pkm = ez.ConvertToPKM(tr, criteria); + pkm.Nature.Should().Be((int)nature, "not nature locked"); + pkm.IsShiny.Should().BeTrue("encounter is shiny locked"); + pkm.TID.Should().Be(tr.TID); + pkm.SID.Should().Be(tr.SID); + } + } } } \ No newline at end of file