mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Split Country/Region/ConsoleRegion to interface
This commit is contained in:
parent
fa3bdfe5f6
commit
27f15d2f20
16 changed files with 49 additions and 50 deletions
|
@ -55,11 +55,11 @@ namespace PKHeX.Core
|
|||
pk.OT_Gender = tr.Gender;
|
||||
pk.TID = tr.TID;
|
||||
pk.SID = tr.SID;
|
||||
if (tr.ConsoleRegion >= 0)
|
||||
if (tr.ConsoleRegion >= 0 && pk is IGeoTrack gt)
|
||||
{
|
||||
pk.ConsoleRegion = tr.ConsoleRegion;
|
||||
pk.Country = tr.Country;
|
||||
pk.Region = tr.SubRegion;
|
||||
gt.ConsoleRegion = tr.ConsoleRegion;
|
||||
gt.Country = tr.Country;
|
||||
gt.Region = tr.SubRegion;
|
||||
}
|
||||
|
||||
// Copy OT trash bytes for sensitive games (Gen1/2)
|
||||
|
|
|
@ -39,9 +39,6 @@ namespace PKHeX.Core
|
|||
public string Version => Get(Strings.gamelist, pkm.Version);
|
||||
public string OTLang => Get(GameDataSource.Languages, pkm.Language);
|
||||
public string Legal { get { var la = new LegalityAnalysis(pkm); return la.Parsed ? la.Valid.ToString() : "-"; } }
|
||||
public string CountryID => pkm.Format > 5 ? pkm.Country.ToString() : "N/A";
|
||||
public string RegionID => pkm.Format > 5 ? pkm.Region.ToString() : "N/A";
|
||||
public string DSRegionID => pkm.Format > 5 ? pkm.ConsoleRegion.ToString() : "N/A";
|
||||
|
||||
#region Extraneous
|
||||
public string EC => pkm.EncryptionConstant.ToString("X8");
|
||||
|
|
|
@ -323,7 +323,9 @@ namespace PKHeX.Core
|
|||
if (pkm.Format < 6)
|
||||
return;
|
||||
|
||||
ConsoleRegion.Verify(this);
|
||||
if (pkm.Format < 8)
|
||||
ConsoleRegion.Verify(this); // Gen 7->8 transfer deletes geolocation tracking data
|
||||
|
||||
History.Verify(this);
|
||||
Memory.Verify(this);
|
||||
if (pkm is ISuperTrain)
|
||||
|
|
|
@ -46,9 +46,12 @@ namespace PKHeX.Core
|
|||
if (lang != 0 && !lang.HasFlagFast((MysteryGiftRestriction) (1 << pk.Language)))
|
||||
return new CheckResult(Severity.Invalid, string.Format(LOTLanguage, lang.GetSuggestedLanguage(), pk.Language), CheckIdentifier.GameOrigin);
|
||||
|
||||
var region = val & MysteryGiftRestriction.RegionRestrict;
|
||||
if (region != 0 && !region.HasFlagFast((MysteryGiftRestriction)((int)MysteryGiftRestriction.RegionBase << pk.ConsoleRegion)))
|
||||
return new CheckResult(Severity.Invalid, LGeoHardwareRange, CheckIdentifier.GameOrigin);
|
||||
if (pk is IGeoTrack tr)
|
||||
{
|
||||
var region = val & MysteryGiftRestriction.RegionRestrict;
|
||||
if (region != 0 && !region.HasFlagFast((MysteryGiftRestriction)((int)MysteryGiftRestriction.RegionBase << tr.ConsoleRegion)))
|
||||
return new CheckResult(Severity.Invalid, LGeoHardwareRange, CheckIdentifier.GameOrigin);
|
||||
}
|
||||
|
||||
return new CheckResult(CheckIdentifier.GameOrigin);
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares the <see cref="PKM.ConsoleRegion"/> and <see cref="PKM.Country"/> to determine if the country is available within that region.
|
||||
/// Compares the <see cref="IGeoTrack.ConsoleRegion"/> and <see cref="IGeoTrack.Country"/> to determine if the country is available within that region.
|
||||
/// </summary>
|
||||
/// <param name="consoleRegion">Console region.</param>
|
||||
/// <param name="country">Country of nationality</param>
|
||||
|
|
|
@ -28,11 +28,11 @@ namespace PKHeX.Core
|
|||
pk.Language = info.Language;
|
||||
pk.Version = info.Game;
|
||||
|
||||
if (pk.Format >= 8 || pk is PB7)
|
||||
if (!(pk is IGeoTrack tr))
|
||||
return;
|
||||
pk.Country = info.Country;
|
||||
pk.Region = info.SubRegion;
|
||||
pk.ConsoleRegion = info.ConsoleRegion;
|
||||
tr.Country = info.Country;
|
||||
tr.Region = info.SubRegion;
|
||||
tr.ConsoleRegion = info.ConsoleRegion;
|
||||
}
|
||||
|
||||
public static void ApplyHandlingTrainerInfo(this ITrainerInfo sav, PKM pk, bool force = false)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies the <see cref="PKM.ConsoleRegion"/> and <see cref="PKM.Country"/> of origin values.
|
||||
/// Verifies the <see cref="IGeoTrack.ConsoleRegion"/> and <see cref="IGeoTrack.Country"/> of origin values.
|
||||
/// </summary>
|
||||
public sealed class ConsoleRegionVerifier : Verifier
|
||||
{
|
||||
|
@ -11,33 +11,26 @@ namespace PKHeX.Core
|
|||
|
||||
public override void Verify(LegalityAnalysis data)
|
||||
{
|
||||
var result = VerifyConsoleRegion(data.pkm, data.Info.Generation);
|
||||
if (!(data.pkm is IGeoTrack tr))
|
||||
return;
|
||||
var result = VerifyConsoleRegion(tr);
|
||||
data.AddLine(result);
|
||||
}
|
||||
|
||||
private CheckResult VerifyConsoleRegion(PKM pkm, int gen)
|
||||
private CheckResult VerifyConsoleRegion(IGeoTrack pkm)
|
||||
{
|
||||
int consoleRegion = pkm.ConsoleRegion;
|
||||
if (consoleRegion >= 7)
|
||||
return GetInvalid(LGeoHardwareRange);
|
||||
|
||||
if (gen >= 8 || pkm.Format >= 8 || pkm.GG)
|
||||
return VerifyNoDataPresent(pkm, consoleRegion);
|
||||
return Verify3DSDataPresent(pkm, consoleRegion);
|
||||
}
|
||||
|
||||
private CheckResult Verify3DSDataPresent(PKM pkm, int consoleRegion)
|
||||
private CheckResult Verify3DSDataPresent(IGeoTrack pkm, int consoleRegion)
|
||||
{
|
||||
if (!Legal.IsConsoleRegionCountryValid(consoleRegion, pkm.Country))
|
||||
return GetInvalid(LGeoHardwareInvalid);
|
||||
return GetValid(LGeoHardwareValid);
|
||||
}
|
||||
|
||||
private CheckResult VerifyNoDataPresent(PKM pkm, int consoleRegion)
|
||||
{
|
||||
if (consoleRegion != 0 || pkm.Country != 0 || pkm.Region != 0)
|
||||
return GetInvalid(LGeoHardwareInvalid);
|
||||
return GetValid(LGeoHardwareValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,9 @@ namespace PKHeX.Core
|
|||
case (int)Species.Spewpa:
|
||||
if (form > 17) // Fancy & Pokéball
|
||||
return GetInvalid(LFormVivillonEventPre);
|
||||
if (!Legal.CheckVivillonPattern(form, (byte)pkm.Country, (byte)pkm.Region))
|
||||
if (!(pkm is IGeoTrack tr))
|
||||
break;
|
||||
if (!Legal.CheckVivillonPattern(form, (byte)tr.Country, (byte)tr.Region))
|
||||
data.AddLine(Get(LFormVivillonInvalid, Severity.Fishy));
|
||||
break;
|
||||
case (int)Species.Vivillon:
|
||||
|
@ -127,7 +129,9 @@ namespace PKHeX.Core
|
|||
return GetInvalid(LFormVivillonInvalid);
|
||||
return GetValid(LFormVivillon);
|
||||
}
|
||||
if (!Legal.CheckVivillonPattern(form, (byte)pkm.Country, (byte)pkm.Region))
|
||||
if (!(pkm is IGeoTrack trv))
|
||||
break;
|
||||
if (!Legal.CheckVivillonPattern(form, (byte)trv.Country, (byte)trv.Region))
|
||||
data.AddLine(Get(LFormVivillonInvalid, Severity.Fishy));
|
||||
break;
|
||||
|
||||
|
|
|
@ -317,9 +317,6 @@ namespace PKHeX.Core
|
|||
Version = OriginGame != 0 ? OriginGame : sav.Game,
|
||||
Language = sav.Language,
|
||||
Ball = Ball,
|
||||
Country = sav.Country,
|
||||
Region = sav.SubRegion,
|
||||
ConsoleRegion = sav.ConsoleRegion,
|
||||
Move1 = Move1,
|
||||
Move2 = Move2,
|
||||
Move3 = Move3,
|
||||
|
|
|
@ -345,9 +345,9 @@ namespace PKHeX.Core
|
|||
public override int OT_Gender { get => Data[0xDD] >> 7; set => Data[0xDD] = (byte)((Data[0xDD] & ~0x80) | (value << 7)); }
|
||||
public override int EncounterType { get => Data[0xDE]; set => Data[0xDE] = (byte)value; }
|
||||
public override int Version { get => Data[0xDF]; set => Data[0xDF] = (byte)value; }
|
||||
public override int Country { get => Data[0xE0]; set => Data[0xE0] = (byte)value; }
|
||||
public override int Region { get => Data[0xE1]; set => Data[0xE1] = (byte)value; }
|
||||
public override int ConsoleRegion { get => Data[0xE2]; set => Data[0xE2] = (byte)value; }
|
||||
public int Country { get => Data[0xE0]; set => Data[0xE0] = (byte)value; }
|
||||
public int Region { get => Data[0xE1]; set => Data[0xE1] = (byte)value; }
|
||||
public int ConsoleRegion { get => Data[0xE2]; set => Data[0xE2] = (byte)value; }
|
||||
public override int Language { get => Data[0xE3]; set => Data[0xE3] = (byte)value; }
|
||||
#endregion
|
||||
#region Battle Stats
|
||||
|
|
|
@ -377,9 +377,9 @@ namespace PKHeX.Core
|
|||
public bool HT_SPD { get => ((HyperTrainFlags >> 4) & 1) == 1; set => HyperTrainFlags = (HyperTrainFlags & ~(1 << 4)) | ((value ? 1 : 0) << 4); }
|
||||
public bool HT_SPE { get => ((HyperTrainFlags >> 5) & 1) == 1; set => HyperTrainFlags = (HyperTrainFlags & ~(1 << 5)) | ((value ? 1 : 0) << 5); }
|
||||
public override int Version { get => Data[0xDF]; set => Data[0xDF] = (byte)value; }
|
||||
public override int Country { get => Data[0xE0]; set => Data[0xE0] = (byte)value; }
|
||||
public override int Region { get => Data[0xE1]; set => Data[0xE1] = (byte)value; }
|
||||
public override int ConsoleRegion { get => Data[0xE2]; set => Data[0xE2] = (byte)value; }
|
||||
public int Country { get => Data[0xE0]; set => Data[0xE0] = (byte)value; }
|
||||
public int Region { get => Data[0xE1]; set => Data[0xE1] = (byte)value; }
|
||||
public int ConsoleRegion { get => Data[0xE2]; set => Data[0xE2] = (byte)value; }
|
||||
public override int Language { get => Data[0xE3]; set => Data[0xE3] = (byte)value; }
|
||||
#endregion
|
||||
#region Battle Stats
|
||||
|
|
|
@ -159,9 +159,6 @@ namespace PKHeX.Core
|
|||
public virtual byte Enjoyment { get; set; }
|
||||
public virtual byte Fullness { get; set; }
|
||||
public virtual int AbilityNumber { get; set; }
|
||||
public virtual int Country { get; set; }
|
||||
public virtual int Region { get; set; }
|
||||
public virtual int ConsoleRegion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date the Pokémon was met.
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
/// </summary>
|
||||
public interface IGeoTrack
|
||||
{
|
||||
int ConsoleRegion { get; set; }
|
||||
int Country { get; set; }
|
||||
int Region { get; set; }
|
||||
|
||||
int Geo1_Region { get; set; }
|
||||
int Geo2_Region { get; set; }
|
||||
int Geo3_Region { get; set; }
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace PKHeX.Core
|
|||
public static int Game => Trainer.Game;
|
||||
public static bool AllowIncompatibleConversion { private get; set; }
|
||||
|
||||
public static void SetConsoleRegionData3DS(PKM pkm)
|
||||
public static void SetConsoleRegionData3DS(IGeoTrack pkm)
|
||||
{
|
||||
var trainer = Trainer.ConsoleRegion != 0 ? Trainer : Trainer67;
|
||||
pkm.ConsoleRegion = trainer.ConsoleRegion;
|
||||
|
|
|
@ -283,7 +283,9 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
LoadRelearnMoves(pk);
|
||||
LoadHandlingTrainer(pk);
|
||||
LoadGeolocation(pk);
|
||||
|
||||
if (pk is IGeoTrack tr)
|
||||
LoadGeolocation(tr);
|
||||
}
|
||||
|
||||
private void SaveMisc6(PKM pk)
|
||||
|
@ -294,18 +296,18 @@ namespace PKHeX.WinForms.Controls
|
|||
SaveRelearnMoves(pk);
|
||||
SaveHandlingTrainer(pk);
|
||||
|
||||
if (pk.Format <= 7 && !(pk is PB7))
|
||||
SaveGeolocation(pk);
|
||||
if (pk is IGeoTrack tr)
|
||||
SaveGeolocation(tr);
|
||||
}
|
||||
|
||||
private void LoadGeolocation(PKM pk)
|
||||
private void LoadGeolocation(IGeoTrack pk)
|
||||
{
|
||||
CB_Country.SelectedValue = pk.Country;
|
||||
CB_SubRegion.SelectedValue = pk.Region;
|
||||
CB_3DSReg.SelectedValue = pk.ConsoleRegion;
|
||||
}
|
||||
|
||||
private void SaveGeolocation(PKM pk)
|
||||
private void SaveGeolocation(IGeoTrack pk)
|
||||
{
|
||||
pk.Country = WinFormsUtil.GetIndex(CB_Country);
|
||||
pk.Region = WinFormsUtil.GetIndex(CB_SubRegion);
|
||||
|
|
|
@ -1743,7 +1743,7 @@ namespace PKHeX.WinForms.Controls
|
|||
BTN_History.Visible = gen >= 6 && !pb7;
|
||||
BTN_Ribbons.Visible = gen >= 3 && !pb7;
|
||||
BTN_Medals.Visible = gen >= 6 && gen <= 7 && !pb7;
|
||||
FLP_Country.Visible = FLP_SubRegion.Visible = FLP_3DSRegion.Visible = gen >= 6 && gen <= 7 && !pb7;
|
||||
FLP_Country.Visible = FLP_SubRegion.Visible = FLP_3DSRegion.Visible = t is IGeoTrack;
|
||||
FLP_OriginalNature.Visible = gen >= 8;
|
||||
B_Records.Visible = gen >= 8;
|
||||
CB_HTLanguage.Visible = gen >= 8;
|
||||
|
|
Loading…
Reference in a new issue