PKHeX/PKHeX.Core/Saves/Abstractions/SimpleTrainerInfo.cs
Kurt 95fbf66a6e
Refactor: Gen3/4 Lead Encounters, property fixing (#4193)
In addition to the Method 1 (and other sibling PIDIV types) correlation, an encounter can only be triggered if the calls prior land on the Method {1} seed. The RNG community has dubbed these patterns as "Method J" (D/P/Pt), "Method K" (HG/SS), and "Method H" (Gen3, coined by yours truly). The basic gist of these is that they are pre-requisites, like the Shadow locks of Colosseum/XD. 

Rename/re-type a bunch of properties to get the codebase more in line with correct property names & more obvious underlying types.
2024-02-22 21:20:54 -06:00

52 lines
1.7 KiB
C#

namespace PKHeX.Core;
/// <summary>
/// Simple record containing trainer data
/// </summary>
public sealed record SimpleTrainerInfo : ITrainerInfo, IRegionOrigin
{
public string OT { get; set; } = "PKHeX";
public ushort TID16 { get; set; } = 12345;
public ushort SID16 { get; set; } = 54321;
public byte Gender { get; set; }
public int Language { get; set; } = (int)LanguageID.English;
public uint ID32 { get => (uint)(TID16 | (SID16 << 16)); set => (TID16, SID16) = ((ushort)value, (ushort)(value >> 16)); }
public TrainerIDFormat TrainerIDDisplayFormat => this.GetTrainerIDFormat();
// 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 GameVersion Version { get; }
public byte Generation { get; init; } = PKX.Generation;
public EntityContext Context { get; init; } = PKX.Context;
public SimpleTrainerInfo(GameVersion game = PKX.Version)
{
Version = game;
SanityCheckRegionOrigin(game);
}
private void SanityCheckRegionOrigin(GameVersion game)
{
if (GameVersion.Gen7b.Contains(game) || game.GetGeneration() >= 8)
this.ClearRegionOrigin();
}
public SimpleTrainerInfo(ITrainerInfo other) : this(other.Version)
{
OT = other.OT;
TID16 = other.TID16;
SID16 = other.SID16;
Gender = other.Gender;
Language = other.Language;
Generation = other.Generation;
Context = other.Context;
if (other is IRegionOrigin r)
r.CopyRegionOrigin(this);
SanityCheckRegionOrigin(Version);
}
}