2022-08-21 08:39:16 +00:00
|
|
|
namespace PKHeX.Core;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2022-08-21 08:39:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Simple record containing trainer data
|
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
public sealed record SimpleTrainerInfo : ITrainerInfo, IRegionOrigin
|
2018-03-29 01:52:50 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
public string OT { get; set; } = "PKHeX";
|
2023-01-22 04:02:33 +00:00
|
|
|
public ushort TID16 { get; set; } = 12345;
|
|
|
|
public ushort SID16 { get; set; } = 54321;
|
2022-06-18 18:04:24 +00:00
|
|
|
public int Gender { get; set; }
|
|
|
|
public int Language { get; set; } = (int)LanguageID.English;
|
2023-01-22 04:02:33 +00:00
|
|
|
public uint ID32 { get => (uint)(TID16 | (SID16 << 16)); set => (TID16, SID16) = ((ushort)value, (ushort)(value >> 16)); }
|
|
|
|
public TrainerIDFormat TrainerIDDisplayFormat => this.GetTrainerIDFormat();
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
// IRegionOrigin for generation 6/7
|
|
|
|
public byte ConsoleRegion { get; set; } = 1; // North America
|
|
|
|
public byte Region { get; set; } = 7; // California
|
|
|
|
public byte Country { get; set; } = 49; // USA
|
|
|
|
|
|
|
|
public int Game { get; }
|
2022-11-25 01:42:17 +00:00
|
|
|
public int Generation { get; init; } = PKX.Generation;
|
|
|
|
public EntityContext Context { get; init; } = PKX.Context;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2022-11-25 01:42:17 +00:00
|
|
|
public SimpleTrainerInfo(GameVersion game = PKX.Version)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
Game = (int) game;
|
|
|
|
SanityCheckRegionOrigin(game);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SanityCheckRegionOrigin(GameVersion game)
|
|
|
|
{
|
|
|
|
if (GameVersion.Gen7b.Contains(game) || game.GetGeneration() >= 8)
|
|
|
|
this.ClearRegionOrigin();
|
|
|
|
}
|
|
|
|
|
|
|
|
public SimpleTrainerInfo(ITrainerInfo other) : this((GameVersion)other.Game)
|
2018-03-29 01:52:50 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
OT = other.OT;
|
2023-01-22 04:02:33 +00:00
|
|
|
TID16 = other.TID16;
|
|
|
|
SID16 = other.SID16;
|
2022-06-18 18:04:24 +00:00
|
|
|
Gender = other.Gender;
|
|
|
|
Language = other.Language;
|
|
|
|
Generation = other.Generation;
|
2022-11-25 01:42:17 +00:00
|
|
|
Context = other.Context;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
if (other is IRegionOrigin r)
|
|
|
|
r.CopyRegionOrigin(this);
|
|
|
|
|
|
|
|
SanityCheckRegionOrigin((GameVersion)Game);
|
2018-03-29 01:52:50 +00:00
|
|
|
}
|
|
|
|
}
|