mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 22:54:14 +00:00
Extract home tracker to interface
This commit is contained in:
parent
3d6846eb3e
commit
6346444db7
5 changed files with 25 additions and 12 deletions
|
@ -82,17 +82,17 @@ namespace PKHeX.Core
|
|||
Debug.Assert(cp.Format == Trainer.Generation);
|
||||
|
||||
// Check the upload tracker to see if there's any duplication.
|
||||
if (cp is PK8 pk8)
|
||||
if (cp is IHomeTrack home)
|
||||
{
|
||||
if (pk8.Tracker != 0)
|
||||
if (home.Tracker != 0)
|
||||
{
|
||||
var tracker = pk8.Tracker;
|
||||
var tracker = home.Tracker;
|
||||
if (Trackers.TryGetValue(tracker, out var clone))
|
||||
AddLine(clone, cp, "Clone detected (Duplicate Tracker).", Encounter);
|
||||
else
|
||||
Trackers.Add(tracker, cp);
|
||||
}
|
||||
else if (pk8.GenNumber < 8)
|
||||
else if (cp.GenNumber < 8)
|
||||
{
|
||||
AddLine(cp, "Missing tracker.", Encounter);
|
||||
}
|
||||
|
|
|
@ -109,13 +109,13 @@ namespace PKHeX.Core
|
|||
{
|
||||
data.AddLine(GetInvalid(LTransferBad));
|
||||
}
|
||||
else if (data.Info.Generation < 8 && pkm is PK8 pk)
|
||||
else if (data.Info.Generation < 8 && pkm.Format >= 8)
|
||||
{
|
||||
if (!pk.GG)
|
||||
if (!pkm.GG && pkm is IScaledSize s)
|
||||
{
|
||||
if (pk.HeightScalar != 0)
|
||||
if (s.HeightScalar != 0)
|
||||
data.AddLine(GetInvalid(LTransferBad));
|
||||
if (pk.WeightScalar != 0)
|
||||
if (s.WeightScalar != 0)
|
||||
data.AddLine(GetInvalid(LTransferBad));
|
||||
|
||||
var enc = data.EncounterMatch;
|
||||
|
@ -130,7 +130,7 @@ namespace PKHeX.Core
|
|||
|
||||
// Tracker value is set via Transfer across HOME.
|
||||
// Can't validate the actual values (we aren't the server), so we can only check against zero.
|
||||
if (pk.Tracker == 0)
|
||||
if (pkm is IHomeTrack home && home.Tracker == 0)
|
||||
{
|
||||
data.AddLine(Get(LTransferTrackerMissing, ParseSettings.Gen8TransferTrackerNotPresent));
|
||||
// To the reader: It seems like the best course of action for setting a tracker is:
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace PKHeX.Core
|
|||
/// <summary> Generation 8 <see cref="PKM"/> format. </summary>
|
||||
public sealed class PK8 : PKM,
|
||||
IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetMark8,
|
||||
IContestStats, IHyperTrain, IScaledSize, IGigantamax, IFavorite, IDynamaxLevel, IRibbonIndex, IHandlerLanguage, IFormArgument
|
||||
IContestStats, IHyperTrain, IScaledSize, IGigantamax, IFavorite, IDynamaxLevel, IRibbonIndex, IHandlerLanguage, IFormArgument, IHomeTrack
|
||||
{
|
||||
private static readonly ushort[] Unused =
|
||||
{
|
||||
|
|
13
PKHeX.Core/PKM/Shared/IHomeTrack.cs
Normal file
13
PKHeX.Core/PKM/Shared/IHomeTrack.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes a <see cref="Tracker"/> for Pokémon HOME.
|
||||
/// </summary>
|
||||
public interface IHomeTrack
|
||||
{
|
||||
/// <summary>
|
||||
/// Tracker for the associated <see cref="PKM"/>
|
||||
/// </summary>
|
||||
ulong Tracker { get; set; }
|
||||
}
|
||||
}
|
|
@ -1470,10 +1470,10 @@ namespace PKHeX.WinForms.Controls
|
|||
if (!FieldsLoaded)
|
||||
return;
|
||||
// Trim out nonhex characters
|
||||
if (sender == TB_HomeTracker && Entity is PK8 pk8)
|
||||
if (sender == TB_HomeTracker && Entity is IHomeTrack home)
|
||||
{
|
||||
var value = Util.GetHexValue64(TB_HomeTracker.Text);
|
||||
pk8.Tracker = value;
|
||||
home.Tracker = value;
|
||||
TB_HomeTracker.Text = value.ToString("X16");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue