mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
Misc updates
possibly gonna update the iencounterable api for criteria check/enforcement, rather than just generating random encounter data.
This commit is contained in:
parent
03ad20dd16
commit
c2422d6927
5 changed files with 133 additions and 2 deletions
|
@ -547,7 +547,7 @@ namespace PKHeX.Core
|
||||||
/// <returns>Highest value the value can be.</returns>
|
/// <returns>Highest value the value can be.</returns>
|
||||||
public static int GetMaximumIV(this PKM pk, int index, bool Allow30 = false)
|
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 - 1;
|
||||||
return pk.MaxIV;
|
return pk.MaxIV;
|
||||||
}
|
}
|
||||||
|
@ -593,6 +593,20 @@ namespace PKHeX.Core
|
||||||
pkm.SetHatchMemory6();
|
pkm.SetHatchMemory6();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Force hatches a PKM by applying the current species name and a valid Met Location from the origin game.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pkm">PKM to apply hatch details to</param>
|
||||||
|
/// <param name="origin">Game the egg originated from</param>
|
||||||
|
/// <param name="dest">Game the egg is currently present on</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximizes the <see cref="PKM.CurrentFriendship"/>. If the <see cref="PKM.IsEgg"/>, the hatch counter is set to 1.
|
/// Maximizes the <see cref="PKM.CurrentFriendship"/>. If the <see cref="PKM.IsEgg"/>, the hatch counter is set to 1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
11
PKHeX.Core/Game/Gender.cs
Normal file
11
PKHeX.Core/Game/Gender.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
namespace PKHeX.Core
|
||||||
|
{
|
||||||
|
public enum Gender : byte
|
||||||
|
{
|
||||||
|
Male = 0,
|
||||||
|
Female = 1,
|
||||||
|
|
||||||
|
Genderless = 2,
|
||||||
|
Random = Genderless,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
namespace PKHeX.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Object that can be fed to a <see cref="IEncounterable"/> converter to ensure that the resulting <see cref="PKM"/> meets rough specifications.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -132,5 +132,14 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
return !(t.IsFishingRodType() || (t & SlotType.Rock_Smash) != 0);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,6 +294,17 @@ namespace PKHeX.Core
|
||||||
/// Gets a random valid gender for the entry.
|
/// Gets a random valid gender for the entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int RandomGender
|
public int RandomGender
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var fix = FixedGender;
|
||||||
|
return fix >= 0 ? fix : Util.Rand.Next(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDualGender => FixedGender < 0;
|
||||||
|
|
||||||
|
public int FixedGender
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -303,7 +314,7 @@ namespace PKHeX.Core
|
||||||
return 1;
|
return 1;
|
||||||
if (OnlyMale)
|
if (OnlyMale)
|
||||||
return 0;
|
return 0;
|
||||||
return Util.Rand.Next(2);
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue