From 78616e1ad533e01bcefbddfe1b701fae382dae90 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 27 Mar 2018 19:45:22 -0700 Subject: [PATCH] Add showdownset -> pkm encounter fetch test case Test parsing glaceon, input must equal output Test generating encounters for a specific version (exists only on Moon) Test generating encounters for the same version (add handling trainer data to permit Tutors) fixes error in VC generations-present fetch which allowed movesets from generations 3-6 lul exclude negative/invalid gameversions --- .../Generator/EncounterMovesetGenerator.cs | 2 +- .../Verifiers/VerifyCurrentMoves.cs | 2 +- Tests/PKHeX.Tests/PKHeX.Tests.csproj | 1 + .../PKHeX.Tests/Simulator/ShowdownSetTests.cs | 47 +++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 Tests/PKHeX.Tests/Simulator/ShowdownSetTests.cs diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs index 0145a52ad..f0dfc965d 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterMovesetGenerator.cs @@ -12,7 +12,7 @@ public static class EncounterMovesetGenerator /// /// List of possible values a can have. /// - private static readonly GameVersion[] Versions = ((GameVersion[]) Enum.GetValues(typeof(GameVersion))).Where(z => z < GameVersion.RB).Reverse().ToArray(); + private static readonly GameVersion[] Versions = ((GameVersion[]) Enum.GetValues(typeof(GameVersion))).Where(z => z < GameVersion.RB && z > 0).Reverse().ToArray(); /// /// Gets possible encounters that allow all moves requested to be learned. diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index e308a54c7..5784133f6 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -819,7 +819,7 @@ public static int[] GetGenMovesCheckOrder(PKM pkm) private static int[] GetGenMovesOrderVC(PKM pkm) { // VC case: check transfer games in reverse order (8, 7..) then past games. - int[] xfer = GetGenMovesOrder(pkm.Format, pkm.GenNumber); + int[] xfer = GetGenMovesOrder(pkm.Format, 7); int[] past = GetGenMovesCheckOrderGB(pkm, pkm.GenNumber); int end = xfer.Length; Array.Resize(ref xfer, xfer.Length + past.Length); diff --git a/Tests/PKHeX.Tests/PKHeX.Tests.csproj b/Tests/PKHeX.Tests/PKHeX.Tests.csproj index 6471d0d89..e26db097a 100644 --- a/Tests/PKHeX.Tests/PKHeX.Tests.csproj +++ b/Tests/PKHeX.Tests/PKHeX.Tests.csproj @@ -83,6 +83,7 @@ + diff --git a/Tests/PKHeX.Tests/Simulator/ShowdownSetTests.cs b/Tests/PKHeX.Tests/Simulator/ShowdownSetTests.cs new file mode 100644 index 000000000..0860edd95 --- /dev/null +++ b/Tests/PKHeX.Tests/Simulator/ShowdownSetTests.cs @@ -0,0 +1,47 @@ +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using PKHeX.Core; + +namespace PKHeX.Tests.Simulator +{ + [TestClass] + public class ShowdownSetTests + { + private const string SimulatorParse = "Set Parsing Tests"; + + [TestMethod] + [TestCategory(SimulatorParse)] + public void SimulatorGetParse() + { + var set = new ShowdownSet(SetGlaceonUSUMTutor); + Assert.AreEqual(SetGlaceonUSUMTutor, set.Text); + } + + [TestMethod] + [TestCategory(SimulatorParse)] + public void SimulatorGetEncounters() + { + var set = new ShowdownSet(SetGlaceonUSUMTutor); + var pk7 = new PK7 {Species = set.Species, AltForm = set.FormIndex, Moves = set.Moves}; + var encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN); + Assert.IsTrue(!encs.Any()); + pk7.HT_Name = "PKHeX"; + encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN); + Assert.IsTrue(encs.Any()); + } + + private const string SetGlaceonUSUMTutor = +@"Glaceon (F) @ Assault Vest +IVs: 0 Atk +EVs: 252 HP / 252 SpA / 4 SpD +Ability: Ice Body +Level: 100 +Shiny: Yes +Modest Nature +- Blizzard +- Water Pulse +- Shadow Ball +- Hyper Voice"; + + } +}