mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Add egg converter & test
only tested for gen7 egg->pkm (not to eventual set) pretty sure a good chunk of the egg generation logic can be pulled out for reuse in other IEncounterable generators (IEncounterable extensions?)
This commit is contained in:
parent
6333c42cf1
commit
76b4db1477
2 changed files with 66 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Egg Encounter Data
|
||||
|
@ -15,6 +17,58 @@
|
|||
public GameVersion Game;
|
||||
public bool SplitBreed;
|
||||
|
||||
public PKM ConvertToPKM(ITrainerInfo SAV) => throw new System.NotImplementedException();
|
||||
public PKM ConvertToPKM(ITrainerInfo SAV)
|
||||
{
|
||||
var pk = PKMConverter.GetBlank(SAV.Generation);
|
||||
SAV.ApplyToPKM(pk);
|
||||
|
||||
pk.Species = Species;
|
||||
pk.Nickname = PKX.GetSpeciesNameGeneration(Species, pk.Language, SAV.Generation);
|
||||
pk.CurrentLevel = Level;
|
||||
pk.Version = (int)Game;
|
||||
|
||||
var moves = Legal.GetEggMoves(pk, Species, pk.AltForm, Game);
|
||||
pk.Moves = moves;
|
||||
pk.SetMaximumPPCurrent(moves);
|
||||
pk.SetRandomIVs();
|
||||
|
||||
if (pk.Format <= 2 && Game != GameVersion.C)
|
||||
return pk;
|
||||
|
||||
pk.PID = Util.Rand32();
|
||||
pk.RefreshAbility(Util.Rand.Next(2));
|
||||
pk.Ball = 4;
|
||||
|
||||
pk.Met_Level = EncounterSuggestion.GetSuggestedEncounterEggMetLevel(pk);
|
||||
pk.Met_Location = EncounterSuggestion.GetSuggestedEggMetLocation(pk);
|
||||
|
||||
if (pk.Format < 4)
|
||||
return pk;
|
||||
|
||||
bool traded = (int)Game == SAV.Game;
|
||||
pk.Egg_Location = EncounterSuggestion.GetSuggestedEncounterEggLocationEgg(pk, traded);
|
||||
pk.EggMetDate = pk.MetDate = DateTime.Today;
|
||||
|
||||
if (pk.Format < 6)
|
||||
return pk;
|
||||
|
||||
if (pk.Format != SAV.Generation)
|
||||
{
|
||||
pk.HT_Name = SAV.OT;
|
||||
pk.HT_Gender = SAV.Gender;
|
||||
if (SAV.Generation == 6)
|
||||
{
|
||||
pk.Geo1_Country = SAV.Country;
|
||||
pk.Geo1_Region = SAV.SubRegion;
|
||||
}
|
||||
}
|
||||
if (SAV.Generation == 6)
|
||||
pk.SetHatchMemory6();
|
||||
|
||||
pk.SetRandomEC();
|
||||
pk.RelearnMoves = moves;
|
||||
|
||||
return pk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,16 @@ namespace PKHeX.Tests.Simulator
|
|||
Assert.IsTrue(!encs.Any());
|
||||
pk7.HT_Name = "PKHeX";
|
||||
encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
|
||||
Assert.IsTrue(encs.Any());
|
||||
var first = encs.FirstOrDefault();
|
||||
Assert.IsTrue(first != null);
|
||||
|
||||
var egg = (EncounterEgg)first;
|
||||
var info = new SimpleTrainerInfo();
|
||||
var pk = egg.ConvertToPKM(info);
|
||||
Assert.IsTrue(pk.Species != set.Species);
|
||||
|
||||
var la = new LegalityAnalysis(pk);
|
||||
Assert.IsTrue(la.Valid);
|
||||
}
|
||||
|
||||
private const string SetGlaceonUSUMTutor =
|
||||
|
|
Loading…
Reference in a new issue