diff --git a/PKHeX.Core/Saves/Substructures/Gen7/GoParkEntities.cs b/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs similarity index 54% rename from PKHeX.Core/Saves/Substructures/Gen7/GoParkEntities.cs rename to PKHeX.Core/Saves/Substructures/Gen7/GP1.cs index ec128dc02..9548ace4b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/GoParkEntities.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs @@ -1,70 +1,22 @@ -using System; -using System.Collections; +using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using System.Text; namespace PKHeX.Core { - public sealed class GoParkEntities : SaveBlock, IEnumerable - { - public GoParkEntities(SaveFile sav) : base(sav) - { - Offset = ((SAV7b)sav).GetBlockOffset(BelugaBlockIndex.GoParkEntities); - } - - public const int SlotsPerArea = 50; - public const int Areas = 20; - public const int Count = SlotsPerArea * Areas; // 1000 - - public GoPKM this[int index] - { - get - { - Debug.Assert(index < Count); - return GoPKM.FromData(Data, Offset + (GoPKM.SIZE * index)); - } - set - { - Debug.Assert(index < Count); - value.WriteTo(Data, Offset + (GoPKM.SIZE * index)); - } - } - - public GoPKM[] AllEntities - { - get - { - var value = new GoPKM[Count]; - for (int i = 0; i < value.Length; i++) - value[i] = this[i]; - return value; - } - set - { - Debug.Assert(value?.Length == Count); - for (int i = 0; i < value.Length; i++) - this[i] = value[i]; - } - } - - public IEnumerable DumpAll(IReadOnlyList speciesNames) => AllEntities.Select((z, i) => new {Index = i, Entry = z}).Where(z => z.Entry.Species > 0).Select(z => z.Entry.Dump(speciesNames, z.Index)); - - public IEnumerator GetEnumerator() => (IEnumerator)AllEntities.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => AllEntities.GetEnumerator(); - } - - public class GoPKM + /// + /// Go Park Entity transferred to . + /// + public class GP1 { public const int SIZE = 0x1B0; public byte[] Data { get; } - public GoPKM() => Data = (byte[])Blank.Clone(); + public GP1() => Data = (byte[])Blank.Clone(); public void WriteTo(byte[] data, int offset) => Data.CopyTo(data, offset); - public static GoPKM FromData(byte[] data, int offset) + public static GP1 FromData(byte[] data, int offset) { - var gpkm = new GoPKM(); + var gpkm = new GP1(); Array.Copy(data, offset, gpkm.Data, 0, SIZE); return gpkm; } @@ -101,7 +53,7 @@ namespace PKHeX.Core public int Gender => Data[0x70] - 1; // M=1, F=2, G=3 ;; shift down by 1. public bool Flag => Data[0x72] == 1; - public bool Shiny => Data[0x73] == 1; + public bool IsShiny => Data[0x73] == 1; // https://bulbapedia.bulbagarden.net/wiki/List_of_moves_in_Pok%C3%A9mon_GO public int Move1 => BitConverter.ToInt32(Data, 0x74); // uses Go Indexes @@ -113,8 +65,10 @@ namespace PKHeX.Core public static readonly string[] Genders = {"M", "F", "-"}; public string GenderString => (uint) Gender >= Genders.Length ? string.Empty : Genders[Gender]; - public string ShinyString => Shiny ? "SHINY" : string.Empty; + public string ShinyString => IsShiny ? "★ " : string.Empty; + public string FileName => $"{ShinyString}{Nickname} lv{Level} - {IV1:00}.{IV2:00}.{IV3:00}, Move1 {Move1}, Move2 {Move2}.gp1"; - public string Dump(IReadOnlyList speciesNames, int index) => $"{index:000} {Nickname} ({speciesNames[Species]} {ShinyString} [{GenderString}]) @ lv{Level} - {IV1:00}/{IV2:00}/{IV3:00}, Move1 {Move1}, Move2 {Move2}, Captured in {GeoCityName} by {Username1}."; + + public string Dump(IReadOnlyList speciesNames, int index) => $"{index:000} {Nickname} ({speciesNames[Species]} {ShinyString}[{GenderString}]) @ lv{Level} - {IV1:00}/{IV2:00}/{IV3:00}, Move1 {Move1}, Move2 {Move2}, Captured in {GeoCityName} by {Username1}."; } } \ No newline at end of file diff --git a/PKHeX.Core/Saves/Substructures/Gen7/GoParkStorage.cs b/PKHeX.Core/Saves/Substructures/Gen7/GoParkStorage.cs new file mode 100644 index 000000000..82ef964eb --- /dev/null +++ b/PKHeX.Core/Saves/Substructures/Gen7/GoParkStorage.cs @@ -0,0 +1,55 @@ +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; + +namespace PKHeX.Core +{ + public sealed class GoParkStorage : SaveBlock, IEnumerable + { + public GoParkStorage(SaveFile sav) : base(sav) + { + Offset = ((SAV7b)sav).GetBlockOffset(BelugaBlockIndex.GoParkEntities); + } + + public const int SlotsPerArea = 50; + public const int Areas = 20; + public const int Count = SlotsPerArea * Areas; // 1000 + + public GP1 this[int index] + { + get + { + Debug.Assert(index < Count); + return GP1.FromData(Data, Offset + (GP1.SIZE * index)); + } + set + { + Debug.Assert(index < Count); + value.WriteTo(Data, Offset + (GP1.SIZE * index)); + } + } + + public GP1[] AllEntities + { + get + { + var value = new GP1[Count]; + for (int i = 0; i < value.Length; i++) + value[i] = this[i]; + return value; + } + set + { + Debug.Assert(value?.Length == Count); + for (int i = 0; i < value.Length; i++) + this[i] = value[i]; + } + } + + public IEnumerable DumpAll(IReadOnlyList speciesNames) => AllEntities.Select((z, i) => new {Index = i, Entry = z}).Where(z => z.Entry.Species > 0).Select(z => z.Entry.Dump(speciesNames, z.Index)); + + public IEnumerator GetEnumerator() => (IEnumerator)AllEntities.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => AllEntities.GetEnumerator(); + } +} \ No newline at end of file