Tweak gen1+transfer checking

Add stadium exclusives (surfchu / amnesiaduck) which are flagged on gen7
This commit is contained in:
Kurt 2017-02-13 18:06:01 -08:00
parent 1990870744
commit 749aa97bb3
7 changed files with 91 additions and 45 deletions

View file

@ -39,6 +39,7 @@
SM = 109,
// Extra Game Groupings (Generation)
Gen1, Gen2, Gen3, Gen4, Gen5, Gen6, Gen7
Gen1, Gen2, Gen3, Gen4, Gen5, Gen6, Gen7,
SPECIAL, // Stadium
}
}

View file

@ -46,6 +46,8 @@ namespace PKHeX.Core
switch (pk.GenNumber)
{
case 6: parsePK6(pk); break;
case 1: parsePK7(pk); break;
case 7: parsePK7(pk); break;
}

View file

@ -115,12 +115,11 @@ namespace PKHeX.Core
return;
}
}
if (pkm.Format < 6)
// abort if specimen wasn't transferred x->6
if (pkm.Format < 6 || !(3 <= pkm.GenNumber && pkm.GenNumber <= 5))
return;
if (pkm.GenNumber >= 6)
return;
// When transferred to Generation 6, the Encryption Constant is copied from the PID.
// The PID is then checked to see if it becomes shiny with the new Shiny rules (>>4 instead of >>3)
// If the PID is nonshiny->shiny, the top bit is flipped.
@ -507,8 +506,12 @@ namespace PKHeX.Core
}
private CheckResult verifyEncounterStatic()
{
// Re-parse relearn moves
var s = (EncounterStatic)EncounterMatch;
// Re-parse moves
parseMoves(s.Moves);
// Re-parse relearn moves
if (s.EggLocation != 60002 || vRelearn.Any(rl => !rl.Valid))
{
for (int i = 0; i < 4; i++)
@ -519,6 +522,22 @@ namespace PKHeX.Core
}
return null;
}
private CheckResult verifyEncounterTrade()
{
var t = (EncounterTrade) EncounterMatch;
parseMoves(t.Moves);
return new CheckResult(Severity.Valid, "Valid ingame trade.", CheckIdentifier.Encounter);
}
private void parseMoves(int[] specialMoves)
{
if (specialMoves == null || specialMoves.Length == 0)
return;
int[] moves = pkm.Moves;
for (int i = 0; i < 4; i++)
if (!vMoves[i].Valid && specialMoves.Contains(moves[i]))
vMoves[i] = new CheckResult(Severity.Valid, "Special encounter move.", CheckIdentifier.Move);
}
private CheckResult verifyEncounterG1()
{
@ -561,50 +580,50 @@ namespace PKHeX.Core
if ((g1 && baseSpecies > Legal.MaxSpeciesID_1) || (baseSpecies > Legal.MaxSpeciesID_2))
return new CheckResult(Severity.Invalid, "VC: Unobtainable species.", CheckIdentifier.Encounter);
// Get EncounterMatch prior to parsing transporter legality
var result = verifyEncounterG1();
if (pkm.Format > 2) // transported to 7+
Parse.Add(verifyVCEncounter(baseSpecies));
return verifyEncounterG1();
return result;
}
if (pkm.WasLink)
return verifyEncounterLink();
if (pkm.WasEvent || pkm.WasEventEgg)
bool wasEvent = pkm.WasEvent || pkm.WasEventEgg;
if (wasEvent)
{
var result = verifyEncounterEvent();
if (result != null)
return result;
}
EncounterMatch = Legal.getValidStaticEncounter(pkm);
if (EncounterMatch != null)
if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm)))
{
var result = verifyEncounterStatic();
if (result != null)
return result;
}
// Reset Encounter Object, test for remaining encounters
EncounterMatch = null;
EncounterMatch = null; // Reset Encounter Object, test for remaining encounters
}
if (pkm.WasEgg)
return verifyEncounterEgg();
EncounterMatch = Legal.getValidFriendSafari(pkm);
if (EncounterMatch != null)
if (null != (EncounterMatch = Legal.getValidFriendSafari(pkm)))
return verifyEncounterSafari();
EncounterMatch = Legal.getValidWildEncounters(pkm);
if (EncounterMatch != null)
if (null != (EncounterMatch = Legal.getValidWildEncounters(pkm)))
return verifyEncounterWild();
if (null != (EncounterMatch = Legal.getValidIngameTrade(pkm)))
return verifyEncounterTrade();
EncounterMatch = Legal.getValidIngameTrade(pkm);
if (EncounterMatch != null)
return new CheckResult(Severity.Valid, "Valid ingame trade.", CheckIdentifier.Encounter);
if (pkm.WasEvent || pkm.WasEventEgg)
return new CheckResult(Severity.Invalid, "Unable to match to a Mystery Gift in the database.", CheckIdentifier.Encounter);
return new CheckResult(Severity.Invalid, "Unknown encounter.", CheckIdentifier.Encounter);
return wasEvent
? new CheckResult(Severity.Invalid, "Unable to match to a Mystery Gift in the database.", CheckIdentifier.Encounter)
: new CheckResult(Severity.Invalid, "Unknown encounter.", CheckIdentifier.Encounter);
}
private CheckResult verifyVCEncounter(int baseSpecies)
{
@ -613,7 +632,14 @@ namespace PKHeX.Core
if ((pkm.VC1 && species > Legal.MaxSpeciesID_1) ||
(pkm.VC2 && species > Legal.MaxSpeciesID_2))
species = baseSpecies;
// Check existing EncounterMatch
if (EncounterMatch == null)
Parse.Add(new CheckResult(Severity.Invalid, "Unable to match an encounter from origin game.", CheckIdentifier.Encounter));
var s = EncounterMatch as EncounterStatic;
if (s != null && s.Version == GameVersion.SPECIAL)
Parse.Add(new CheckResult(Severity.Invalid, "Special encounter is not available to Virtual Console games.", CheckIdentifier.Encounter));
EncounterMatch = new EncounterStatic
{
Species = species,
@ -902,12 +928,24 @@ namespace PKHeX.Core
}
}
if (pkm.GenNumber >= 6 && abilities[pkm.AbilityNumber >> 1] != pkm.Ability)
AddLine(Severity.Invalid, "Ability does not match ability number.", CheckIdentifier.Ability);
else if (pkm.GenNumber <= 5 && pkm.Version != (int)GameVersion.CXD && abilities[0] != abilities[1] && pkm.PIDAbility != abilval)
AddLine(Severity.Invalid, "Ability does not match PID.", CheckIdentifier.Ability);
if (3 <= pkm.Format && pkm.Format <= 5) // 3-5
{
if (pkm.Version != (int) GameVersion.CXD && abilities[0] != abilities[1] && pkm.PIDAbility != abilval)
{
AddLine(Severity.Invalid, "Ability does not match PID.", CheckIdentifier.Ability);
return;
}
}
else
AddLine(Severity.Valid, "Ability matches ability number.", CheckIdentifier.Ability);
{
if (abilities[pkm.AbilityNumber >> 1] != pkm.Ability)
{
AddLine(Severity.Invalid, "Ability does not match ability number.", CheckIdentifier.Ability);
return;
}
}
AddLine(Severity.Valid, "Ability matches ability number.", CheckIdentifier.Ability);
}
private void verifyBall()
{

View file

@ -40,8 +40,7 @@ namespace PKHeX.Core
switch (Game)
{
case GameVersion.RBY:
table = Encounter_RBY;
break;
return Encounter_RBY; // GameVersion filtering not possible, return immediately
case GameVersion.X: case GameVersion.Y:
table = Encounter_XY;
break;
@ -203,15 +202,13 @@ namespace PKHeX.Core
internal static IEnumerable<int> getValidRelearn(PKM pkm, int skipOption)
{
List<int> r = new List<int> { 0 };
if (pkm.Format < 6)
if (pkm.GenNumber < 6)
return r;
int species = getBaseSpecies(pkm, skipOption);
r.AddRange(getLVLMoves(pkm, species, 1, pkm.AltForm));
int form = pkm.AltForm;
if (pkm.Format < 6)
form = 0;
if (pkm.Format == 6 && pkm.Species != 678)
form = 0;
@ -1137,7 +1134,11 @@ namespace PKHeX.Core
List<int> moves = new List<int>();
if (pkm.Format < 3)
{
if (pkm.Species == 25 || pkm.Species == 26) // Surf Pikachu via Stadium
moves.Add(57);
return moves;
}
// Type Tutors -- Pledge moves and High BP moves switched places in G7+
if (pkm.Format <= 6)

View file

@ -10,6 +10,7 @@
public int Form = 0;
public bool? Shiny = null; // false = never, true = always, null = possible
public int[] Relearn = new int[4];
public int[] Moves = new int[4];
public int Gender = -1;
public int EggLocation = 0;
public Nature Nature = Nature.Random;

View file

@ -48,7 +48,7 @@ namespace PKHeX.Core
new EncounterStatic { Species = 001, Level = 05 }, // Bulbasaur
new EncounterStatic { Species = 004, Level = 05 }, // Charmander
new EncounterStatic { Species = 007, Level = 05 }, // Squirtle
new EncounterStatic { Species = 025, Level = 05 }, // Pikachu
new EncounterStatic { Species = 025, Level = 05, Version = GameVersion.YW }, // Pikachu
// Game Corner
new EncounterStatic { Species = 030, Level = 17 }, // Nidorina (Red Game Corner)
@ -98,14 +98,15 @@ namespace PKHeX.Core
new EncounterStatic { Species = 133, Level = 25 }, // Eevee
// Yellow Only -- duplicate encounters with a higher level
// new EncounterStatic { Species = 133, Level = 25 }, // Eevee (Celadon City)
// new EncounterStatic { Species = 001, Level = 10 }, // Bulbasaur (Cerulean City)
// new EncounterStatic { Species = 004, Level = 10 }, // Charmander (Route 24)
// new EncounterStatic { Species = 007, Level = 10 }, // Squirtle (Vermillion City)
// new EncounterStatic { Species = 133, Level = 25, Version = GameVersion.YW }, // Eevee (Celadon City)
// new EncounterStatic { Species = 001, Level = 10, Version = GameVersion.YW }, // Bulbasaur (Cerulean City)
// new EncounterStatic { Species = 004, Level = 10, Version = GameVersion.YW }, // Charmander (Route 24)
// new EncounterStatic { Species = 007, Level = 10, Version = GameVersion.YW }, // Squirtle (Vermillion City)
new EncounterStatic {Species = 054, Level = 15, Moves = new [] { 10, 133 }, Version = GameVersion.SPECIAL }, // Stadium Psyduck (Amnesia)
};
internal static readonly EncounterTrade[] TradeGift_RBY =
{
// todo
};
internal static readonly EncounterArea FishOldGood_RBY = new EncounterArea { Location = -1, Slots = new EncounterSlot[]
{

View file

@ -282,7 +282,6 @@ namespace PKHeX.Core
{
get
{
if (VC) return 7;
if (Gen7) return 7;
if (Gen6) return 6;
if (Gen5) return 5;
@ -290,6 +289,7 @@ namespace PKHeX.Core
if (Gen3) return 3;
if (Gen2) return Format; // 2
if (Gen1) return Format; // 1
if (VC) return 1;
return -1;
}
}
@ -420,6 +420,8 @@ namespace PKHeX.Core
}
switch (GenNumber)
{
case 1: return Species <= Legal.MaxSpeciesID_1;
case 2: return Species <= Legal.MaxSpeciesID_2;
case 3: return Species <= Legal.MaxSpeciesID_3;
case 4: return Species <= Legal.MaxSpeciesID_4;
case 5: return Species <= Legal.MaxSpeciesID_5;