Relocate console-location data setting to PKMConverter

When adding data, check if the current Trainer has valid console data; if not, use a default value.
This commit is contained in:
Kurt 2020-01-05 21:41:32 -08:00
parent 3d581283c2
commit 1906a1040f
6 changed files with 24 additions and 23 deletions

View file

@ -151,15 +151,12 @@ namespace PKHeX.Core
OT_Name = StringConverter12.GetG1ConvertedString(otname, Japanese),
IsNicknamed = false,
Country = PKMConverter.Country,
Region = PKMConverter.Region,
ConsoleRegion = PKMConverter.ConsoleRegion,
CurrentHandler = 1,
HT_Name = PKMConverter.OT_Name,
HT_Gender = PKMConverter.OT_Gender,
Geo1_Country = PKMConverter.Country,
Geo1_Region = PKMConverter.Region
};
PKMConverter.SetConsoleRegionData3DS(pk7);
PKMConverter.SetFirstCountryRegion(pk7);
pk7.HealPP();
pk7.Language = TransferLanguage(PKMConverter.Language);
pk7.Nickname = SpeciesName.GetSpeciesNameGeneration(pk7.Species, pk7.Language, pk7.Format);

View file

@ -150,15 +150,12 @@ namespace PKHeX.Core
IsNicknamed = false,
AltForm = AltForm,
Country = PKMConverter.Country,
Region = PKMConverter.Region,
ConsoleRegion = PKMConverter.ConsoleRegion,
CurrentHandler = 1,
HT_Name = PKMConverter.OT_Name,
HT_Gender = PKMConverter.OT_Gender,
Geo1_Country = PKMConverter.Country,
Geo1_Region = PKMConverter.Region
};
PKMConverter.SetConsoleRegionData3DS(pk7);
PKMConverter.SetFirstCountryRegion(pk7);
pk7.HealPP();
pk7.Language = TransferLanguage(PKMConverter.Language);
pk7.Nickname = SpeciesName.GetSpeciesNameGeneration(pk7.Species, pk7.Language, pk7.Format);

View file

@ -480,16 +480,13 @@ namespace PKHeX.Core
pk6.RibbonChampionWorld = RibbonChampionWorld;
// Write Transfer Location - location is dependent on 3DS system that transfers.
pk6.Country = PKMConverter.Country;
pk6.Region = PKMConverter.Region;
pk6.ConsoleRegion = PKMConverter.ConsoleRegion;
PKMConverter.SetConsoleRegionData3DS(pk6);
PKMConverter.SetFirstCountryRegion(pk6);
// Write the Memories, Friendship, and Origin!
pk6.CurrentHandler = 1;
pk6.HT_Name = PKMConverter.OT_Name;
pk6.HT_Gender = PKMConverter.OT_Gender;
pk6.Geo1_Region = PKMConverter.Region;
pk6.Geo1_Country = PKMConverter.Country;
pk6.HT_Intensity = 1;
pk6.HT_Memory = 4;
pk6.HT_Feeling = Memories.GetRandomFeeling(pk6.HT_Memory);

View file

@ -463,8 +463,7 @@ namespace PKHeX.Core
}
pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm
pk7.Geo1_Country = PKMConverter.Country;
pk7.Geo1_Region = PKMConverter.Region;
PKMConverter.SetFirstCountryRegion(pk7);
// Bank-accurate data zeroing
for (var i = 0x94; i < 0x9E; i++) pk7.Data[i] = 0; /* Geolocations. */

View file

@ -105,10 +105,8 @@ namespace PKHeX.Core
CurrentLevel = Level,
Met_Level = Level,
MetDate = DateTime.Now,
Country = PKMConverter.Country,
Region = PKMConverter.Region,
ConsoleRegion = PKMConverter.ConsoleRegion,
};
PKMConverter.SetConsoleRegionData3DS(pk);
pk.RefreshAbility(AbilityIndex >> 1);
pk.ForcePartyData();

View file

@ -13,15 +13,28 @@ namespace PKHeX.Core
public static class PKMConverter
{
public static ITrainerInfo Trainer { internal get; set; } = new SimpleTrainerInfo();
public static int Country => Trainer.Country;
public static int Region => Trainer.SubRegion;
public static int ConsoleRegion => Trainer.ConsoleRegion;
private static readonly ITrainerInfo Trainer67 = new SimpleTrainerInfo(GameVersion.SN);
public static string OT_Name => Trainer.OT;
public static int OT_Gender => Trainer.Gender;
public static int Language => Trainer.Language;
public static int Format => Trainer.Generation;
public static bool AllowIncompatibleConversion { private get; set; }
public static void SetConsoleRegionData3DS(PKM pkm)
{
var trainer = Trainer.ConsoleRegion != 0 ? Trainer : Trainer67;
pkm.ConsoleRegion = trainer.ConsoleRegion;
pkm.Country = trainer.Country;
pkm.Region = trainer.SubRegion;
}
public static void SetFirstCountryRegion(IGeoTrack pkm)
{
var trainer = Trainer.ConsoleRegion != 0 ? Trainer : Trainer67;
pkm.Geo1_Country = trainer.Country;
pkm.Geo1_Region = trainer.SubRegion;
}
/// <summary>
/// Gets the generation of the Pokemon data.
/// </summary>