Make multiple-met locations a single object instance

make trade have Any again; it's a marker to apply the gameversion since we're lazy
This commit is contained in:
Kurt 2020-08-30 19:24:24 -07:00
parent b5677758be
commit e3ad6ec55d
10 changed files with 227 additions and 206 deletions

View file

@ -19,8 +19,6 @@ namespace PKHeX.Core
return source.Where(s => s.Version.Contains(game)).ToArray();
}
internal static T[] ConcatAll<T>(params IEnumerable<T>[] arr) => arr.SelectMany(z => z).ToArray();
internal static EncounterStatic Clone(this EncounterStatic s, int location)
{
var result = s.Clone();
@ -28,30 +26,6 @@ namespace PKHeX.Core
return result;
}
internal static T[] Clone<T>(this T s, int[] locations) where T : EncounterStatic
{
var Encounters = new T[locations.Length];
for (int i = 0; i < locations.Length; i++)
Encounters[i] = (T)s.Clone(locations[i]);
return Encounters;
}
internal static IEnumerable<EncounterStatic5> DreamRadarClone(this EncounterStatic5 s)
{
for (int i = 0; i < 8; i++)
yield return s.DreamRadarClone((5 * i) + 5); // Level from 5->40 depends on the number of badges
}
private static EncounterStatic5 DreamRadarClone(this EncounterStatic5 s, int level)
{
var result = (EncounterStatic5)s.Clone(level);
result.Level = level;
result.Location = 30015;// Pokemon Dream Radar
result.Gift = true; // Only
result.Ball = 25; // Dream Ball
return result;
}
internal static void MarkEncounterTradeStrings<T>(T[] table, string[][] strings) where T : EncounterTrade
{
int half = strings[1].Length / 2;

View file

@ -1,5 +1,4 @@
using static PKHeX.Core.EncounterUtil;
using static PKHeX.Core.GameVersion;
using static PKHeX.Core.GameVersion;
namespace PKHeX.Core
{

View file

@ -217,43 +217,7 @@ namespace PKHeX.Core
};
#endregion
#region Static Encounter/Gift Tables
private static readonly int[] Roaming_MetLocation_DPPt_Grass =
{
// Routes 201-218, 221-222 can be encountered in grass
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 36, 37,
47, // Valley Windworks
49, // Fuego Ironworks
};
private static readonly int[] Roaming_MetLocation_DPPt_Surf =
{
// Routes 203-205, 208-210, 212-214, 218-222 can be encountered in water
18, 19, 20, 23, 24, 25, 27, 28, 29, 33,
34, 35, 36, 37,
47, // Valley Windworks
49, // Fuego Ironworks
};
private static readonly EncounterStaticTyped[] Encounter_DPPt_Roam_Grass =
{
new EncounterStaticTyped { Species = 481, Level = 50, Roaming = true, TypeEncounter = EncounterType.TallGrass }, // Mesprit
new EncounterStaticTyped { Species = 488, Level = 50, Roaming = true, TypeEncounter = EncounterType.TallGrass }, // Cresselia
new EncounterStaticTyped { Species = 144, Level = 60, Roaming = true, TypeEncounter = EncounterType.TallGrass, Version = Pt }, // Articuno
new EncounterStaticTyped { Species = 145, Level = 60, Roaming = true, TypeEncounter = EncounterType.TallGrass, Version = Pt }, // Zapdos
new EncounterStaticTyped { Species = 146, Level = 60, Roaming = true, TypeEncounter = EncounterType.TallGrass, Version = Pt }, // Moltres
};
private static readonly EncounterStaticTyped[] Encounter_DPPt_Roam_Surf =
{
new EncounterStaticTyped { Species = 481, Level = 50, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing }, // Mesprit
new EncounterStaticTyped { Species = 488, Level = 50, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing }, // Cresselia
new EncounterStaticTyped { Species = 144, Level = 60, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing, Version = Pt }, // Articuno
new EncounterStaticTyped { Species = 145, Level = 60, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing, Version = Pt }, // Zapdos
new EncounterStaticTyped { Species = 146, Level = 60, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing, Version = Pt }, // Moltres
};
private static readonly EncounterStatic4[] Encounter_DPPt_Regular =
private static readonly EncounterStatic4[] Encounter_DPPt =
{
// Starters
new EncounterStaticTyped { Gift = true, Species = 387, Level = 5, Location = 076, TypeEncounter = EncounterType.Starter_Fossil_Gift_DP, Version = DP }, // Turtwig @ Lake Verity
@ -318,69 +282,13 @@ namespace PKHeX.Core
new EncounterStatic4 { Species = 492, Form = 0, Level = 30, Location = 063, Version = Pt, Fateful = true }, // Shaymin @ Flower Paradise
new EncounterStatic4 { Species = 492, Form = 0, Level = 30, Location = 063, Version = DP, Fateful = false }, // Shaymin @ Flower Paradise (Unreleased in Diamond and Pearl)
new EncounterStaticTyped { Species = 493, Form = 0, Level = 80, Location = 086, TypeEncounter = EncounterType.Cave_HallOfOrigin }, // Arceus @ Hall of Origin (Unreleased)
};
private static readonly EncounterStatic4[] Encounter_DPPt = Encounter_DPPt_Roam_Grass.SelectMany(e => e.Clone(Roaming_MetLocation_DPPt_Grass)).Concat(
Encounter_DPPt_Roam_Surf.SelectMany(e => e.Clone(Roaming_MetLocation_DPPt_Surf))).Concat(
Encounter_DPPt_Regular).ToArray();
// Grass 29-39, 42-46, 47, 48
// Surf 30-32 34-35, 40-45, 47
// Route 45 innacesible surf
private static readonly int[] Roaming_MetLocation_HGSS_Johto_Grass =
{
// Routes 29-48 can be encountered in grass
// Won't go to routes 40,41,47,48
177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
187, 190, 191, 192, 193, 194,
};
private static readonly int[] Roaming_MetLocation_HGSS_Johto_Surf =
{
// Routes 30-32,34-35,40-45 and 47 can be encountered in water
// Won't go to routes 40,41,47,48
178, 179, 180, 182, 183, 190, 191, 192, 193
};
private static readonly EncounterStaticTyped[] Encounter_HGSS_JohtoRoam_Grass =
{
new EncounterStaticTyped { Species = 243, Level = 40, Roaming = true, TypeEncounter = EncounterType.TallGrass, }, // Raikou
new EncounterStaticTyped { Species = 244, Level = 40, Roaming = true, TypeEncounter = EncounterType.TallGrass, }, // Entei
};
private static readonly EncounterStaticTyped[] Encounter_HGSS_JohtoRoam_Surf =
{
new EncounterStaticTyped { Species = 243, Level = 40, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing, }, // Raikou
new EncounterStaticTyped { Species = 244, Level = 40, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing, }, // Entei
};
private static readonly int[] Roaming_MetLocation_HGSS_Kanto_Grass =
{
// Route 01-18,21,22,24,26 and 28 can be encountered in grass
// Won't go to route 23 25 27
149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166,
169, 170, 172, 174, 176,
};
private static readonly int[] Roaming_MetLocation_HGSS_Kanto_Surf =
{
// Route 4,6,9,10,12,13,19-22,24,26 and 28 can be encountered in water
// Won't go to route 23 25 27
152, 154, 157, 158, 160, 161, 167, 168, 169, 170,
172, 174, 176,
};
private static readonly EncounterStaticTyped[] Encounter_HGSS_KantoRoam_Grass =
{
new EncounterStaticTyped { Species = 380, Level = 35, Version = HG, Roaming = true, TypeEncounter = EncounterType.TallGrass, }, // Latias
new EncounterStaticTyped { Species = 381, Level = 35, Version = SS, Roaming = true, TypeEncounter = EncounterType.TallGrass, }, // Latios
};
private static readonly EncounterStaticTyped[] Encounter_HGSS_KantoRoam_Surf =
{
new EncounterStaticTyped { Species = 380, Level = 35, Version = HG, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing, }, // Latias
new EncounterStaticTyped { Species = 381, Level = 35, Version = SS, Roaming = true, TypeEncounter = EncounterType.Surfing_Fishing, }, // Latios
// Roamers
new EncounterStaticTyped { Roaming = true, Species = 481, Level = 50, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, Version = DPPt }, // Mesprit
new EncounterStaticTyped { Roaming = true, Species = 488, Level = 50, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, Version = DPPt }, // Cresselia
new EncounterStaticTyped { Roaming = true, Species = 144, Level = 60, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, Version = Pt }, // Articuno
new EncounterStaticTyped { Roaming = true, Species = 145, Level = 60, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, Version = Pt }, // Zapdos
new EncounterStaticTyped { Roaming = true, Species = 146, Level = 60, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, Version = Pt }, // Moltres
};
internal static readonly EncounterStaticTyped SpikyEaredPichu = new EncounterStaticTyped // Spiky-Eared Pichu @ Ilex Forest
@ -396,7 +304,7 @@ namespace PKHeX.Core
Shiny = Shiny.Never
};
private static readonly EncounterStatic4[] Encounter_HGSS_Regular =
private static readonly EncounterStatic4[] Encounter_HGSS =
{
// Starters
new EncounterStaticTyped { Gift = true, Species = 001, Level = 05, Location = 138, TypeEncounter = EncounterType.Starter_Fossil_Gift_Pt_DPTrio }, // Bulbasaur @ Pallet Town
@ -472,14 +380,15 @@ namespace PKHeX.Core
new EncounterStaticTyped { Species = 483, Level = 01, Location = 231, Gift = true, TypeEncounter = EncounterType.Starter_Fossil_Gift_Pt_DPTrio }, // Dialga @ Sinjoh Ruins
new EncounterStaticTyped { Species = 484, Level = 01, Location = 231, Gift = true, TypeEncounter = EncounterType.Starter_Fossil_Gift_Pt_DPTrio }, // Palkia @ Sinjoh Ruins
new EncounterStaticTyped { Species = 487, Level = 01, Location = 231, Gift = true, TypeEncounter = EncounterType.Starter_Fossil_Gift_Pt_DPTrio, Form = 1, HeldItem = 112 }, // Giratina @ Sinjoh Ruins
};
private static readonly EncounterStatic4[] Encounter_HGSS = ConcatAll(
Encounter_HGSS_KantoRoam_Grass.SelectMany(e => e.Clone(Roaming_MetLocation_HGSS_Kanto_Grass)),
Encounter_HGSS_KantoRoam_Surf.SelectMany(e => e.Clone(Roaming_MetLocation_HGSS_Kanto_Surf)),
Encounter_HGSS_JohtoRoam_Grass.SelectMany(e => e.Clone(Roaming_MetLocation_HGSS_Johto_Grass)),
Encounter_HGSS_JohtoRoam_Surf.SelectMany(e => e.Clone(Roaming_MetLocation_HGSS_Johto_Surf)),
Encounter_HGSS_Regular);
// Johto Roamers
new EncounterStaticTyped { Roaming = true, Species = 243, Level = 40, Version = HGSS, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, }, // Raikou
new EncounterStaticTyped { Roaming = true, Species = 244, Level = 40, Version = HGSS, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, }, // Entei
// Kanto Roamers
new EncounterStaticTyped { Roaming = true, Species = 380, Level = 35, Version = HG, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, }, // Latias
new EncounterStaticTyped { Roaming = true, Species = 381, Level = 35, Version = SS, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, }, // Latios
};
#endregion
#region Trade Tables
private static readonly string[] RanchOTNames = { string.Empty, "ユカリ", "Hayley", "EULALIE", "GIULIA", "EUKALIA", string.Empty, "Eulalia" };

