2020-07-18 20:36:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
public class EncounterStatic2 : EncounterStatic
|
|
|
|
|
{
|
2020-09-07 20:51:13 +00:00
|
|
|
|
public sealed override int Generation => 2;
|
2020-07-18 20:36:30 +00:00
|
|
|
|
public sealed override int Level { get; set; }
|
|
|
|
|
|
2020-10-07 02:35:03 +00:00
|
|
|
|
public EncounterStatic2(int species, int level, GameVersion ver)
|
2020-07-18 20:36:30 +00:00
|
|
|
|
{
|
|
|
|
|
Species = species;
|
|
|
|
|
Level = level;
|
2020-10-07 02:35:03 +00:00
|
|
|
|
Version = ver;
|
2020-07-18 20:36:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected override bool IsMatchEggLocation(PKM pkm)
|
2020-07-18 20:36:30 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Format > 2)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
{
|
2020-10-07 22:28:58 +00:00
|
|
|
|
if (!EggEncounter)
|
|
|
|
|
return false;
|
2020-07-18 20:36:30 +00:00
|
|
|
|
if (pkm.Met_Location != 0 && pkm.Met_Level != 0)
|
|
|
|
|
return false;
|
|
|
|
|
if (pkm.OT_Friendship > EggCycles) // Dizzy Punch eggs start with below-normal hatch counters.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (pkm.Met_Level)
|
|
|
|
|
{
|
|
|
|
|
case 0 when pkm.Met_Location != 0:
|
|
|
|
|
return false;
|
|
|
|
|
case 1 when pkm.Met_Location == 0:
|
|
|
|
|
return false;
|
|
|
|
|
default:
|
|
|
|
|
if (pkm.Met_Location == 0 && pkm.Met_Level != 0)
|
|
|
|
|
return false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetMetData(PKM pk, int level, DateTime today)
|
|
|
|
|
{
|
2020-09-04 02:00:46 +00:00
|
|
|
|
if (Version != GameVersion.C)
|
|
|
|
|
return;
|
|
|
|
|
var pk2 = (PK2)pk;
|
|
|
|
|
pk2.Met_Location = Location;
|
|
|
|
|
pk2.Met_Level = level;
|
|
|
|
|
pk2.Met_TimeOfDay = EncounterTime.Any.RandomValidTime();
|
2020-07-18 20:36:30 +00:00
|
|
|
|
}
|
2020-08-21 23:35:49 +00:00
|
|
|
|
|
|
|
|
|
protected override bool IsMatchLevel(PKM pkm, DexLevel evo)
|
|
|
|
|
{
|
2020-10-03 01:08:40 +00:00
|
|
|
|
if (pkm is ICaughtData2 pk2 && pk2.CaughtData != 0)
|
2020-08-21 23:35:49 +00:00
|
|
|
|
return pkm.Met_Level == (EggEncounter ? 1 : Level);
|
|
|
|
|
|
|
|
|
|
return Level <= evo.Level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool IsMatchLocation(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (EggEncounter)
|
|
|
|
|
return true;
|
|
|
|
|
if (Location == 0)
|
|
|
|
|
return true;
|
2020-10-03 01:08:40 +00:00
|
|
|
|
if (pkm is ICaughtData2 pk2 && pk2.CaughtData != 0)
|
2020-08-21 23:35:49 +00:00
|
|
|
|
return Location == pkm.Met_Location;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-07-18 20:36:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed class EncounterStatic2Odd : EncounterStatic2
|
|
|
|
|
{
|
|
|
|
|
private const int Dizzy = 146;
|
|
|
|
|
private static readonly int[] _dizzy = { Dizzy };
|
|
|
|
|
|
2020-10-07 02:35:03 +00:00
|
|
|
|
public EncounterStatic2Odd(int species) : base(species, 5, GameVersion.C)
|
2020-07-18 20:36:30 +00:00
|
|
|
|
{
|
|
|
|
|
Moves = _dizzy;
|
|
|
|
|
EggLocation = 256;
|
|
|
|
|
EggCycles = 20;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
public override bool IsMatch(PKM pkm, DexLevel evo)
|
2020-07-18 20:36:30 +00:00
|
|
|
|
{
|
|
|
|
|
// Let it get picked up as regular EncounterEgg under other conditions.
|
|
|
|
|
if (pkm.Format > 2)
|
|
|
|
|
return false;
|
|
|
|
|
if (pkm.Move1 != Dizzy && pkm.Move2 != Dizzy && pkm.Move3 != Dizzy && pkm.Move4 != Dizzy)
|
|
|
|
|
return false;
|
|
|
|
|
if (pkm.IsEgg && pkm.EXP != 125)
|
|
|
|
|
return false;
|
2020-08-21 23:35:49 +00:00
|
|
|
|
return base.IsMatch(pkm, evo);
|
2020-07-18 20:36:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed class EncounterStatic2Roam : EncounterStatic2
|
|
|
|
|
{
|
|
|
|
|
private static readonly int[] Roaming_MetLocation_GSC_Grass =
|
|
|
|
|
{
|
|
|
|
|
// Routes 29, 30-31, 33, 34, 35, 36-37, 38-39, 42, 43, 44, 45-46 can be encountered in grass
|
|
|
|
|
2, 4, 5, 8, 11, 15, 18, 20, 21,
|
|
|
|
|
25, 26, 34, 37, 39, 43, 45,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override int Location => Roaming_MetLocation_GSC_Grass[0];
|
|
|
|
|
|
2020-10-07 02:35:03 +00:00
|
|
|
|
public EncounterStatic2Roam(int species, int level, GameVersion ver) : base(species, level, ver) { }
|
2020-07-18 20:36:30 +00:00
|
|
|
|
|
|
|
|
|
protected override bool IsMatchLocation(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (!pkm.HasOriginalMetLocation)
|
|
|
|
|
return true;
|
|
|
|
|
return Roaming_MetLocation_GSC_Grass.Contains(Location);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|