2020-10-24 18:16:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-02-15 00:00:43 +00:00
|
|
|
|
using static PKHeX.Core.OverworldCorrelation8Requirement;
|
2020-10-24 18:16:01 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 8 Static Encounter
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <inheritdoc cref="EncounterStatic"/>
|
|
|
|
|
public record EncounterStatic8(GameVersion Version) : EncounterStatic(Version), IDynamaxLevel, IGigantamax, IRelearn, IOverworldCorrelation8
|
2019-11-19 03:23:01 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public sealed override int Generation => 8;
|
|
|
|
|
public bool ScriptedNoMarks { get; init; }
|
|
|
|
|
public bool CanGigantamax { get; set; }
|
|
|
|
|
public byte DynamaxLevel { get; set; }
|
|
|
|
|
public IReadOnlyList<int> Relearn { get; init; } = Array.Empty<int>();
|
2020-08-30 23:10:24 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public AreaWeather8 Weather {get; init; } = AreaWeather8.Normal;
|
2021-01-16 17:31:21 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
protected override bool IsMatchLevel(PKM pk, EvoCriteria evo)
|
|
|
|
|
{
|
|
|
|
|
var met = pk.Met_Level;
|
|
|
|
|
var lvl = Level;
|
|
|
|
|
if (met == lvl)
|
|
|
|
|
return true;
|
|
|
|
|
if (lvl < EncounterArea8.BoostLevel && EncounterArea8.IsBoostedArea60(Location))
|
|
|
|
|
return met == EncounterArea8.BoostLevel;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
|
|
|
|
{
|
|
|
|
|
if (pk is PK8 d && d.DynamaxLevel < DynamaxLevel)
|
2019-11-19 03:23:01 +00:00
|
|
|
|
return false;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (pk.Met_Level < EncounterArea8.BoostLevel && Weather is AreaWeather8.Heavy_Fog && EncounterArea8.IsBoostedArea60Fog(Location))
|
|
|
|
|
return false;
|
|
|
|
|
return base.IsMatchExact(pk, evo);
|
|
|
|
|
}
|
2020-10-24 18:16:01 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
protected override void ApplyDetails(ITrainerInfo tr, EncounterCriteria criteria, PKM pk)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyDetails(tr, criteria, pk);
|
|
|
|
|
if (Weather is AreaWeather8.Heavy_Fog && EncounterArea8.IsBoostedArea60Fog(Location))
|
|
|
|
|
pk.CurrentLevel = pk.Met_Level = EncounterArea8.BoostLevel;
|
2021-02-14 18:20:35 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
var req = GetRequirement(pk);
|
|
|
|
|
if (req != MustHave)
|
2021-02-14 20:27:14 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
pk.SetRandomEC();
|
|
|
|
|
return;
|
2021-02-14 20:27:14 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
var shiny = Shiny == Shiny.Random ? Shiny.FixedValue : Shiny;
|
|
|
|
|
Overworld8RNG.ApplyDetails(pk, criteria, shiny, FlawlessIVCount);
|
|
|
|
|
}
|
2021-02-14 20:27:14 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public bool IsOverworldCorrelation
|
|
|
|
|
{
|
|
|
|
|
get
|
2021-02-14 18:20:35 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (Gift)
|
|
|
|
|
return false; // gifts can have any 128bit seed from overworld
|
|
|
|
|
if (ScriptedNoMarks)
|
|
|
|
|
return false; // scripted encounters don't act as saved spawned overworld encounters
|
|
|
|
|
return true;
|
2021-02-14 18:20:35 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
}
|
2021-02-14 18:20:35 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public OverworldCorrelation8Requirement GetRequirement(PKM pk) => IsOverworldCorrelation
|
|
|
|
|
? MustHave
|
|
|
|
|
: MustNotHave;
|
2021-02-14 23:14:45 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public bool IsOverworldCorrelationCorrect(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
return Overworld8RNG.ValidateOverworldEncounter(pk, Shiny == Shiny.Random ? Shiny.FixedValue : Shiny, FlawlessIVCount);
|
|
|
|
|
}
|
2021-02-14 23:14:45 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public override EncounterMatchRating GetMatchRating(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
var rating = base.GetMatchRating(pk);
|
|
|
|
|
if (rating != EncounterMatchRating.Match)
|
|
|
|
|
return rating;
|
2021-02-15 05:24:31 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
var req = GetRequirement(pk);
|
|
|
|
|
bool correlation = IsOverworldCorrelationCorrect(pk);
|
|
|
|
|
if ((req == MustHave) != correlation)
|
|
|
|
|
return EncounterMatchRating.DeferredErrors;
|
2021-02-15 05:24:31 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
// Only encounter slots can have these marks; defer for collisions.
|
|
|
|
|
if (pk.Species == (int) Core.Species.Shedinja)
|
|
|
|
|
{
|
|
|
|
|
// Loses Mark on evolution to Shedinja, but not affixed ribbon value.
|
|
|
|
|
return pk switch
|
2021-04-21 22:20:16 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
IRibbonSetMark8 {RibbonMarkCurry: true} => EncounterMatchRating.DeferredErrors,
|
|
|
|
|
PK8 {AffixedRibbon: (int) RibbonIndex.MarkCurry} => EncounterMatchRating.Deferred,
|
|
|
|
|
_ => EncounterMatchRating.Match,
|
|
|
|
|
};
|
2021-02-14 23:14:45 +00:00
|
|
|
|
}
|
2021-02-14 18:20:35 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (pk is IRibbonSetMark8 m && (m.RibbonMarkCurry || m.RibbonMarkFishing || m.HasWeatherMark()))
|
|
|
|
|
return EncounterMatchRating.DeferredErrors;
|
2021-02-15 00:00:43 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
return EncounterMatchRating.Match;
|
2021-02-15 00:00:43 +00:00
|
|
|
|
}
|
2020-10-24 18:16:01 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
|
|
public interface IOverworldCorrelation8
|
|
|
|
|
{
|
|
|
|
|
OverworldCorrelation8Requirement GetRequirement(PKM pk);
|
|
|
|
|
bool IsOverworldCorrelationCorrect(PKM pk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum OverworldCorrelation8Requirement
|
|
|
|
|
{
|
|
|
|
|
CanBeEither,
|
|
|
|
|
MustHave,
|
|
|
|
|
MustNotHave,
|
|
|
|
|
}
|