mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 00:07:15 +00:00
Cleanup
Removed unnecessary parenthesis Simplified use of linq Fixed encounterstatic error (wrong variable referenced in linq)
This commit is contained in:
parent
db642a257b
commit
cd9987ed09
4 changed files with 32 additions and 28 deletions
|
@ -52,56 +52,57 @@
|
|||
{
|
||||
public static bool Contains(this GameVersion g1, GameVersion g2)
|
||||
{
|
||||
if (g1 == g2 || g1 == GameVersion.Any) return true;
|
||||
if (g1 == g2 || g1 == GameVersion.Any)
|
||||
return true;
|
||||
|
||||
switch (g1)
|
||||
{
|
||||
case GameVersion.RBY:
|
||||
return (g2 == GameVersion.RD || g2 == GameVersion.BU || g2 == GameVersion.YW || g2 == GameVersion.GN);
|
||||
return g2 == GameVersion.RD || g2 == GameVersion.BU || g2 == GameVersion.YW || g2 == GameVersion.GN;
|
||||
case GameVersion.Gen1:
|
||||
return ( GameVersion.RBY.Contains(g2) || g2 == GameVersion.Stadium || g2 == GameVersion.EventsGBGen1 || g2 == GameVersion.VCEvents);
|
||||
return GameVersion.RBY.Contains(g2) || g2 == GameVersion.Stadium || g2 == GameVersion.EventsGBGen1 || g2 == GameVersion.VCEvents;
|
||||
case GameVersion.Stadium:
|
||||
case GameVersion.EventsGBGen1:
|
||||
case GameVersion.VCEvents:
|
||||
return GameVersion.RBY.Contains(g2);
|
||||
|
||||
case GameVersion.GS: return (g2 == GameVersion.GD || g2 == GameVersion.SV);
|
||||
case GameVersion.GS: return g2 == GameVersion.GD || g2 == GameVersion.SV;
|
||||
case GameVersion.GSC:
|
||||
return (GameVersion.GS.Contains(g2) || g2 == GameVersion.C);
|
||||
return GameVersion.GS.Contains(g2) || g2 == GameVersion.C;
|
||||
case GameVersion.Gen2:
|
||||
return (GameVersion.GSC.Contains(g2) || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGBGen2);
|
||||
return GameVersion.GSC.Contains(g2) || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGBGen2;
|
||||
case GameVersion.Stadium2:
|
||||
case GameVersion.EventsGBGen2:
|
||||
return GameVersion.GSC.Contains(g2);
|
||||
case GameVersion.GBCartEraOnly:
|
||||
return g2 == GameVersion.Stadium || g2 == GameVersion.Stadium2 || g2 == GameVersion.EventsGBGen1 || g2 == GameVersion.EventsGBGen2;
|
||||
|
||||
case GameVersion.RS: return (g2 == GameVersion.R || g2 == GameVersion.S);
|
||||
case GameVersion.FRLG: return (g2 == GameVersion.FR || g2 == GameVersion.LG);
|
||||
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));
|
||||
case GameVersion.RS: return g2 == GameVersion.R || g2 == GameVersion.S;
|
||||
case GameVersion.FRLG: return g2 == GameVersion.FR || g2 == GameVersion.LG;
|
||||
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);
|
||||
case GameVersion.Gen3:
|
||||
return (GameVersion.RS.Contains(g2) || g2 == GameVersion.E || GameVersion.FRLG.Contains(g2) || GameVersion.CXD.Contains(g2) || g2 == GameVersion.RSBOX);
|
||||
return GameVersion.RS.Contains(g2) || g2 == GameVersion.E || GameVersion.FRLG.Contains(g2) || GameVersion.CXD.Contains(g2) || g2 == GameVersion.RSBOX;
|
||||
|
||||
case GameVersion.DP: return (g2 == GameVersion.D || g2 == GameVersion.P);
|
||||
case GameVersion.HGSS: return (g2 == GameVersion.HG || g2 == GameVersion.SS);
|
||||
case GameVersion.BATREV: return (GameVersion.DP.Contains(g2) || g2 == GameVersion.Pt || GameVersion.HGSS.Contains(g2));
|
||||
case GameVersion.DP: return g2 == GameVersion.D || g2 == GameVersion.P;
|
||||
case GameVersion.HGSS: return g2 == GameVersion.HG || g2 == GameVersion.SS;
|
||||
case GameVersion.BATREV: return GameVersion.DP.Contains(g2) || g2 == GameVersion.Pt || GameVersion.HGSS.Contains(g2);
|
||||
case GameVersion.Gen4:
|
||||
return (GameVersion.DP.Contains(g2) || g2 == GameVersion.Pt || GameVersion.HGSS.Contains(g2) || g2 == GameVersion.BATREV);
|
||||
return GameVersion.DP.Contains(g2) || g2 == GameVersion.Pt || GameVersion.HGSS.Contains(g2) || g2 == GameVersion.BATREV;
|
||||
|
||||
case GameVersion.BW: return (g2 == GameVersion.B || g2 == GameVersion.W);
|
||||
case GameVersion.B2W2: return (g2 == GameVersion.B2 || g2 == GameVersion.W2);
|
||||
case GameVersion.BW: return g2 == GameVersion.B || g2 == GameVersion.W;
|
||||
case GameVersion.B2W2: return g2 == GameVersion.B2 || g2 == GameVersion.W2;
|
||||
case GameVersion.Gen5:
|
||||
return (GameVersion.BW.Contains(g2) || GameVersion.B2W2.Contains(g2));
|
||||
return GameVersion.BW.Contains(g2) || GameVersion.B2W2.Contains(g2);
|
||||
|
||||
case GameVersion.XY: return (g2 == GameVersion.X || g2 == GameVersion.Y);
|
||||
case GameVersion.ORAS: return (g2 == GameVersion.OR || g2 == GameVersion.AS);
|
||||
case GameVersion.XY: return g2 == GameVersion.X || g2 == GameVersion.Y;
|
||||
case GameVersion.ORAS: return g2 == GameVersion.OR || g2 == GameVersion.AS;
|
||||
case GameVersion.Gen6:
|
||||
return (GameVersion.XY.Contains(g2) || GameVersion.ORAS.Contains(g2));
|
||||
return GameVersion.XY.Contains(g2) || GameVersion.ORAS.Contains(g2);
|
||||
|
||||
case GameVersion.SM:
|
||||
case GameVersion.Gen7:
|
||||
return (g2 == GameVersion.SN || g2 == GameVersion.MN);
|
||||
return g2 == GameVersion.SN || g2 == GameVersion.MN;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
|
|
|
@ -959,7 +959,7 @@ namespace PKHeX.Core
|
|||
return new CheckResult(Severity.Invalid, V80, CheckIdentifier.Encounter);
|
||||
|
||||
var s = EncounterMatch as List<EncounterStatic>;
|
||||
var sgb = s?.Where(v => GameVersion.GBCartEraOnly.Contains(v.Version) || v.Version == GameVersion.VCEvents).FirstOrDefault();
|
||||
var sgb = s?.FirstOrDefault(v => GameVersion.GBCartEraOnly.Contains(v.Version) || v.Version == GameVersion.VCEvents);
|
||||
if (sgb != null)
|
||||
{
|
||||
bool exceptions = false;
|
||||
|
|
|
@ -1108,8 +1108,11 @@ namespace PKHeX.Core
|
|||
var em = e != null ? vs.Reverse().First(evo => e.Any(slot => slot.Species == evo.Species)).Species : invalid;
|
||||
var tm = t?.Species ?? invalid;
|
||||
|
||||
if (s != null && (s?.Any(m => m.Moves[0] != 0 && pkm.Moves.Contains(m.Moves[0])) ?? false))
|
||||
return new Tuple<object, int, byte>(s, s.Where(m => m.Moves[0] != 0 && pkm.Moves.Contains(m.Moves[0])).First().Level, 20); // special move
|
||||
// check for special move static encounter
|
||||
var special = s?.FirstOrDefault(m => m.Moves[0] != 0 && pkm.Moves.Contains(m.Moves[0]));
|
||||
if (special != null) // return with high priority
|
||||
return new Tuple<object, int, byte>(s, special.Level, 20);
|
||||
|
||||
if (game == GameVersion.GSC)
|
||||
{
|
||||
if (t != null && t.TID != 0)
|
||||
|
@ -1120,7 +1123,7 @@ namespace PKHeX.Core
|
|||
if (em <= sm && em <= tm)
|
||||
return new Tuple<object, int, byte>(e, e.Where(slot => slot.Species == em).Min(slot => slot.LevelMin), 3);
|
||||
if (sm <= em && sm <= tm)
|
||||
return new Tuple<object, int, byte>(s, s.Where(slot => slot.Species == em).Min(slot => slot.Level), 2);
|
||||
return new Tuple<object, int, byte>(s, s.Where(slot => slot.Species == sm).Min(slot => slot.Level), 2);
|
||||
if (tm <= sm && tm <= em)
|
||||
return new Tuple<object, int, byte>(t, t.Level, 1);
|
||||
return null;
|
||||
|
|
|
@ -1175,11 +1175,11 @@ namespace PKHeX.Core
|
|||
201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
|
||||
221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 234, //233: Pokéwalker
|
||||
};
|
||||
internal static int[] GiftEggLocation4 =
|
||||
internal static readonly int[] GiftEggLocation4 =
|
||||
{
|
||||
2009, 2010, 2011, 2013, 2014
|
||||
};
|
||||
internal static int[] EggLocations4 =
|
||||
internal static readonly int[] EggLocations4 =
|
||||
{
|
||||
2000, 2002, 2009, 2010, 2011, 2013, 2014
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue