2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-10-29 22:41:55 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Game Version ID enum shared between actual Version IDs and lumped version groupings.
|
|
|
|
|
/// </summary>
|
2016-10-29 22:41:55 +00:00
|
|
|
|
public enum GameVersion
|
|
|
|
|
{
|
|
|
|
|
// Indicators
|
|
|
|
|
Invalid = -2,
|
|
|
|
|
Any = -1,
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
|
|
|
|
|
// Version IDs, also stored in PKM structure
|
|
|
|
|
/*Gen3*/ S = 1, R = 2, E = 3, FR = 4, LG = 5, CXD = 15,
|
|
|
|
|
/*Gen4*/ D = 10, P = 11, Pt = 12, HG = 7, SS = 8,
|
|
|
|
|
/*Gen5*/ W = 20, B = 21, W2 = 22, B2 = 23,
|
|
|
|
|
/*Gen6*/ X = 24, Y = 25, AS = 26, OR = 27,
|
2017-06-07 04:59:29 +00:00
|
|
|
|
/*Gen7*/ SN = 30, MN = 31, US = 32, UM = 33,
|
2017-01-25 11:29:38 +00:00
|
|
|
|
/* GO */ GO = 34,
|
2017-06-07 04:59:29 +00:00
|
|
|
|
/* VC1*/ RD = 35, GN = 36, BU = 37, YW = 38, // GN = Blue for international release
|
2017-09-04 02:51:29 +00:00
|
|
|
|
/* VC2*/ GD = 39, SV = 40, C = 41, // Crystal is unused
|
|
|
|
|
|
|
|
|
|
// Not actually stored values, but assigned as properties.
|
2016-10-29 22:41:55 +00:00
|
|
|
|
|
|
|
|
|
// Game Groupings (SaveFile type)
|
2017-09-04 02:51:29 +00:00
|
|
|
|
/*SAV1*/ RB, RBY,
|
|
|
|
|
/*SAV2*/ GS, GSC,
|
2018-03-31 04:37:01 +00:00
|
|
|
|
/*SAV3*/ RS, RSE, FRLG, RSBOX, COLO, XD,
|
|
|
|
|
/*SAV4*/ DP, DPPt, HGSS, BATREV,
|
2017-09-04 02:51:29 +00:00
|
|
|
|
/*SAV5*/ BW, B2W2,
|
|
|
|
|
/*SAV6*/ XY, ORASDEMO, ORAS,
|
|
|
|
|
/*SAV7*/ SM, USUM,
|
2016-10-29 22:41:55 +00:00
|
|
|
|
|
|
|
|
|
// Extra Game Groupings (Generation)
|
2017-02-14 02:06:01 +00:00
|
|
|
|
Gen1, Gen2, Gen3, Gen4, Gen5, Gen6, Gen7,
|
2017-04-02 15:16:53 +00:00
|
|
|
|
GBCartEraOnly,
|
|
|
|
|
Stadium,
|
|
|
|
|
Stadium2,
|
2017-04-04 02:59:29 +00:00
|
|
|
|
EventsGBGen1,
|
|
|
|
|
EventsGBGen2,
|
|
|
|
|
VCEvents
|
2016-10-29 22:41:55 +00:00
|
|
|
|
}
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public static partial class Extensions
|
2017-03-26 09:39:13 +00:00
|
|
|
|
{
|
2018-03-30 04:00:38 +00:00
|
|
|
|
public static int GetGeneration(this GameVersion g)
|
|
|
|
|
{
|
|
|
|
|
if (GameVersion.Gen1.Contains(g)) return 1;
|
|
|
|
|
if (GameVersion.Gen2.Contains(g)) return 2;
|
|
|
|
|
if (GameVersion.Gen3.Contains(g)) return 3;
|
|
|
|
|
if (GameVersion.Gen4.Contains(g)) return 4;
|
|
|
|
|
if (GameVersion.Gen5.Contains(g)) return 5;
|
|
|
|
|
if (GameVersion.Gen6.Contains(g)) return 6;
|
|
|
|
|
if (GameVersion.Gen7.Contains(g)) return 7;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2017-03-26 09:39:13 +00:00
|
|
|
|
public static bool Contains(this GameVersion g1, GameVersion g2)
|
|
|
|
|
{
|
2017-04-04 03:28:04 +00:00
|
|
|
|
if (g1 == g2 || g1 == GameVersion.Any)
|
|
|
|
|
return true;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
|
|
|
|
switch (g1)
|
|
|
|
|
{
|
2017-07-06 23:03:41 +00:00
|
|
|
|
case GameVersion.RB:
|
|
|
|
|
return g2 == GameVersion.RD || g2 == GameVersion.BU || g2 == GameVersion.GN;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
case GameVersion.RBY:
|
2017-07-06 23:03:41 +00:00
|
|
|
|
return GameVersion.RB.Contains(g2) || g2 == GameVersion.YW;
|
2017-03-26 12:02:04 +00:00
|
|
|
|
case GameVersion.Gen1:
|
2017-04-04 03:28:04 +00:00
|
|
|
|
return GameVersion.RBY.Contains(g2) || g2 == GameVersion.Stadium || g2 == GameVersion.EventsGBGen1 || g2 == GameVersion.VCEvents;
|
2017-04-02 15:16:53 +00:00
|
|
|
|
case GameVersion.Stadium:
|
2017-04-04 02:59:29 +00:00
|
|
|
|
case GameVersion.EventsGBGen1:
|
|
|
|
|
case GameVersion.VCEvents:
|
2017-09-04 02:51:29 +00:00
|
|
|
|
goto case GameVersion.RBY;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.GS: return g2 == GameVersion.GD || g2 == GameVersion.SV;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
case GameVersion.GSC:
|
2017-04-04 03:28:04 +00:00
|
|
|
|
return GameVersion.GS.Contains(g2) || g2 == GameVersion.C;
|
2017-03-26 12:02:04 +00:00
|
|
|
|
case GameVersion.Gen2:
|
2017-04-04 03:28:04 +00:00
|
|
|
|
return GameVersion.GSC.Contains(g2) || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGBGen2;
|
2017-04-02 15:16:53 +00:00
|
|
|
|
case GameVersion.Stadium2:
|
2017-04-04 02:59:29 +00:00
|
|
|
|
case GameVersion.EventsGBGen2:
|
2017-09-04 02:51:29 +00:00
|
|
|
|
goto case GameVersion.GSC;
|
2017-04-02 15:16:53 +00:00
|
|
|
|
case GameVersion.GBCartEraOnly:
|
2017-04-04 02:59:29 +00:00
|
|
|
|
return g2 == GameVersion.Stadium || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGBGen1 || g2 == GameVersion.EventsGBGen2;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.RS: return g2 == GameVersion.R || g2 == GameVersion.S;
|
2018-03-31 04:37:01 +00:00
|
|
|
|
case GameVersion.RSE:
|
|
|
|
|
return GameVersion.RS.Contains(g2) || g2 == GameVersion.E;
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.FRLG: return g2 == GameVersion.FR || g2 == GameVersion.LG;
|
2018-04-29 05:56:10 +00:00
|
|
|
|
case GameVersion.COLO:
|
|
|
|
|
case GameVersion.XD: return g2 == GameVersion.CXD;
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.CXD: return g2 == GameVersion.COLO || g2 == GameVersion.XD;
|
|
|
|
|
case GameVersion.RSBOX: return GameVersion.RS.Contains(g2) || g2 == GameVersion.E || GameVersion.FRLG.Contains(g2);
|
2017-03-26 09:39:13 +00:00
|
|
|
|
case GameVersion.Gen3:
|
2018-03-31 04:37:01 +00:00
|
|
|
|
return GameVersion.RSE.Contains(g2) || GameVersion.FRLG.Contains(g2) || GameVersion.CXD.Contains(g2) || g2 == GameVersion.RSBOX;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.DP: return g2 == GameVersion.D || g2 == GameVersion.P;
|
|
|
|
|
case GameVersion.HGSS: return g2 == GameVersion.HG || g2 == GameVersion.SS;
|
2018-03-31 04:37:01 +00:00
|
|
|
|
case GameVersion.DPPt:
|
|
|
|
|
return GameVersion.DP.Contains(g2) || g2 == GameVersion.Pt;
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.BATREV: return GameVersion.DP.Contains(g2) || g2 == GameVersion.Pt || GameVersion.HGSS.Contains(g2);
|
2017-03-26 09:39:13 +00:00
|
|
|
|
case GameVersion.Gen4:
|
2018-03-31 04:37:01 +00:00
|
|
|
|
return GameVersion.DPPt.Contains(g2) || GameVersion.HGSS.Contains(g2) || g2 == GameVersion.BATREV;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.BW: return g2 == GameVersion.B || g2 == GameVersion.W;
|
|
|
|
|
case GameVersion.B2W2: return g2 == GameVersion.B2 || g2 == GameVersion.W2;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
case GameVersion.Gen5:
|
2017-04-04 03:28:04 +00:00
|
|
|
|
return GameVersion.BW.Contains(g2) || GameVersion.B2W2.Contains(g2);
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
2017-04-04 03:28:04 +00:00
|
|
|
|
case GameVersion.XY: return g2 == GameVersion.X || g2 == GameVersion.Y;
|
|
|
|
|
case GameVersion.ORAS: return g2 == GameVersion.OR || g2 == GameVersion.AS;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
case GameVersion.Gen6:
|
2017-04-04 03:28:04 +00:00
|
|
|
|
return GameVersion.XY.Contains(g2) || GameVersion.ORAS.Contains(g2);
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
|
|
|
|
case GameVersion.SM:
|
2017-04-04 03:28:04 +00:00
|
|
|
|
return g2 == GameVersion.SN || g2 == GameVersion.MN;
|
2017-09-02 15:41:36 +00:00
|
|
|
|
case GameVersion.USUM:
|
|
|
|
|
return g2 == GameVersion.US || g2 == GameVersion.UM;
|
|
|
|
|
case GameVersion.Gen7:
|
|
|
|
|
return GameVersion.SM.Contains(g2) || GameVersion.USUM.Contains(g2);
|
2017-03-26 09:39:13 +00:00
|
|
|
|
|
|
|
|
|
default: return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-23 15:25:32 +00:00
|
|
|
|
public static bool IsValid(this GameVersion g) => 0 < g && g <= GameVersion.RB;
|
2017-03-26 09:39:13 +00:00
|
|
|
|
}
|
2016-10-29 22:41:55 +00:00
|
|
|
|
}
|