2020-08-21 23:35:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2020-11-27 19:51:02 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 7 Static Encounter
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <inheritdoc cref="EncounterStatic"/>
|
2020-12-24 04:40:59 +00:00
|
|
|
|
public sealed record EncounterStatic7 : EncounterStatic, IRelearn
|
2020-08-21 23:35:49 +00:00
|
|
|
|
{
|
2020-08-30 23:10:24 +00:00
|
|
|
|
public override int Generation => 7;
|
2020-12-22 07:37:07 +00:00
|
|
|
|
public IReadOnlyList<int> Relearn { get; init; } = Array.Empty<int>();
|
2020-08-21 23:35:49 +00:00
|
|
|
|
|
2021-04-17 20:24:57 +00:00
|
|
|
|
public bool IsTotem => FormInfo.IsTotemForm(Species, Form);
|
|
|
|
|
|
2021-01-04 00:49:49 +00:00
|
|
|
|
public EncounterStatic7(GameVersion game) : base(game) { }
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected override bool IsMatchLocation(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (EggLocation == Locations.Daycare5 && Relearn.Count == 0 && pkm.RelearnMove1 != 0) // Gift Eevee edge case
|
|
|
|
|
return false;
|
|
|
|
|
return base.IsMatchLocation(pkm);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-21 20:57:07 +00:00
|
|
|
|
protected override bool IsMatchEggLocation(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
var eggloc = pkm.Egg_Location;
|
|
|
|
|
if (!EggEncounter)
|
|
|
|
|
return eggloc == EggLocation;
|
|
|
|
|
|
|
|
|
|
if (!pkm.IsEgg) // hatched
|
|
|
|
|
return eggloc == EggLocation || eggloc == Locations.LinkTrade6;
|
|
|
|
|
|
|
|
|
|
// Unhatched:
|
|
|
|
|
if (eggloc != EggLocation)
|
|
|
|
|
return false;
|
|
|
|
|
if (pkm.Met_Location is not 0 or Locations.LinkTrade6)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected override bool IsMatchForm(PKM pkm, DexLevel evo)
|
|
|
|
|
{
|
2021-04-17 20:24:57 +00:00
|
|
|
|
if (IsTotem)
|
2020-08-21 23:35:49 +00:00
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var expectForm = pkm.Format == 7 ? Form : FormInfo.GetTotemBaseForm(Species, Form);
|
2020-08-21 23:35:49 +00:00
|
|
|
|
return expectForm == evo.Form;
|
|
|
|
|
}
|
2021-08-03 03:45:52 +00:00
|
|
|
|
return base.IsMatchForm(pkm, evo);
|
2020-08-21 23:35:49 +00:00
|
|
|
|
}
|
2020-09-05 19:11:43 +00:00
|
|
|
|
|
2020-09-13 21:40:10 +00:00
|
|
|
|
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyDetails(sav, criteria, pk);
|
|
|
|
|
if (Species == (int)Core.Species.Magearna && pk is IRibbonSetEvent4 e4)
|
|
|
|
|
e4.RibbonWishing = true;
|
2021-08-05 19:36:47 +00:00
|
|
|
|
if (Form == FormVivillon && pk is PK7 pk7)
|
|
|
|
|
pk.Form = Vivillon3DS.GetPattern(pk7.Country, pk7.Region);
|
2021-02-14 20:27:14 +00:00
|
|
|
|
pk.SetRandomEC();
|
2020-09-13 21:40:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-05 19:33:00 +00:00
|
|
|
|
internal static EncounterStatic7 GetVC1(int species, int metLevel)
|
2020-09-05 19:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
bool mew = species == (int)Core.Species.Mew;
|
2021-01-04 00:49:49 +00:00
|
|
|
|
return new EncounterStatic7(GameVersion.RBY)
|
2020-09-05 19:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
Species = species,
|
|
|
|
|
Gift = true, // Forces Poké Ball
|
2021-01-02 08:46:09 +00:00
|
|
|
|
Ability = Legal.TransferSpeciesDefaultAbilityGen1(species) ? 1 : 4, // Hidden by default, else first
|
2020-09-05 19:11:43 +00:00
|
|
|
|
Shiny = mew ? Shiny.Never : Shiny.Random,
|
|
|
|
|
Fateful = mew,
|
|
|
|
|
Location = Locations.Transfer1,
|
|
|
|
|
Level = metLevel,
|
|
|
|
|
FlawlessIVCount = mew ? 5 : 3,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-05 19:33:00 +00:00
|
|
|
|
internal static EncounterStatic7 GetVC2(int species, int metLevel)
|
2020-09-05 19:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
bool mew = species == (int)Core.Species.Mew;
|
|
|
|
|
bool fateful = mew || species == (int)Core.Species.Celebi;
|
2021-01-04 00:49:49 +00:00
|
|
|
|
return new EncounterStatic7(GameVersion.GSC)
|
2020-09-05 19:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
Species = species,
|
|
|
|
|
Gift = true, // Forces Poké Ball
|
2021-01-02 08:46:09 +00:00
|
|
|
|
Ability = Legal.TransferSpeciesDefaultAbilityGen2(species) ? 1 : 4, // Hidden by default, else first
|
2020-09-05 19:11:43 +00:00
|
|
|
|
Shiny = mew ? Shiny.Never : Shiny.Random,
|
|
|
|
|
Fateful = fateful,
|
|
|
|
|
Location = Locations.Transfer2,
|
|
|
|
|
Level = metLevel,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
FlawlessIVCount = fateful ? 5 : 3,
|
2020-09-05 19:11:43 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2020-08-21 23:35:49 +00:00
|
|
|
|
}
|
2020-09-05 19:11:43 +00:00
|
|
|
|
}
|