Finish fix for gameversion passing

This commit is contained in:
Kurt 2016-11-08 22:10:32 -08:00
parent 4c477de985
commit db8d5cb5e0
2 changed files with 23 additions and 23 deletions

View file

@ -944,11 +944,11 @@ namespace PKHeX
if (!Legal.getCanLearnMachineMove(new PK6 {Species = t, EXP = PKX.getEXP(100, t)}, 19)) if (!Legal.getCanLearnMachineMove(new PK6 {Species = t, EXP = PKX.getEXP(100, t)}, 19))
return new CheckResult(Severity.Invalid, resultPrefix + "Memory: Argument Species cannot learn Fly.", CheckIdentifier.Memory); return new CheckResult(Severity.Invalid, resultPrefix + "Memory: Argument Species cannot learn Fly.", CheckIdentifier.Memory);
} }
if ((m == 16 || m == 48) && (t == 0 || !Legal.getCanKnowMove(pkm, t, 1))) if ((m == 16 || m == 48) && (t == 0 || !Legal.getCanKnowMove(pkm, t, GameVersion.Any)))
{ {
return new CheckResult(Severity.Invalid, resultPrefix + "Memory: Species cannot know this move.", CheckIdentifier.Memory); return new CheckResult(Severity.Invalid, resultPrefix + "Memory: Species cannot know this move.", CheckIdentifier.Memory);
} }
if (m == 49 && (t == 0 || !Legal.getCanRelearnMove(pkm, t, 1))) // {0} was able to remember {2} at {1}'s instruction. {4} that {3}. if (m == 49 && (t == 0 || !Legal.getCanRelearnMove(pkm, t, GameVersion.Any))) // {0} was able to remember {2} at {1}'s instruction. {4} that {3}.
{ {
return new CheckResult(Severity.Invalid, resultPrefix + "Memory: Species cannot relearn this move.", CheckIdentifier.Memory); return new CheckResult(Severity.Invalid, resultPrefix + "Memory: Species cannot relearn this move.", CheckIdentifier.Memory);
} }
@ -1001,7 +1001,7 @@ namespace PKHeX
return; return;
case 14: case 14:
if (!Legal.getCanBeCaptured(pkm.OT_TextVar, pkm.GenNumber, pkm.Version)) if (!Legal.getCanBeCaptured(pkm.OT_TextVar, pkm.GenNumber, (GameVersion)pkm.Version))
AddLine(Severity.Invalid, "OT Memory: Captured Species can not be captured in game.", CheckIdentifier.Memory); AddLine(Severity.Invalid, "OT Memory: Captured Species can not be captured in game.", CheckIdentifier.Memory);
else else
AddLine(Severity.Valid, "OT Memory: Captured Species can be captured in game.", CheckIdentifier.Memory); AddLine(Severity.Valid, "OT Memory: Captured Species can be captured in game.", CheckIdentifier.Memory);

View file

