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"/>
|
2021-12-09 09:08:46 +00:00
|
|
|
|
public sealed record EncounterStatic7(GameVersion Version) : EncounterStatic(Version), 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);
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (!EggEncounter)
|
2022-05-31 04:43:52 +00:00
|
|
|
|
return base.IsMatchEggLocation(pkm);
|
2021-05-21 20:57:07 +00:00
|
|
|
|
|
2022-05-31 04:43:52 +00:00
|
|
|
|
var eggloc = pkm.Egg_Location;
|
2021-05-21 20:57:07 +00:00
|
|
|
|
if (!pkm.IsEgg) // hatched
|
|
|
|
|
return eggloc == EggLocation || eggloc == Locations.LinkTrade6;
|
|
|
|
|
|
|
|
|
|
// Unhatched:
|
|
|
|
|
if (eggloc != EggLocation)
|
|
|
|
|
return false;
|
2021-10-14 03:05:19 +00:00
|
|
|
|
if (pkm.Met_Location is not (0 or Locations.LinkTrade6))
|
2021-05-21 20:57:07 +00:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-08 01:29:36 +00:00
|
|
|
|
protected override bool IsMatchForm(PKM pkm, EvoCriteria evo)
|
2020-08-21 23:35:49 +00:00
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 07:25:47 +00:00
|
|
|
|
internal static EncounterStatic7 GetVC1(int species, byte 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
|
2022-01-09 06:34:04 +00:00
|
|
|
|
Ability = Legal.TransferSpeciesDefaultAbilityGen1(species) ? AbilityPermission.OnlyFirst : AbilityPermission.OnlyHidden, // 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,
|
2022-03-01 06:46:59 +00:00
|
|
|
|
FlawlessIVCount = mew ? (byte)5 : (byte)3,
|
2020-09-05 19:11:43 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 07:25:47 +00:00
|
|
|
|
internal static EncounterStatic7 GetVC2(int species, byte 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
|
2022-01-09 06:34:04 +00:00
|
|
|
|
Ability = Legal.TransferSpeciesDefaultAbilityGen2(species) ? AbilityPermission.OnlyFirst : AbilityPermission.OnlyHidden, // 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,
|
2022-03-01 06:46:59 +00:00
|
|
|
|
FlawlessIVCount = fateful ? (byte)5 : (byte)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
|
|
|
|
}
|