View file

@ -60,34 +60,34 @@ namespace PKHeX.Core
#region Dream Radar Tables
private static readonly EncounterStatic5[] Encounter_DreamRadar =
private static readonly EncounterStatic5DR[] Encounter_DreamRadar =
{
new EncounterStatic5 { Shiny = Shiny.Never, Species = 120, Ability = 4 }, // Staryu
new EncounterStatic5 { Shiny = Shiny.Never, Species = 137, Ability = 4 }, // Porygon
new EncounterStatic5 { Shiny = Shiny.Never, Species = 174, Ability = 4 }, // Igglybuff
new EncounterStatic5 { Shiny = Shiny.Never, Species = 175, Ability = 4 }, // Togepi
new EncounterStatic5 { Shiny = Shiny.Never, Species = 213, Ability = 4 }, // Shuckle
new EncounterStatic5 { Shiny = Shiny.Never, Species = 238, Ability = 4 }, // Smoochum
new EncounterStatic5 { Shiny = Shiny.Never, Species = 280, Ability = 4 }, // Ralts
new EncounterStatic5 { Shiny = Shiny.Never, Species = 333, Ability = 4 }, // Swablu
new EncounterStatic5 { Shiny = Shiny.Never, Species = 425, Ability = 4 }, // Drifloon
new EncounterStatic5 { Shiny = Shiny.Never, Species = 436, Ability = 4 }, // Bronzor
new EncounterStatic5 { Shiny = Shiny.Never, Species = 442, Ability = 4 }, // Spiritomb
new EncounterStatic5 { Shiny = Shiny.Never, Species = 447, Ability = 4 }, // Riolu
new EncounterStatic5 { Shiny = Shiny.Never, Species = 479, }, // Rotom (no HA)
new EncounterStatic5 { Shiny = Shiny.Never, Species = 517, Ability = 4 }, // Munna
new EncounterStatic5 { Shiny = Shiny.Never, Species = 561, Ability = 4 }, // Sigilyph
new EncounterStatic5 { Shiny = Shiny.Never, Species = 641, Ability = 4, Form = 1}, // Therian Tornadus
new EncounterStatic5 { Shiny = Shiny.Never, Species = 642, Ability = 4, Form = 1}, // Therian Thundurus
new EncounterStatic5 { Shiny = Shiny.Never, Species = 645, Ability = 4, Form = 1}, // Therian Landorus
new EncounterStatic5 { Shiny = Shiny.Never, Species = 249, Ability = 4 }, // Lugia (SoulSilver cart)
new EncounterStatic5 { Shiny = Shiny.Never, Species = 250, Ability = 4 }, // Ho-Oh (HeartGold cart)
new EncounterStatic5 { Shiny = Shiny.Never, Species = 483, Ability = 4 }, // Dialga (Diamond cart)
new EncounterStatic5 { Shiny = Shiny.Never, Species = 484, Ability = 4 }, // Palkia (Pearl cart)
new EncounterStatic5 { Shiny = Shiny.Never, Species = 487, Ability = 4 }, // Giratina (Platinum cart)
new EncounterStatic5 { Shiny = Shiny.Never, Species = 079, Ability = 4 }, // Slowpoke
new EncounterStatic5 { Shiny = Shiny.Never, Species = 163, Ability = 4 }, // Hoothoot
new EncounterStatic5 { Shiny = Shiny.Never, Species = 374, Ability = 4 }, // Beldum
new EncounterStatic5DR(120, 0), // Staryu
new EncounterStatic5DR(137, 0), // Porygon
new EncounterStatic5DR(174, 0), // Igglybuff
new EncounterStatic5DR(175, 0), // Togepi
new EncounterStatic5DR(213, 0), // Shuckle
new EncounterStatic5DR(238, 0), // Smoochum
new EncounterStatic5DR(280, 0), // Ralts
new EncounterStatic5DR(333, 0), // Swablu
new EncounterStatic5DR(425, 0), // Drifloon
new EncounterStatic5DR(436, 0), // Bronzor
new EncounterStatic5DR(442, 0), // Spiritomb
new EncounterStatic5DR(447, 0), // Riolu
new EncounterStatic5DR(479, 0, 0), // Rotom (no HA)
new EncounterStatic5DR(517, 0), // Munna
new EncounterStatic5DR(561, 0), // Sigilyph
new EncounterStatic5DR(641, 1), // Therian Tornadus
new EncounterStatic5DR(642, 1), // Therian Thundurus
new EncounterStatic5DR(645, 1), // Therian Landorus
new EncounterStatic5DR(249, 0), // Lugia (SoulSilver cart)
new EncounterStatic5DR(250, 0), // Ho-Oh (HeartGold cart)
new EncounterStatic5DR(483, 0), // Dialga (Diamond cart)
new EncounterStatic5DR(484, 0), // Palkia (Pearl cart)
new EncounterStatic5DR(487, 0), // Giratina (Platinum cart)
new EncounterStatic5DR(079, 0), // Slowpoke
new EncounterStatic5DR(163, 0), // Hoothoot
new EncounterStatic5DR(374, 0), // Beldum
};
#endregion
@ -436,23 +436,7 @@ namespace PKHeX.Core
#endregion
#region Static Encounter/Gift Tables
private static readonly int[] Roaming_MetLocation_BW =
{
25,26,27,28, // Route 12, 13, 14, 15 Night latter half
15,16,31, // Route 2, 3, 18 Morning
17,18,29, // Route 4, 5, 16 Daytime
19,20,21, // Route 6, 7, 8 Evening
22,23,24, // Route 9, 10, 11 Night former half
};
private static readonly EncounterStatic5[] Encounter_BW_Roam =
{
new EncounterStatic5 { Species = 641, Level = 40, Version = GameVersion.B, Roaming = true }, // Tornadus
new EncounterStatic5 { Species = 642, Level = 40, Version = GameVersion.W, Roaming = true }, // Thundurus
};
private static readonly EncounterStatic5[] Encounter_BW_Regular =
private static readonly EncounterStatic5[] Encounter_BW =
{
// Starters @ Nuvema Town
new EncounterStatic5 { Gift = true, Species = 495, Level = 5, Location = 004, }, // Snivy
@ -500,9 +484,11 @@ namespace PKHeX.Core
new EncounterStatic5 { Species = 494, Level = 15, Location = 062, Shiny = Shiny.Never}, // Victini @ Liberty Garden
new EncounterStatic5 { Species = 570, Level = 10, Location = 008, Shiny = Shiny.Never, Gender = 0, }, // Zorua @ Castelia City
new EncounterStatic5 { Species = 571, Level = 25, Location = 072, Shiny = Shiny.Never, Gender = 1, }, // Zoroark @ Lostlorn Forest
};
private static readonly EncounterStatic5[] Encounter_BW = Encounter_BW_Roam.SelectMany(e => e.Clone(Roaming_MetLocation_BW)).Concat(Encounter_BW_Regular).ToArray();
// Roamer
new EncounterStatic5 { Roaming = true, Species = 641, Level = 40, Version = GameVersion.B, Location = 25, }, // Tornadus
new EncounterStatic5 { Roaming = true, Species = 642, Level = 40, Version = GameVersion.W, Location = 25, }, // Thundurus
};
private static readonly EncounterStatic5[] Encounter_B2W2_Regular =
{
@ -588,7 +574,7 @@ namespace PKHeX.Core
new EncounterStatic5N(0xFF00001F) { Species = 570, Level = 25, Location = 010, Ability = 1, Nature = Nature.Hasty, Gift = true } // N's Zorua @ Driftveil City
};
private static readonly EncounterStatic5[] Encounter_B2W2 = Encounter_DreamRadar.SelectMany(e => e.DreamRadarClone()).Concat(Encounter_B2W2_Regular).ToArray();
private static readonly EncounterStatic5[] Encounter_B2W2 = ArrayUtil.ConcatAll(Encounter_B2W2_Regular, Encounter_DreamRadar);
#endregion
#region Trade Tables

View file

@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using static PKHeX.Core.EncounterUtil;
using static PKHeX.Core.EncounterUtil;
namespace PKHeX.Core
{
@ -94,6 +92,19 @@ namespace PKHeX.Core
new EncounterStatic6 { Species = 146, Level = 70, Location = 146, Ability = 1, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Moltres
};
private static readonly EncounterStatic6 CosplayPikachu = new EncounterStatic6
{
Location = 178, // Or 180, 186, 194
Species = 025,
Level = 20,
Gender = 1,
Ability = 4,
FlawlessIVCount = 3,
Contest = new[] {70, 70, 70, 70, 70, 0},
Gift = true,
Shiny = Shiny.Never
};
private static readonly EncounterStatic6[] Encounter_AO_Regular =
{
// Starters @ Route 101
@ -196,26 +207,25 @@ namespace PKHeX.Core
new EncounterStatic6 { Species = 333, Level = 40, Location = 348 }, // Swablu
new EncounterStatic6 { Species = 425, Level = 45, Location = 348 }, // Drifloon
new EncounterStatic6 { Species = 628, Level = 45, Location = 348 }, // Braviary
CosplayPikachu,
PermuteCosplay(1),
PermuteCosplay(2),
PermuteCosplay(3),
PermuteCosplay(4),
PermuteCosplay(5),
PermuteCosplay(6),
};
private static readonly EncounterStatic[] Encounter_AO = ArrayUtil.ConcatAll(Encounter_AO_Regular, PermuteCosplayPikachu().ToArray());
private static IEnumerable<EncounterStatic> PermuteCosplayPikachu()
private static EncounterStatic6 PermuteCosplay(int form)
{
var CosplayPikachu = new EncounterStatic6
{
Species = 25, Level = 20, Gender = 1, Ability = 4, FlawlessIVCount = 3,
Contest = new[] { 70, 70, 70, 70, 70, 0 }, Gift = true, Shiny = Shiny.Never
};
foreach (int loc in new[] { 178, 180, 186, 194 })
{
for (int f = 1; f <= 6; f++)
{
var pk = CosplayPikachu.Clone(loc); pk.Form = f;
yield return pk;
}
}
var clone = (EncounterStatic6)CosplayPikachu.Clone();
clone.Form = form;
return clone;
}
private static readonly EncounterStatic[] Encounter_AO = Encounter_AO_Regular;
#endregion
#region Trade Tables
internal static readonly EncounterTrade[] TradeGift_XY =

View file

@ -51,8 +51,6 @@
{
if (EggEncounter)
return true;
if (Location == 0)
return true;
if (pkm.Format == 4)
return Location == pkm.Met_Location;
return true; // transfer location verified later

View file

@ -1,4 +1,6 @@
namespace PKHeX.Core
using System.Linq;
namespace PKHeX.Core
{
public class EncounterStatic5 : EncounterStatic
{
@ -13,5 +15,47 @@
return true;
return false;
}
protected sealed override bool IsMatchLocation(PKM pk)
{
if (!Roaming)
return base.IsMatchLocation(pk);
return Roaming_MetLocation_BW.Contains(pk.Met_Location);
}
private static readonly int[] Roaming_MetLocation_BW =
{
25,26,27,28, // Route 12, 13, 14, 15 Night latter half
15,16,31, // Route 2, 3, 18 Morning
17,18,29, // Route 4, 5, 16 Daytime
19,20,21, // Route 6, 7, 8 Evening
22,23,24, // Route 9, 10, 11 Night former half
};
}
/// <summary>
/// Generation 5 Dream Radar gift encounters
/// </summary>
public sealed class EncounterStatic5DR : EncounterStatic5
{
public EncounterStatic5DR(int species, int form, int abilityIndex = 4)
{
Species = species;
Form = form;
Ability = abilityIndex;
Location = 30015;
Gift = true;
Ball = 25;
Level = 5; // to 40
}
protected override bool IsMatchLevel(PKM pkm, DexLevel evo)
{
// Level from 5->40 depends on the number of badges
var met = pkm.Met_Level;
if (met % 5 != 0)
return false;
return (uint) (met - 5) <= 35; // 5 <= x <= 40
}
}
}

View file

@ -13,5 +13,18 @@ namespace PKHeX.Core
public int CNT_Smart { get; set; }
public int CNT_Tough { get; set; }
public int CNT_Sheen { get; set; }
protected override bool IsMatchLocation(PKM pkm)
{
if (base.IsMatchLocation(pkm))
return true;
if (Species != (int) Core.Species.Pikachu)
return false;
// Cosplay Pikachu is given from multiple locations
var loc = pkm.Met_Location;
return loc == 180 || loc == 186 || loc == 194;
}
}
}

View file

@ -1,4 +1,7 @@
namespace PKHeX.Core
using System;
using System.Linq;
namespace PKHeX.Core
{
public sealed class EncounterStaticTyped : EncounterStatic4
{
@ -8,5 +11,90 @@
/// <see cref="PK4.EncounterType"/> values permitted for the encounter.
/// </summary>
public EncounterType TypeEncounter { get; internal set; } = EncounterType.None;
protected override bool IsMatchLocation(PKM pkm)
{
if (!Roaming)
return base.IsMatchLocation(pkm);
if (!(pkm is PK4 pk4))
return true;
var locs = GetRoamLocations(Species, pk4.EncounterType);
return locs.Contains(pkm.Met_Location);
}
private int[] GetRoamLocations(int species, int type)
{
switch (species)
{
case 481: case 488: case 144: case 145: case 146:
return 1 << type == (int)EncounterType.TallGrass
? Roaming_MetLocation_DPPt_Grass
: Roaming_MetLocation_DPPt_Surf;
case 243: case 244:
return 1 << type == (int)EncounterType.TallGrass
? Roaming_MetLocation_HGSS_Johto_Grass
: Roaming_MetLocation_HGSS_Johto_Surf;
case 380: case 381:
return 1 << type == (int)EncounterType.TallGrass
? Roaming_MetLocation_HGSS_Kanto_Grass
: Roaming_MetLocation_HGSS_Kanto_Surf;
default: throw new IndexOutOfRangeException(nameof(species));
}
}
private static readonly int[] Roaming_MetLocation_DPPt_Grass =
{
// Routes 201-218, 221-222 can be encountered in grass
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 36, 37,
47, // Valley Windworks
49, // Fuego Ironworks
};
private static readonly int[] Roaming_MetLocation_DPPt_Surf =
{
// Routes 203-205, 208-210, 212-214, 218-222 can be encountered in water
18, 19, 20, 23, 24, 25, 27, 28, 29, 33,
34, 35, 36, 37,
47, // Valley Windworks
49, // Fuego Ironworks
};
// Grass 29-39, 42-46, 47, 48
// Surf 30-32 34-35, 40-45, 47
// Route 45 inaccessible surf
private static readonly int[] Roaming_MetLocation_HGSS_Johto_Grass =
{
// Routes 29-48 can be encountered in grass
// Won't go to routes 40,41,47,48
177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
187, 190, 191, 192, 193, 194,
};
private static readonly int[] Roaming_MetLocation_HGSS_Johto_Surf =
{
// Routes 30-32,34-35,40-45 and 47 can be encountered in water
// Won't go to routes 40,41,47,48
178, 179, 180, 182, 183, 190, 191, 192, 193
};
private static readonly int[] Roaming_MetLocation_HGSS_Kanto_Grass =
{
// Route 01-18,21,22,24,26 and 28 can be encountered in grass
// Won't go to route 23 25 27
149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166,
169, 170, 172, 174, 176,
};
private static readonly int[] Roaming_MetLocation_HGSS_Kanto_Surf =
{
// Route 4,6,9,10,12,13,19-22,24,26 and 28 can be encountered in water
// Won't go to route 23 25 27
152, 154, 157, 158, 160, 161, 167, 168, 169, 170,
172, 174, 176,
};
}
}

View file

@ -31,7 +31,7 @@ namespace PKHeX.Core
public int TID { get; set; }
public int SID { get; set; }
public int OTGender { get; set; } = -1;
public GameVersion Version { get; set; }
public GameVersion Version { get; set; } = GameVersion.Any;
public IReadOnlyList<int> IVs { get; set; } = Array.Empty<int>();
public int FlawlessIVCount { get; set; }