@ -150,9 +150,9 @@ namespace PKHeX
// Moves // Moves
internal static IEnumerable<int> getValidMoves(PKM pkm) internal static IEnumerable<int> getValidMoves(PKM pkm)
{ {
int version = pkm.Version; GameVersion version = (GameVersion)pkm.Version;
if (!pkm.IsUntraded) if (!pkm.IsUntraded)
version = -1; version = GameVersion.Any;
return getValidMoves(pkm, version, LVL: true, Relearn: false, Tutor: true, Machine: true); return getValidMoves(pkm, version, LVL: true, Relearn: false, Tutor: true, Machine: true);
} }
internal static IEnumerable<int> getValidRelearn(PKM pkm, int skipOption) internal static IEnumerable<int> getValidRelearn(PKM pkm, int skipOption)
@ -453,25 +453,25 @@ namespace PKHeX
return curr.Count() >= poss.Count(); return curr.Count() >= poss.Count();
} }
internal static bool getCanBeCaptured(int species, int gen, int version = -1) internal static bool getCanBeCaptured(int species, int gen, GameVersion version = GameVersion.Any)
{ {
switch (gen) switch (gen)
{ {
case 6: case 6:
switch (version) switch (version)
{ {
case -1: case GameVersion.Any:
return getCanBeCaptured(species, SlotsX, StaticX, XY:true) return getCanBeCaptured(species, SlotsX, StaticX, XY:true)
|| getCanBeCaptured(species, SlotsY, StaticY, XY:true) || getCanBeCaptured(species, SlotsY, StaticY, XY:true)
|| getCanBeCaptured(species, SlotsA, StaticA) || getCanBeCaptured(species, SlotsA, StaticA)
|| getCanBeCaptured(species, SlotsO, StaticO); || getCanBeCaptured(species, SlotsO, StaticO);
case (int)GameVersion.X: case GameVersion.X:
return getCanBeCaptured(species, SlotsX, StaticX, XY:true); return getCanBeCaptured(species, SlotsX, StaticX, XY:true);
case (int)GameVersion.Y: case GameVersion.Y:
return getCanBeCaptured(species, SlotsY, StaticY, XY:true); return getCanBeCaptured(species, SlotsY, StaticY, XY:true);
case (int)GameVersion.AS: case GameVersion.AS:
return getCanBeCaptured(species, SlotsA, StaticA); return getCanBeCaptured(species, SlotsA, StaticA);
case (int)GameVersion.OR: case GameVersion.OR:
return getCanBeCaptured(species, SlotsO, StaticO); return getCanBeCaptured(species, SlotsO, StaticO);
default: default:
@ -480,12 +480,12 @@ namespace PKHeX
case 7: case 7:
switch (version) switch (version)
{ {
case -1: case GameVersion.Any:
return getCanBeCaptured(species, SlotsSN, StaticSN) return getCanBeCaptured(species, SlotsSN, StaticSN)
|| getCanBeCaptured(species, SlotsMN, StaticMN); || getCanBeCaptured(species, SlotsMN, StaticMN);
case (int)GameVersion.SN: case GameVersion.SN:
return getCanBeCaptured(species, SlotsSN, StaticSN); return getCanBeCaptured(species, SlotsSN, StaticSN);
case (int)GameVersion.MN: case GameVersion.MN:
return getCanBeCaptured(species, SlotsMN, StaticMN); return getCanBeCaptured(species, SlotsMN, StaticMN);
default: default:
@ -506,19 +506,19 @@ namespace PKHeX
return false; return false;
} }
internal static bool getCanLearnMachineMove(PKM pkm, int move, int version = -1) internal static bool getCanLearnMachineMove(PKM pkm, int move, GameVersion version = GameVersion.Any)
{ {
return getValidMoves(pkm, version, Machine: true).Contains(move); return getValidMoves(pkm, version, Machine: true).Contains(move);
} }
internal static bool getCanRelearnMove(PKM pkm, int move, int version = -1) internal static bool getCanRelearnMove(PKM pkm, int move, GameVersion version = GameVersion.Any)
{ {
return getValidMoves(pkm, version, LVL: true, Relearn: true).Contains(move); return getValidMoves(pkm, version, LVL: true, Relearn: true).Contains(move);
} }
internal static bool getCanLearnMove(PKM pkm, int move, int version = -1) internal static bool getCanLearnMove(PKM pkm, int move, GameVersion version = GameVersion.Any)
{ {
return getValidMoves(pkm, version, Tutor: true, Machine: true).Contains(move); return getValidMoves(pkm, version, Tutor: true, Machine: true).Contains(move);
} }
internal static bool getCanKnowMove(PKM pkm, int move, int version = -1) internal static bool getCanKnowMove(PKM pkm, int move, GameVersion version = GameVersion.Any)
{ {
if (pkm.Species == 235 && !InvalidSketch.Contains(move)) if (pkm.Species == 235 && !InvalidSketch.Contains(move))
return true; return true;
@ -698,14 +698,14 @@ namespace PKHeX
IEnumerable<DexLevel> dl = getValidPreEvolutions(pkm); IEnumerable<DexLevel> dl = getValidPreEvolutions(pkm);
return table.Where(e => dl.Any(d => d.Species == e.Species)); return table.Where(e => dl.Any(d => d.Species == e.Species));
} }
private static IEnumerable<int> getValidMoves(PKM pkm, int Version, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false) private static IEnumerable<int> getValidMoves(PKM pkm, GameVersion Version, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false)
{ {
List<int> r = new List<int> { 0 }; List<int> r = new List<int> { 0 };
int species = pkm.Species; int species = pkm.Species;
int lvl = pkm.CurrentLevel; int lvl = pkm.CurrentLevel;
// Special (non Type) Tutor Availability // Special (non Type) Tutor Availability
bool moveTutor = Version == -1 || pkm.Format != pkm.GenNumber; bool moveTutor = Version == GameVersion.Any || pkm.Format != pkm.GenNumber;
// Add extra cases where tutors // Add extra cases where tutors
moveTutor |= pkm.AO; moveTutor |= pkm.AO;
moveTutor |= pkm.XY && !pkm.IsUntraded; moveTutor |= pkm.XY && !pkm.IsUntraded;
@ -735,18 +735,18 @@ namespace PKHeX
if (Relearn) r.AddRange(pkm.RelearnMoves); if (Relearn) r.AddRange(pkm.RelearnMoves);
return r.Distinct().ToArray(); return r.Distinct().ToArray();
} }
private static IEnumerable<int> getMoves(PKM pkm, int species, int lvl, int form, bool moveTutor, int Version, bool LVL, bool Tutor, bool Machine) private static IEnumerable<int> getMoves(PKM pkm, int species, int lvl, int form, bool moveTutor, GameVersion Version, bool LVL, bool Tutor, bool Machine)
{ {
List<int> r = new List<int> { 0 }; List<int> r = new List<int> { 0 };
for (int gen = pkm.GenNumber; gen <= pkm.Format; gen++) for (int gen = pkm.GenNumber; gen <= pkm.Format; gen++)
r.AddRange(getMoves(pkm, species, lvl, form, moveTutor, Version, LVL, Tutor, Machine, gen)); r.AddRange(getMoves(pkm, species, lvl, form, moveTutor, Version, LVL, Tutor, Machine, gen));
return r.Distinct(); return r.Distinct();
} }
private static IEnumerable<int> getMoves(PKM pkm, int species, int lvl, int form, bool moveTutor, int Version, bool LVL, bool Tutor, bool Machine, int Generation) private static IEnumerable<int> getMoves(PKM pkm, int species, int lvl, int form, bool moveTutor, GameVersion Version, bool LVL, bool Tutor, bool Machine, int Generation)
{ {
List<int> r = new List<int>(); List<int> r = new List<int>();
var ver = (GameVersion) Version; var ver = Version;
switch (Generation) switch (Generation)
{ {
case 6: case 6: