PKHeX/PKHeX.Core/Game/GameUtil.cs
Kurt 5e59e20ea1 Store matched encounter generation
previously was only defined for gen1/2, why not all gens
can now query encounters in Core for encounters per generation via
reflection; can help group encounters for data vis or be faster than
getting individual gen numbers
2017-12-18 16:17:21 -08:00

138 lines
4.3 KiB
C#

namespace PKHeX.Core
{
/// <summary>
/// Utility class for <see cref="GameVersion"/> logic.
/// </summary>
public static class GameUtil
{
/// <summary>Determines the Version Grouping of an input Version ID</summary>
/// <param name="Version">Version of which to determine the group</param>
/// <returns>Version Group Identifier or Invalid if type cannot be determined.</returns>
public static GameVersion GetMetLocationVersionGroup(GameVersion Version)
{
switch (Version)
{
case GameVersion.CXD:
return GameVersion.CXD;
case GameVersion.GO:
return GameVersion.GO;
case GameVersion.RBY:
case GameVersion.RD:
case GameVersion.BU:
case GameVersion.YW:
case GameVersion.GN:
return GameVersion.RBY;
case GameVersion.GS:
case GameVersion.GD:
case GameVersion.SV:
case GameVersion.C:
return GameVersion.GSC;
case GameVersion.R:
case GameVersion.S:
return GameVersion.RS;
case GameVersion.E:
return GameVersion.E;
case GameVersion.FR:
case GameVersion.LG:
return GameVersion.FR;
case GameVersion.D:
case GameVersion.P:
return GameVersion.DP;
case GameVersion.Pt:
return GameVersion.Pt;
case GameVersion.HG:
case GameVersion.SS:
return GameVersion.HGSS;
case GameVersion.B:
case GameVersion.W:
return GameVersion.BW;
case GameVersion.B2:
case GameVersion.W2:
return GameVersion.B2W2;
case GameVersion.X:
case GameVersion.Y:
return GameVersion.XY;
case GameVersion.OR:
case GameVersion.AS:
return GameVersion.ORAS;
case GameVersion.SN:
case GameVersion.MN:
return GameVersion.SM;
case GameVersion.US:
case GameVersion.UM:
return GameVersion.USUM;
default:
return GameVersion.Invalid;
}
}
/// <summary>
/// Gets a Version ID from the end of that Generation
/// </summary>
/// <param name="generation">Generation ID</param>
/// <returns>Version ID from requested generation. If none, return Unknown.</returns>
public static GameVersion GetVersion(int generation)
{
switch (generation)
{
case 1: return GameVersion.RBY;
case 2: return GameVersion.C;
case 3: return GameVersion.E;
case 4: return GameVersion.SS;
case 5: return GameVersion.W2;
case 6: return GameVersion.AS;
case 7: return GameVersion.UM;
default:
return GameVersion.Unknown;
}
}
public static int GetGeneration(GameVersion game)
{
game = GetMetLocationVersionGroup(game); // get group
switch (game)
{
default: return -1;
case GameVersion.RBY: return 1;
case GameVersion.GSC: return 2;
case GameVersion.CXD:
case GameVersion.RS: case GameVersion.E:
case GameVersion.FR: case GameVersion.LG:
return 3;
case GameVersion.DP: case GameVersion.Pt:
case GameVersion.HGSS:
return 4;
case GameVersion.BW:
case GameVersion.B2W2:
return 5;
case GameVersion.XY:
case GameVersion.ORAS:
return 6;
case GameVersion.SM:
case GameVersion.USUM:
return 7;
}
}
}
}