add location interface for verbose analysis output

indicates met location for transferred mons
most gen1/2 encounters won't show values due to the location not being
stored respective to the string tables (anyone wanna do a location remap
after initial load?)
This commit is contained in:
Kurt 2018-01-02 12:00:41 -08:00
parent 5888898e7d
commit 0f21fc2217
15 changed files with 74 additions and 23 deletions

View file

@ -64,6 +64,14 @@ namespace PKHeX.Core
return $"{enc.GetEncounterTypeName()} ({SpeciesStrings[enc.Species]})";
}
}
private string EncounterLocation
{
get
{
var enc = (EncounterOriginalGB ?? EncounterMatch) as ILocation;
return enc?.GetEncounterLocation(Info.Generation);
}
}
/// <summary>
/// Checks the input <see cref="PKM"/> data for legality.
@ -338,6 +346,9 @@ namespace PKHeX.Core
lines.AddRange(br);
lines.Add(string.Format(V195, EncounterName));
var loc = EncounterLocation;
if (!string.IsNullOrEmpty(loc))
lines.Add(string.Format(V196, "Location", loc));
if (pkm.VC)
lines.Add(string.Format(V196, nameof(GameVersion), Info.Game));
var pidiv = Info.PIDIV ?? MethodFinder.Analyze(pkm);

View file

