diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs
index eb963b9e0..5943c304a 100644
--- a/PKHeX.Core/Editing/CommonEdits.cs
+++ b/PKHeX.Core/Editing/CommonEdits.cs
@@ -547,7 +547,7 @@ namespace PKHeX.Core
/// Highest value the value can be.
public static int GetMaximumIV(this PKM pk, int index, bool Allow30 = false)
{
- if (pk.IVs[index] == pk.MaxIV && Allow30)
+ if (pk.GetIV(index) == pk.MaxIV && Allow30)
return pk.MaxIV - 1;
return pk.MaxIV;
}
@@ -593,6 +593,20 @@ namespace PKHeX.Core
pkm.SetHatchMemory6();
}
+ ///
+ /// Force hatches a PKM by applying the current species name and a valid Met Location from the origin game.
+ ///
+ /// PKM to apply hatch details to
+ /// Game the egg originated from
+ /// Game the egg is currently present on
+ public static void SetEggMetData(this PKM pkm, GameVersion origin, GameVersion dest)
+ {
+ bool traded = origin == dest;
+ var today = pkm.MetDate = DateTime.Today;
+ pkm.Egg_Location = EncounterSuggestion.GetSuggestedEncounterEggLocationEgg(pkm, traded);
+ pkm.EggMetDate = today;
+ }
+
///
/// Maximizes the . If the , the hatch counter is set to 1.
///
diff --git a/PKHeX.Core/Game/Gender.cs b/PKHeX.Core/Game/Gender.cs
new file mode 100644
index 000000000..4221dbd9c
--- /dev/null
+++ b/PKHeX.Core/Game/Gender.cs
@@ -0,0 +1,11 @@
+namespace PKHeX.Core
+{
+ public enum Gender : byte
+ {
+ Male = 0,
+ Female = 1,
+
+ Genderless = 2,
+ Random = Genderless,
+ }
+}
diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs
new file mode 100644
index 000000000..012973e4a
--- /dev/null
+++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs
@@ -0,0 +1,86 @@
+namespace PKHeX.Core
+{
+ ///
+ /// Object that can be fed to a converter to ensure that the resulting meets rough specifications.
+ ///
+ public class EncounterCriteria
+ {
+ public static readonly EncounterCriteria Unrestricted = new EncounterCriteria();
+
+ public int Ability { get; set; } = -1;
+ public int Gender { get; set; } = -1;
+ public Nature Nature { get; set; } = Nature.Random;
+ public Shiny Shiny { get; set; } = Shiny.Random;
+
+ public int IV_HP { get; set; } = RandomIV;
+ public int IV_ATK { get; set; } = RandomIV;
+ public int IV_DEF { get; set; } = RandomIV;
+ public int IV_SPA { get; set; } = RandomIV;
+ public int IV_SPD { get; set; } = RandomIV;
+ public int IV_SPE { get; set; } = RandomIV;
+
+ public int HPType { get; set; } = -1;
+
+ private const int RandomIV = -1;
+
+ public bool IsIVsCompatible(int[] encounterIV, int gen)
+ {
+ var IVs = encounterIV;
+ if (!ivCanMatch(IV_HP , IVs[0])) return false;
+ if (!ivCanMatch(IV_ATK, IVs[1])) return false;
+ if (!ivCanMatch(IV_DEF, IVs[2])) return false;
+ if (!ivCanMatch(IV_SPE, IVs[3])) return false;
+ if (!ivCanMatch(IV_SPA, IVs[4])) return false;
+ if (!ivCanMatch(IV_SPD, IVs[5])) return false;
+
+ bool ivCanMatch(int spec, int enc)
+ {
+ if (spec >= 30 && gen >= 6) // hyper training possible
+ return true;
+ return enc == RandomIV || spec == enc;
+ }
+
+ return true;
+ }
+
+ public static EncounterCriteria GetCriteria(ShowdownSet s)
+ {
+ int gender = s.Gender == null ? -1 : PKX.GetGenderFromString(s.Gender);
+ return new EncounterCriteria
+ {
+ Gender = gender,
+ Ability = s.Ability,
+ IV_HP = s.IVs[0],
+ IV_ATK = s.IVs[1],
+ IV_DEF = s.IVs[2],
+ IV_SPE = s.IVs[3],
+ IV_SPA = s.IVs[4],
+ IV_SPD = s.IVs[5],
+ HPType = s.HiddenPowerType,
+
+ Nature = (Nature)s.Nature,
+ Shiny = s.Shiny ? Shiny.Always : Shiny.Never,
+ };
+ }
+
+ public Nature GetNature(Nature encValue)
+ {
+ if (encValue != Nature.Random)
+ return encValue;
+ if (Nature != Nature.Random)
+ return Nature;
+ return (Nature)Util.Rand.Next(25);
+ }
+
+ public int GetGender(int gender, PersonalInfo pkPersonalInfo)
+ {
+ if (gender >= 0)
+ return gender;
+ if (!pkPersonalInfo.IsDualGender)
+ return pkPersonalInfo.FixedGender;
+ if (Gender >= 0)
+ return Gender;
+ return pkPersonalInfo.RandomGender;
+ }
+ }
+}
diff --git a/PKHeX.Core/Legality/Enums/SlotType.cs b/PKHeX.Core/Legality/Enums/SlotType.cs
index d2036a33e..a8234f878 100644
--- a/PKHeX.Core/Legality/Enums/SlotType.cs
+++ b/PKHeX.Core/Legality/Enums/SlotType.cs
@@ -132,5 +132,14 @@ namespace PKHeX.Core
{
return !(t.IsFishingRodType() || (t & SlotType.Rock_Smash) != 0);
}
+
+ public static Ball GetBall(this SlotType t)
+ {
+ if (t == SlotType.BugContest)
+ return Ball.Sport;
+ if (t.IsSafariType())
+ return Ball.Safari;
+ return Ball.Poke;
+ }
}
}
diff --git a/PKHeX.Core/PersonalInfo/PersonalInfo.cs b/PKHeX.Core/PersonalInfo/PersonalInfo.cs
index 40668f8a2..26cac3246 100644
--- a/PKHeX.Core/PersonalInfo/PersonalInfo.cs
+++ b/PKHeX.Core/PersonalInfo/PersonalInfo.cs
@@ -294,6 +294,17 @@ namespace PKHeX.Core
/// Gets a random valid gender for the entry.
///
public int RandomGender
+ {
+ get
+ {
+ var fix = FixedGender;
+ return fix >= 0 ? fix : Util.Rand.Next(2);
+ }
+ }
+
+ public bool IsDualGender => FixedGender < 0;
+
+ public int FixedGender
{
get
{
@@ -303,7 +314,7 @@ namespace PKHeX.Core
return 1;
if (OnlyMale)
return 0;
- return Util.Rand.Next(2);
+ return -1;
}
}