diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs index 03b9c902a..dd06c1c2d 100644 --- a/PKHeX.Core/MysteryGifts/MysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs @@ -38,6 +38,8 @@ namespace PKHeX.Core case WC6.SizeFull when ext == ".wc6full": case WC6.Size when ext == ".wc6": return new WC6(data); + case WR7.Size when ext == ".wr7": + return new WR7(data); case PGF.Size when ext == ".pgf": return new PGF(data); @@ -69,6 +71,7 @@ namespace PKHeX.Core if (BitConverter.ToUInt32(data, 0x4C) / 10000 < 2000) return new WC7(data); return new WC6(data); + case WR7.Size: return new WR7(data); case PGF.Size: return new PGF(data); case PGT.Size: return new PGT(data); diff --git a/PKHeX.Core/Saves/Substructures/Gen7/WB7Records.cs b/PKHeX.Core/Saves/Substructures/Gen7/WB7Records.cs index 01f3d2968..37ffd78f9 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/WB7Records.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/WB7Records.cs @@ -13,14 +13,14 @@ namespace PKHeX.Core private const int RecordMax = 10; // 0xE90 > (0x140 * 0xA = 0xC80), not sure what final 0x210 bytes are used for private const int FlagCountMax = 0x1C00; // (7168) end of the block? - private int FlagStart => Offset + (RecordMax * WR7.SIZE); + private int FlagStart => Offset + (RecordMax * WR7.Size); private int GetRecordOffset(int index) { if (index >= RecordMax) throw new ArgumentException(nameof(index)); - return Offset + (index * WR7.SIZE); + return Offset + (index * WR7.Size); } private int GetFlagOffset(int flag) @@ -33,8 +33,8 @@ namespace PKHeX.Core public WR7 GetRecord(int index) { int ofs = GetRecordOffset(index); - byte[] data = new byte[WR7.SIZE]; - Array.Copy(Data, ofs, data, 0, WR7.SIZE); + byte[] data = new byte[WR7.Size]; + Array.Copy(Data, ofs, data, 0, WR7.Size); return new WR7(data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/WR7.cs b/PKHeX.Core/Saves/Substructures/Gen7/WR7.cs index 93b971d5e..fc094f384 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/WR7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/WR7.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core { public class WR7 : MysteryGift { - public const int SIZE = 0x140; + public const int Size = 0x140; public WR7(byte[] data) => Data = data; @@ -88,7 +88,6 @@ namespace PKHeX.Core // Mystery Gift implementation public override int Format => 7; - public override PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) => throw new Exception("Non-convertible format."); protected override bool IsMatchExact(PKM pkm, IEnumerable vs) => false; protected override bool IsMatchDeferred(PKM pkm) => false; public override int Location { get; set; } @@ -116,5 +115,21 @@ namespace PKHeX.Core GiftType = WR7GiftType.Pokemon; } } + + public override PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) + { + if (!IsPokémon) + return null; + + var pk = new PB7(); + SAV.ApplyToPKM(pk); + if (!GameVersion.GG.Contains((GameVersion) SAV.Game)) + pk.Version = (int) GameVersion.GP; + + pk.Species = Species; + pk.Met_Level = pk.CurrentLevel = Level; + + return pk; // can't really do much more + } } }