mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Add gen1->gen7 IV legality check
Also fix gen1/2 evo tree trimming error, thanks BeyondTheHorizon! Also fix an exception when no static encounter can be generated for 1->7, match is now generated by checking gen1 and reusing the static encounter creation info (now moved to core).
This commit is contained in:
parent
0715f133d2
commit
efd25a2c7c
3 changed files with 35 additions and 19 deletions
|
@ -293,7 +293,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
var encounter = Legal.getStaticLocation(pkm);
|
||||
if (loc != -1)
|
||||
if (loc != -1 && encounter != null)
|
||||
encounter.Location = loc;
|
||||
return encounter;
|
||||
}
|
||||
|
|
|
@ -313,11 +313,15 @@ namespace PKHeX.Core
|
|||
}
|
||||
private void verifyIVs()
|
||||
{
|
||||
var e = EncounterMatch as EncounterStatic;
|
||||
if ((EncounterMatch as EncounterStatic)?.IV3 == true)
|
||||
{
|
||||
if (pkm.IVs.Count(iv => iv == 31) < 3)
|
||||
int IVCount = 3;
|
||||
if (e.Version == GameVersion.RBY && pkm.Species == 151)
|
||||
IVCount = 5; // VC Mew
|
||||
if (pkm.IVs.Count(iv => iv == 31) < IVCount)
|
||||
{
|
||||
AddLine(Severity.Invalid, "Should have at least 3 IVs = 31.", CheckIdentifier.IVs);
|
||||
AddLine(Severity.Invalid, $"Should have at least {IVCount} IVs = 31.", CheckIdentifier.IVs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -334,8 +338,9 @@ namespace PKHeX.Core
|
|||
int[] IVs;
|
||||
switch (((MysteryGift) EncounterMatch).Format)
|
||||
{
|
||||
case 6: IVs = ((WC6)EncounterMatch).IVs; break;
|
||||
case 7: IVs = ((WC7)EncounterMatch).IVs; break;
|
||||
case 6: IVs = ((WC6)EncounterMatch).IVs; break;
|
||||
case 5: IVs = ((PGF)EncounterMatch).IVs; break;
|
||||
default: IVs = null; break;
|
||||
}
|
||||
|
||||
|
@ -659,18 +664,8 @@ namespace PKHeX.Core
|
|||
if (!exceptions)
|
||||
AddLine(new CheckResult(Severity.Invalid, "Special encounter is not available to Virtual Console games.", CheckIdentifier.Encounter));
|
||||
}
|
||||
|
||||
EncounterMatch = new EncounterStatic
|
||||
{
|
||||
Species = species,
|
||||
Gift = true, // Forces Poké Ball
|
||||
Ability = Legal.TransferSpeciesDefaultAbility_1.Contains(species) ? 1 : 4, // Hidden by default, else first
|
||||
Shiny = species == 151 ? (bool?)false : null,
|
||||
Fateful = species == 151,
|
||||
Location = 30013,
|
||||
EggLocation = 0,
|
||||
Version = GameVersion.RBY
|
||||
};
|
||||
|
||||
EncounterMatch = Legal.getRBYStaticTransfer(species);
|
||||
var ematch = (EncounterStatic) EncounterMatch;
|
||||
|
||||
if (pkm.Met_Location != ematch.Location)
|
||||
|
|
|
@ -878,9 +878,30 @@ namespace PKHeX.Core
|
|||
Location = area.Location, Slots = slots,
|
||||
}).OrderBy(area => area.Slots.Min(x => x.LevelMin)).FirstOrDefault();
|
||||
}
|
||||
internal static EncounterStatic getStaticLocation(PKM pkm)
|
||||
internal static EncounterStatic getRBYStaticTransfer(int species)
|
||||
{
|
||||
return getStaticEncounters(pkm, 100).OrderBy(s => s.Level).FirstOrDefault();
|
||||
return new EncounterStatic
|
||||
{
|
||||
Species = species,
|
||||
Gift = true, // Forces Poké Ball
|
||||
Ability = TransferSpeciesDefaultAbility_1.Contains(species) ? 1 : 4, // Hidden by default, else first
|
||||
Shiny = species == 151 ? (bool?)false : null,
|
||||
Fateful = species == 151,
|
||||
Location = 30013,
|
||||
EggLocation = 0,
|
||||
IV3 = true,
|
||||
Version = GameVersion.RBY
|
||||
};
|
||||
}
|
||||
internal static EncounterStatic getStaticLocation(PKM pkm, int species = -1)
|
||||
{
|
||||
switch (pkm.GenNumber)
|
||||
{
|
||||
case 1:
|
||||
return getRBYStaticTransfer(species);
|
||||
default:
|
||||
return getStaticEncounters(pkm, 100).OrderBy(s => s.Level).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getLowestLevel(PKM pkm, int refSpecies = -1)
|
||||
|
@ -1123,7 +1144,7 @@ namespace PKHeX.Core
|
|||
continue;
|
||||
|
||||
GensEvoChains[gen] = getEvolutionChain(pkm, Encounter, CompleteEvoChain.First().Species, lvl);
|
||||
if (!pkm.HasOriginalMetLocation && gen >= pkm.GenNumber )
|
||||
if (gen > 2 && !pkm.HasOriginalMetLocation && gen >= pkm.GenNumber)
|
||||
//Remove previous evolutions bellow transfer level
|
||||
//For example a gen3 charizar in format 7 with current level 36 and met level 36
|
||||
//chain level for charmander is 35, is bellow met level
|
||||
|
|
Loading…
Reference in a new issue