Add safari slots for floette 2/3

Move the array into the constructor; let it get garbage collected rather than leaving it as static
This commit is contained in:
Kurt 2021-02-21 15:18:58 -08:00
parent 41096fb56e
commit c8b12a9ddc
3 changed files with 48 additions and 34 deletions

View file

@ -18,20 +18,12 @@ namespace PKHeX.Core
return result;
}
public EncounterArea6XY(ICollection<int> species) : base(GameVersion.XY)
public EncounterArea6XY() : base(GameVersion.XY)
{
Location = 148;
Location = 148; // Friend Safari
Type = SlotType.FriendSafari;
var slots = new EncounterSlot6XY[species.Count];
int ctr = 0;
foreach (var s in species)
slots[ctr++] = new EncounterSlot6XY(this, s, 0, 30, 30);
// Find Vivillon and replace form to be region-random
var idx = Array.FindIndex(slots, z => z.Species == (int)Species.Vivillon);
slots[idx] = new EncounterSlot6XY(this, (int)Species.Vivillon, 30, 30, 30);
Slots = slots;
Slots = LoadSafariSlots();
}
private EncounterArea6XY(byte[] data, GameVersion game) : base(game)
@ -42,6 +34,50 @@ namespace PKHeX.Core
Slots = ReadSlots(data);
}
private EncounterSlot6XY[] LoadSafariSlots()
{
const int SpeciesFormSlots = 4;
// Single form species
ushort[] species =
{
002, 005, 008, 012, 014, 016, 021, 025, 027, 035,
038, 039, 043, 044, 046, 049, 049, 051, 056, 058,
061, 063, 067, 077, 082, 083, 084, 087, 089, 091,
095, 096, 098, 101, 105, 112, 113, 114, 125, 126,
127, 130, 131, 132, 133, 148, 163, 165, 168, 175,
178, 184, 190, 191, 194, 195, 202, 203, 205, 206,
209, 213, 214, 215, 215, 216, 218, 219, 221, 222,
224, 225, 227, 231, 235, 236, 247, 262, 267, 268,
274, 281, 284, 286, 290, 294, 297, 299, 302, 303,
303, 307, 310, 313, 314, 317, 323, 326, 328, 332,
336, 342, 352, 353, 356, 357, 359, 361, 363, 372,
375, 400, 404, 415, 417, 419, 423, 426, 437, 442,
444, 447, 452, 454, 459, 506, 510, 511, 513, 515,
517, 520, 523, 525, 527, 530, 531, 536, 538, 539,
541, 544, 548, 551, 556, 557, 561, 569, 572, 575,
578, 581, 586, 587, 596, 597, 600, 608, 611, 614,
618, 619, 621, 623, 624, 627, 629, 636, 651, 654,
657, 660, 662, 662, 668, 673, 674, 677, 682, 684,
686, 689, 694, 701, 702, 702, 705, 707, 708, 710,
712, 714
};
var slots = new EncounterSlot6XY[species.Length + SpeciesFormSlots];
int i = 0;
for (; i < species.Length; i++)
slots[i] = new EncounterSlot6XY(this, species[i], 0, 30, 30);
// Floette has 3 separate forms (RBY)
slots[i++] = new EncounterSlot6XY(this, (int)Species.Floette, 0, 30, 30);
slots[i++] = new EncounterSlot6XY(this, (int)Species.Floette, 2, 30, 30);
slots[i++] = new EncounterSlot6XY(this, (int)Species.Floette, 3, 30, 30);
// Region Random Vivillon
slots[i] = new EncounterSlot6XY(this, (int)Species.Vivillon, 30, 30, 30);
return slots;
}
private EncounterSlot6XY[] ReadSlots(byte[] data)
{
const int size = 4;

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core
/// </summary>
internal static class Encounters6
{
private static readonly EncounterArea6XY FriendSafari = new(Legal.FriendSafari);
private static readonly EncounterArea6XY FriendSafari = new();
internal static readonly EncounterArea6XY[] SlotsX = EncounterArea6XY.GetAreas(Get("x", "xy"), GameVersion.X, FriendSafari);
internal static readonly EncounterArea6XY[] SlotsY = EncounterArea6XY.GetAreas(Get("y", "xy"), GameVersion.Y, FriendSafari);
internal static readonly EncounterArea6AO[] SlotsA = EncounterArea6AO.GetAreas(Get("a", "ao"), GameVersion.AS);

View file

@ -251,28 +251,6 @@ namespace PKHeX.Core
332, 334, 336, 338, 340, 342, 344, 346, 350, 352, 354
};
internal static readonly HashSet<int> FriendSafari = new()
{
190, 206, 216, 506, 294, 352, 531, 572, 113, 132, 133, 235,
012, 046, 165, 415, 267, 284, 313, 314, 049, 127, 214, 666,
262, 274, 624, 629, 215, 332, 342, 551, 302, 359, 510, 686,
444, 611, 148, 372, 714, 621, 705,
101, 417, 587, 702, 025, 125, 618, 694, 310, 404, 523, 596,
175, 209, 281, 702, 039, 303, 682, 684, 035, 670,
056, 067, 307, 619, 538, 539, 674, 236, 286, 297, 447,
058, 077, 126, 513, 005, 218, 636, 668, 038, 654, 662,
016, 021, 083, 084, 163, 520, 527, 581, 357, 627, 662, 701,
353, 608, 708, 710, 356, 426, 442, 623,
043, 114, 191, 511, 002, 541, 548, 586, 556, 651, 673,
027, 194, 231, 328, 051, 105, 290, 323, 423, 536, 660,
225, 361, 363, 459, 215, 614, 712, 087, 091, 131, 221,
014, 044, 268, 336, 049, 168, 317, 569, 089, 452, 454, 544,
063, 096, 326, 517, 202, 561, 677, 178, 203, 575, 578,
299, 525, 557, 095, 219, 222, 247, 112, 213, 689,
082, 303, 597, 205, 227, 375, 600, 437, 530, 707,
098, 224, 400, 515, 008, 130, 195, 419, 061, 184, 657
};
internal static readonly byte[] MovePP_XY =
{
00,