@ -914,7 +914,7 @@ namespace PKHeX.Core
new EncounterTradePID { Species = 241, Level = 16, Moves = new[] {208,215,360,359}, TID = 1000, SID = 02707, OTGender = 1, Version = GameVersion.D, Location = 3000, Gender = 1, PID = 323975570, CurrentLevel = 48, }, // Miltank
new EncounterTradePID { Species = 285, Level = 22, Moves = new[] {402,147,206,078}, TID = 1000, SID = 02788, OTGender = 1, Version = GameVersion.D, Location = 3000, Gender = 0, PID = 323975563, CurrentLevel = 45, Ball = 0x05, }, // Shroomish
new EncounterTradePID { Species = 320, Level = 30, Moves = new[] {156,323,133,058}, TID = 1000, SID = 27046, OTGender = 1, Version = GameVersion.D, Location = 0038, Gender = 0, PID = 323975559, CurrentLevel = 45, }, // Wailmer
new EncounterTradePID { Species = 360, Level = 01, Moves = new[] {204,150,227,000}, TID = 1000, SID = 01788, OTGender = 1, Version = GameVersion.D, Location = 0004, Gender = 0, PID = 323977657, Egg_Location = 2000, }, // Wynaut
new EncounterTradePID { Species = 360, Level = 01, Moves = new[] {204,150,227,000}, TID = 1000, SID = 01788, OTGender = 1, Version = GameVersion.D, Location = 0004, Gender = 0, PID = 323977657, EggLocation = 2000, }, // Wynaut
new EncounterTradePID { Species = 397, Level = 02, Moves = new[] {355,017,283,018}, TID = 1000, SID = 59298, OTGender = 1, Version = GameVersion.D, Location = 0016, Gender = 0, PID = 323975563, CurrentLevel = 23, }, // Staravia
new EncounterTradePID { Species = 415, Level = 05, Moves = new[] {230,016,000,000}, TID = 1000, SID = 54140, OTGender = 1, Version = GameVersion.D, Location = 0020, Gender = 1, PID = 323970584, CurrentLevel = 20, }, // Combee
new EncounterTradePID { Species = 417, Level = 09, Moves = new[] {447,045,351,098}, TID = 1000, SID = 18830, OTGender = 1, Version = GameVersion.D, Location = 0020, Gender = 1, PID = 323977539, CurrentLevel = 10, }, // Pachirisu
@ -923,7 +923,7 @@ namespace PKHeX.Core
new EncounterTradePID { Species = 453, Level = 22, Moves = new[] {310,207,426,389}, TID = 1000, SID = 41342, OTGender = 1, Version = GameVersion.D, Location = 0052, Gender = 0, PID = 323975579, CurrentLevel = 31, Ball = 0x05, }, // Croagunk
new EncounterTradePID { Species = 456, Level = 15, Moves = new[] {213,352,219,392}, TID = 1000, SID = 48348, OTGender = 1, Version = GameVersion.D, Location = 0020, Gender = 1, PID = 323977566, CurrentLevel = 35, }, // Finneon
new EncounterTradePID { Species = 459, Level = 32, Moves = new[] {452,420,275,059}, TID = 1000, SID = 23360, OTGender = 1, Version = GameVersion.D, Location = 0031, Gender = 0, PID = 323975582, CurrentLevel = 41, }, // Snover
new EncounterTrade { Species = 489, Level = 01, Moves = new[] {447,240,156,057}, TID = 1000, SID = 09248, OTGender = 1, Version = GameVersion.D, Location = 3000, Gender = 2, Fateful = true, CurrentLevel = 50, Ball = 0x10, Egg_Location = 3000, }, // Phione
new EncounterTrade { Species = 489, Level = 01, Moves = new[] {447,240,156,057}, TID = 1000, SID = 09248, OTGender = 1, Version = GameVersion.D, Location = 3000, Gender = 2, Fateful = true, CurrentLevel = 50, Ball = 0x10, EggLocation = 3000, }, // Phione
};
internal static readonly EncounterTrade[] TradeGift_DPPt = new[]
{

View file

@ -34,11 +34,11 @@ namespace PKHeX.Core
var id = (LanguageID) l;
return new[]
{
new WC3 { Species = 239, Level = 20, Language = l, Fateful = true, Met_Location = 164, TID = 41400, SID = -1, OT_Gender = 0, OT_Name = h[l], CardTitle = $"Trade Togepi ({id})", Method = PIDType.CXD, Moves = new[] { 008, 007, 009, 238 } }, // Elekid @ Snagem Hideout
new WC3 { Species = 307, Level = 20, Language = l, Fateful = true, Met_Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Trade Trapinch ({id})", Method = PIDType.CXD, Moves = new[] { 223, 093, 247, 197 } }, // Meditite @ Pyrite Town
new WC3 { Species = 213, Level = 20, Language = l, Fateful = true, Met_Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Trade Surskit ({id})", Method = PIDType.CXD, Moves = new[] { 092, 164, 188, 277 } }, // Shuckle @ Pyrite Town
new WC3 { Species = 246, Level = 20, Language = l, Fateful = true, Met_Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Trade Wooper ({id})", Method = PIDType.CXD, Moves = new[] { 201, 349, 044, 200 } }, // Larvitar @ Pyrite Town
new WC3 { Species = 311, Level = 13, Language = l, Fateful = false, Met_Location = 254, TID = 37149, SID = 0, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Special Gift ({id})", Method = PIDType.CXD }, // Plusle @ Ingame Trade
new WC3 { Species = 239, Level = 20, Language = l, Fateful = true, Location = 164, TID = 41400, SID = -1, OT_Gender = 0, OT_Name = h[l], CardTitle = $"Trade Togepi ({id})", Method = PIDType.CXD, Moves = new[] { 008, 007, 009, 238 } }, // Elekid @ Snagem Hideout
new WC3 { Species = 307, Level = 20, Language = l, Fateful = true, Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Trade Trapinch ({id})", Method = PIDType.CXD, Moves = new[] { 223, 093, 247, 197 } }, // Meditite @ Pyrite Town
new WC3 { Species = 213, Level = 20, Language = l, Fateful = true, Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Trade Surskit ({id})", Method = PIDType.CXD, Moves = new[] { 092, 164, 188, 277 } }, // Shuckle @ Pyrite Town
new WC3 { Species = 246, Level = 20, Language = l, Fateful = true, Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Trade Wooper ({id})", Method = PIDType.CXD, Moves = new[] { 201, 349, 044, 200 } }, // Larvitar @ Pyrite Town
new WC3 { Species = 311, Level = 13, Language = l, Fateful = false, Location = 254, TID = 37149, SID = 0, OT_Gender = 0, OT_Name = d[l], CardTitle = $"Special Gift ({id})", Method = PIDType.CXD }, // Plusle @ Ingame Trade
new WC3 { Species = 250, Level = 70, Language = l, Fateful = false, /*loc already set*/ TID = 10048, SID = 0, OT_Gender = 0, OT_Name = m[l], CardTitle = $"Mt. Battle Ho-oh ({id})", Method = PIDType.CXD, Shiny = false } // Ho-oh @ Mt. Battle
};
}

View file

@ -1033,7 +1033,7 @@ namespace PKHeX.Core
return false;
if (z.OTGender != -1 && z.OTGender != pkm.OT_Gender)
return false;
if (z.Egg_Location != pkm.Egg_Location)
if (z.EggLocation != pkm.Egg_Location)
return false;
// if (z.Ability == 4 ^ pkm.AbilityNumber == 4) // defer to Ability
// countinue;
@ -1217,7 +1217,7 @@ namespace PKHeX.Core
{
if (wc.Met_Level != pkm.Met_Level)
return false;
if (wc.Met_Location != pkm.Met_Location && (!wc.IsEgg || pkm.IsEgg))
if (wc.Location != pkm.Met_Location && (!wc.IsEgg || pkm.IsEgg))
return false;
}
else

View file

@ -3,7 +3,7 @@
/// <summary>
/// Pokémon Link Encounter Data
/// </summary>
public class EncounterLink : IEncounterable, IRibbonSetEvent4, IMoveset
public class EncounterLink : IEncounterable, IRibbonSetEvent4, IMoveset, ILocation
{
public int Species { get; set; }
public int Level { get; set; }
@ -16,7 +16,9 @@
public int[] RelearnMoves = new int[4];
public bool? Shiny { get; set; } = false;
public bool OT { get; set; } = true; // Receiver is OT?
public bool EggEncounter => false;
public int EggLocation { get => 0; set { } }
public bool XY { get; set; }
public bool ORAS { get; set; }

View file

@ -19,7 +19,7 @@
/// <summary>
/// Wild Encounter Slot data
/// </summary>
public class EncounterSlot : IEncounterable, IGeneration
public class EncounterSlot : IEncounterable, IGeneration, ILocation
{
public int Species { get; set; }
public int Form { get; set; }
@ -28,13 +28,15 @@
public SlotType Type { get; set; } = SlotType.Any;
public EncounterType TypeEncounter { get; set; } = EncounterType.None;
public int SlotNumber { get; set; }
public bool EggEncounter => false;
public int Generation { get; set; } = -1;
internal EncounterSlotPermissions _perm;
public EncounterSlotPermissions Permissions => _perm ?? (_perm = new EncounterSlotPermissions());
internal EncounterArea Area { get; set; }
public int Location => Area.Location;
public int Location { get => Area.Location; set { } }
public bool EggEncounter => false;
public int EggLocation { get => 0; set { } }
public EncounterSlot Clone()
{
var slot = (EncounterSlot) MemberwiseClone();

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core
/// <remarks>
/// Static Encounters are fixed position encounters with properties that are not subject to Wild Encounter conditions.
/// </remarks>
public class EncounterStatic : IEncounterable, IMoveset, IGeneration
public class EncounterStatic : IEncounterable, IMoveset, IGeneration, ILocation
{
public int Species { get; set; }
public int[] Moves { get; set; }

View file

@ -6,7 +6,7 @@
/// <remarks>
/// Trade data is fixed level in all cases except for the first few generations of games.
/// </remarks>
public class EncounterTrade : IEncounterable, IMoveset, IGeneration
public class EncounterTrade : IEncounterable, IMoveset, IGeneration, ILocation
{
public int Species { get; set; }
public int[] Moves { get; set; }
@ -28,7 +28,7 @@
public int Gender { get; set; } = -1;
public int OTGender { get; set; } = -1;
public bool EggEncounter => false;
public int Egg_Location { get; set; }
public int EggLocation { get; set; }
public bool EvolveOnTrade { get; set; }
public int Ball { get; set; } = 4;
public int CurrentLevel { get; set; } = -1;

View file

@ -0,0 +1,27 @@
namespace PKHeX.Core
{
public interface ILocation
{
int Location { get; set; }
int EggLocation { get; set; }
}
public static partial class Extensions
{
public static int GetLocation(this ILocation encounter)
{
if (encounter == null)
return -1;
return encounter.Location != 0
? encounter.Location
: encounter.EggLocation;
}
internal static string GetEncounterLocation(this ILocation Encounter, int gen)
{
int loc = Encounter.GetLocation();
if (loc < 0)
return null;
return GameInfo.GetLocationName(loc != Encounter.Location, loc, gen, gen);
}
}
}

View file

@ -6,7 +6,7 @@ namespace PKHeX.Core
/// <summary>
/// Mystery Gift Template File
/// </summary>
public abstract class MysteryGift : IEncounterable, IMoveset, IGeneration
public abstract class MysteryGift : IEncounterable, IMoveset, IGeneration, ILocation
{
/// <summary>
/// Determines whether or not the given length of bytes is valid for a mystery gift.
@ -142,6 +142,7 @@ namespace PKHeX.Core
public abstract int TID { get; set; }
public abstract int SID { get; set; }
public abstract string OT_Name { get; set; }
public abstract int Location { get; set; }
public abstract int Level { get; set; }
public int LevelMin => Level;
@ -154,5 +155,6 @@ namespace PKHeX.Core
public bool Gen3 => Format == 3;
public virtual bool EggEncounter => IsEgg;
public int Generation { get => Format; set {} }
public abstract int EggLocation { get; set; }
}
}

View file

@ -59,7 +59,7 @@ namespace PKHeX.Core
public override int Gender { get => Data[0x35]; set => Data[0x35] = (byte)value; }
public int AbilityType { get => Data[0x36]; set => Data[0x36] = (byte)value; }
public int PIDType { get => Data[0x37]; set => Data[0x37] = (byte)value; }
public ushort EggLocation { get => BitConverter.ToUInt16(Data, 0x38); set => BitConverter.GetBytes(value).CopyTo(Data, 0x38); }
public override int EggLocation { get => BitConverter.ToUInt16(Data, 0x38); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x38); }
public ushort MetLocation { get => BitConverter.ToUInt16(Data, 0x3A); set => BitConverter.GetBytes(value).CopyTo(Data, 0x3A); }
public int MetLevel { get => Data[0x3C]; set => Data[0x3C] = (byte)value; }
public int CNT_Cool { get => Data[0x3D]; set => Data[0x3D] = (byte)value; }
@ -143,7 +143,7 @@ namespace PKHeX.Core
public int[] IVs => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD };
public bool IsNicknamed => Nickname.Length > 0;
public override bool IsShiny => PIDType == 2;
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
public override int[] Moves => new[] { Move1, Move2, Move3, Move4 };
public override bool IsPokémon { get => CardType == 1; set { if (value) CardType = 1; } }
public override bool IsItem { get => CardType == 2; set { if (value) CardType = 2; } }

View file

@ -90,6 +90,8 @@ namespace PKHeX.Core
public override int TID { get => Gift.TID; set => Gift.TID = value; }
public override int SID { get => Gift.SID; set => Gift.SID = value; }
public override string OT_Name { get => Gift.OT_Name; set => Gift.OT_Name = value; }
public override int Location { get => Gift.Location; set => Gift.Location = value; }
public override int EggLocation { get => Gift.EggLocation; set => Gift.EggLocation = value; }
public bool GiftEquals(PGT pgt)
{
@ -226,6 +228,8 @@ namespace PKHeX.Core
public override int TID { get => (ushort)PK.TID; set => PK.TID = value; }
public override int SID { get => (ushort)PK.SID; set => PK.SID = value; }
public override string OT_Name { get => PK.OT_Name; set => PK.OT_Name = value; }
public override int Location { get => PK.Met_Location; set => PK.Met_Location = value; }
public override int EggLocation { get => PK.Egg_Location; set => PK.Egg_Location = value; }
public override PKM ConvertToPKM(SaveFile SAV)
{

View file

@ -22,7 +22,8 @@ namespace PKHeX.Core
public int OT_Gender { get; set; } = 3;
public override int TID { get; set; }
public override int SID { get; set; }
public int Met_Location { get; internal set; } = 255;
public override int Location { get; set; } = 255;
public override int EggLocation { get => 0; set {} }
public int Version { get; set; }
public int Language { get; set; } = -1;
public override int Species { get; set; }
@ -66,7 +67,7 @@ namespace PKHeX.Core
{
Species = Species,
Met_Level = Met_Level,
Met_Location = Met_Location,
Met_Location = Location,
Ball = 4,
EXP = PKX.GetEXP(Level, Species),

View file

@ -158,7 +158,7 @@ namespace PKHeX.Core
public int PIDType {
get => Data[0xA3];
set => Data[0xA3] = (byte)value; }
public int EggLocation {
public override int EggLocation {
get => BitConverter.ToUInt16(Data, 0xA4);
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xA4); }
public int MetLocation {
@ -253,6 +253,7 @@ namespace PKHeX.Core
}
}
public bool IsNicknamed => Nickname.Length > 0;
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
public override int[] Moves
{

View file

@ -180,7 +180,7 @@ namespace PKHeX.Core
public int PIDType {
get => Data[0xA3];
set => Data[0xA3] = (byte)value; }
public int EggLocation {
public override int EggLocation {
get => BitConverter.ToUInt16(Data, 0xA4);
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xA4); }
public int MetLocation {
@ -277,6 +277,7 @@ namespace PKHeX.Core
}
}
public bool IsNicknamed => Nickname.Length > 0 || IsEgg;
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
public override int[] Moves
{