2022-06-26 06:08:28 +00:00
|
|
|
using System;
|
2020-01-19 00:31:24 +00:00
|
|
|
using System.Collections.Generic;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Static Encounter Data
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// Static Encounters are fixed position encounters with properties that are not subject to Wild Encounter conditions.
|
|
|
|
/// </remarks>
|
|
|
|
public abstract record EncounterStatic(GameVersion Version) : IEncounterable, IMoveset, IEncounterMatch
|
2016-11-08 16:43:57 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
public int Species { get; init; }
|
|
|
|
public int Form { get; init; }
|
|
|
|
public virtual byte Level { get; init; }
|
|
|
|
public virtual byte LevelMin => Level;
|
|
|
|
public virtual byte LevelMax => Level;
|
|
|
|
public abstract int Generation { get; }
|
Refactoring: Move Source (Legality) (#3560)
Rewrites a good amount of legality APIs pertaining to:
* Legal moves that can be learned
* Evolution chains & cross-generation paths
* Memory validation with forgotten moves
In generation 8, there are 3 separate contexts an entity can exist in: SW/SH, BD/SP, and LA. Not every entity can cross between them, and not every entity from generation 7 can exist in generation 8 (Gogoat, etc). By creating class models representing the restrictions to cross each boundary, we are able to better track and validate data.
The old implementation of validating moves was greedy: it would iterate for all generations and evolutions, and build a full list of every move that can be learned, storing it on the heap. Now, we check one game group at a time to see if the entity can learn a move that hasn't yet been validated. End result is an algorithm that requires 0 allocation, and a smaller/quicker search space.
The old implementation of storing move parses was inefficient; for each move that was parsed, a new object is created and adjusted depending on the parse. Now, move parse results are `struct` and store the move parse contiguously in memory. End result is faster parsing and 0 memory allocation.
* `PersonalTable` objects have been improved with new API methods to check if a species+form can exist in the game.
* `IEncounterTemplate` objects have been improved to indicate the `EntityContext` they originate in (similar to `Generation`).
* Some APIs have been extended to accept `Span<T>` instead of Array/IEnumerable
2022-08-03 23:15:27 +00:00
|
|
|
public abstract EntityContext Context { get; }
|
2020-09-13 21:40:10 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public virtual int Location { get; init; }
|
|
|
|
public AbilityPermission Ability { get; init; }
|
|
|
|
public Shiny Shiny { get; init; }
|
|
|
|
public Nature Nature { get; init; } = Nature.Random;
|
|
|
|
public sbyte Gender { get; init; } = -1;
|
2022-03-01 06:46:59 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public ushort HeldItem { get; init; }
|
|
|
|
public bool Gift { get; init; }
|
|
|
|
public bool Fateful { get; init; }
|
2022-03-01 06:46:59 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public byte EggCycles { get; init; }
|
|
|
|
public byte FlawlessIVCount { get; init; }
|
|
|
|
public byte Ball { get; init; } = 4; // Only checked when is Gift
|
2022-03-01 06:46:59 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int EggLocation { get; init; }
|
2020-09-13 21:40:10 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public Ball FixedBall => Gift ? (Ball)Ball : Core.Ball.None;
|
2021-08-24 21:03:20 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public IReadOnlyList<int> Moves { get; init; } = Array.Empty<int>();
|
|
|
|
public IReadOnlyList<int> IVs { get; init; } = Array.Empty<int>();
|
2018-03-24 17:36:48 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public virtual bool EggEncounter => EggLocation != 0;
|
2017-03-20 12:35:12 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private const string _name = "Static Encounter";
|
|
|
|
public string Name => _name;
|
|
|
|
public string LongName => $"{_name} ({Version})";
|
|
|
|
public bool IsShiny => Shiny.IsShiny();
|
2018-03-29 03:38:07 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool IsRandomUnspecificForm => Form >= FormDynamic;
|
|
|
|
private const int FormDynamic = FormVivillon;
|
|
|
|
internal const int FormVivillon = 30;
|
|
|
|
//protected const int FormRandom = 31;
|
2021-08-03 03:45:52 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected virtual PKM GetBlank(ITrainerInfo tr) => EntityBlank.GetBlank(Generation, Version);
|
2021-02-03 06:14:33 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public PKM ConvertToPKM(ITrainerInfo tr) => ConvertToPKM(tr, EncounterCriteria.Unrestricted);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public PKM ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
|
|
|
|
{
|
|
|
|
var pk = GetBlank(tr);
|
|
|
|
tr.ApplyTo(pk);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
ApplyDetails(tr, criteria, pk);
|
|
|
|
return pk;
|
|
|
|
}
|
2020-09-13 21:40:10 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected virtual void ApplyDetails(ITrainerInfo tr, EncounterCriteria criteria, PKM pk)
|
|
|
|
{
|
|
|
|
pk.EncryptionConstant = Util.Rand32();
|
|
|
|
pk.Species = Species;
|
|
|
|
pk.Form = Form;
|
2018-04-29 16:31:13 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var version = this.GetCompatibleVersion((GameVersion)tr.Game);
|
|
|
|
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)tr.Language, version);
|
|
|
|
int level = GetMinimalLevel();
|
2022-02-05 01:35:15 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.Version = (int)version;
|
|
|
|
pk.Language = lang = GetEdgeCaseLanguage(pk, lang);
|
|
|
|
pk.Nickname = SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.CurrentLevel = level;
|
|
|
|
ApplyDetailsBall(pk);
|
|
|
|
pk.HeldItem = HeldItem;
|
|
|
|
pk.OT_Friendship = pk.PersonalInfo.BaseFriendship;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var today = DateTime.Today;
|
|
|
|
SetMetData(pk, level, today);
|
|
|
|
if (EggEncounter)
|
|
|
|
SetEggMetData(pk, tr, today);
|
2019-02-09 19:37:20 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
SetPINGA(pk, criteria);
|
|
|
|
SetEncounterMoves(pk, version, level);
|
2019-02-09 19:37:20 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (Fateful)
|
|
|
|
pk.FatefulEncounter = true;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (pk.Format < 6)
|
|
|
|
return;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (this is IRelearn relearn)
|
|
|
|
pk.SetRelearnMoves(relearn.Relearn);
|
|
|
|
|
|
|
|
tr.ApplyHandlingTrainerInfo(pk);
|
2018-05-10 00:50:56 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (pk is IScaledSize { HeightScalar: 0, WeightScalar: 0 } s)
|
2018-05-08 05:12:12 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
s.HeightScalar = PokeSizeUtil.GetRandomScalar();
|
|
|
|
s.WeightScalar = PokeSizeUtil.GetRandomScalar();
|
2018-05-08 05:12:12 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
if (this is IGigantamax g && pk is PK8 pg)
|
|
|
|
pg.CanGigantamax = g.CanGigantamax;
|
|
|
|
if (this is IDynamaxLevel d && pk is PK8 pd)
|
|
|
|
pd.DynamaxLevel = d.DynamaxLevel;
|
|
|
|
}
|
2018-05-08 05:12:12 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected virtual void ApplyDetailsBall(PKM pk) => pk.Ball = Ball;
|
|
|
|
|
|
|
|
protected virtual int GetMinimalLevel() => LevelMin;
|
|
|
|
|
|
|
|
protected virtual void SetPINGA(PKM pk, EncounterCriteria criteria)
|
|
|
|
{
|
|
|
|
var pi = pk.PersonalInfo;
|
|
|
|
int gender = criteria.GetGender(Gender, pi);
|
|
|
|
int nature = (int)criteria.GetNature(Nature);
|
|
|
|
int ability = criteria.GetAbilityFromNumber(Ability);
|
|
|
|
|
|
|
|
var pidtype = GetPIDType();
|
|
|
|
PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, ability, gender, pidtype);
|
|
|
|
SetIVs(pk);
|
|
|
|
pk.StatNature = pk.Nature;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SetEggMetData(PKM pk, ITrainerInfo tr, DateTime today)
|
|
|
|
{
|
|
|
|
pk.Met_Location = Math.Max(0, EncounterSuggestion.GetSuggestedEggMetLocation(pk));
|
|
|
|
pk.Met_Level = EncounterSuggestion.GetSuggestedEncounterEggMetLevel(pk);
|
|
|
|
|
|
|
|
if (Generation >= 4)
|
2018-04-29 16:31:13 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
bool traded = (int)Version == tr.Game;
|
|
|
|
pk.Egg_Location = EncounterSuggestion.GetSuggestedEncounterEggLocationEgg(Generation, Version, traded);
|
|
|
|
pk.EggMetDate = today;
|
2018-04-29 16:31:13 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.Egg_Location = EggLocation;
|
|
|
|
pk.EggMetDate = today;
|
|
|
|
}
|
2018-12-27 09:00:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected virtual void SetMetData(PKM pk, int level, DateTime today)
|
|
|
|
{
|
|
|
|
if (pk.Format <= 2)
|
|
|
|
return;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.Met_Location = Location;
|
|
|
|
pk.Met_Level = level;
|
|
|
|
if (pk.Format >= 4)
|
|
|
|
pk.MetDate = today;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected virtual void SetEncounterMoves(PKM pk, GameVersion version, int level)
|
|
|
|
{
|
|
|
|
var moves = Moves.Count > 0 ? (int[])Moves : MoveLevelUp.GetEncounterMoves(pk, level, version);
|
|
|
|
pk.SetMoves(moves);
|
|
|
|
pk.SetMaximumPPCurrent(moves);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
protected void SetIVs(PKM pk)
|
|
|
|
{
|
|
|
|
if (IVs.Count != 0)
|
2022-06-26 06:08:28 +00:00
|
|
|
pk.SetRandomIVsTemplate((int[])IVs, FlawlessIVCount);
|
2022-06-18 18:04:24 +00:00
|
|
|
else if (FlawlessIVCount > 0)
|
2022-06-26 06:08:28 +00:00
|
|
|
pk.SetRandomIVs(minFlawless: FlawlessIVCount);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private int GetEdgeCaseLanguage(PKM pk, int lang)
|
|
|
|
{
|
|
|
|
switch (this)
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
// Cannot trade between languages
|
|
|
|
case IFixedGBLanguage e:
|
|
|
|
return e.Language == EncounterGBLanguage.Japanese ? 1 : 2;
|
|
|
|
|
|
|
|
// E-Reader was only available to Japanese games.
|
|
|
|
case EncounterStaticShadow {EReader: true}:
|
|
|
|
// Old Sea Map was only distributed to Japanese games.
|
|
|
|
case EncounterStatic3 when Species == (int)Core.Species.Mew:
|
|
|
|
pk.OT_Name = "ゲーフリ";
|
|
|
|
return (int)LanguageID.Japanese;
|
|
|
|
|
|
|
|
// Deoxys for Emerald was not available for Japanese games.
|
|
|
|
case EncounterStatic3 when Species == (int)Core.Species.Deoxys && Version == GameVersion.E && lang == 1:
|
|
|
|
pk.OT_Name = "GF";
|
|
|
|
return (int)LanguageID.English;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return lang;
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2018-12-27 09:00:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private PIDType GetPIDType()
|
|
|
|
{
|
|
|
|
switch (Generation)
|
2022-05-31 04:43:52 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
case 3 when this is EncounterStatic3 {Roaming: true, Version: not GameVersion.E}: // Roamer IV glitch was fixed in Emerald
|
|
|
|
return PIDType.Method_1_Roamer;
|
|
|
|
case 4 when Shiny == Shiny.Always: // Lake of Rage Gyarados
|
|
|
|
return PIDType.ChainShiny;
|
|
|
|
case 4 when Species == (int)Core.Species.Pichu: // Spiky Eared Pichu
|
|
|
|
case 4 when Location == Locations.PokeWalker4: // Pokéwalker
|
|
|
|
return PIDType.Pokewalker;
|
|
|
|
case 5 when Shiny == Shiny.Always:
|
|
|
|
return PIDType.G5MGShiny;
|
|
|
|
|
|
|
|
default: return PIDType.None;
|
2022-05-31 04:43:52 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2018-12-27 09:00:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public virtual bool IsMatchExact(PKM pk, EvoCriteria evo)
|
|
|
|
{
|
|
|
|
if (Nature != Nature.Random && pk.Nature != (int) Nature)
|
|
|
|
return false;
|
2018-12-27 09:00:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (!IsMatchEggLocation(pk))
|
|
|
|
return false;
|
|
|
|
if (!IsMatchLocation(pk))
|
|
|
|
return false;
|
|
|
|
if (!IsMatchLevel(pk, evo))
|
|
|
|
return false;
|
|
|
|
if (!IsMatchGender(pk))
|
|
|
|
return false;
|
|
|
|
if (!IsMatchForm(pk, evo))
|
|
|
|
return false;
|
|
|
|
if (!IsMatchIVs(pk))
|
|
|
|
return false;
|
2018-12-27 09:00:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (this is IContestStats es && pk is IContestStats s && s.IsContestBelow(es))
|
2019-11-16 01:34:18 +00:00
|
|
|
return false;
|
2018-12-27 09:00:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Defer to EC/PID check
|
|
|
|
// if (e.Shiny != null && e.Shiny != pk.IsShiny)
|
|
|
|
// continue;
|
2019-11-17 23:50:41 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Defer ball check to later
|
|
|
|
// if (e.Gift && pk.Ball != 4) // PokéBall
|
|
|
|
// continue;
|
2019-11-22 04:02:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private bool IsMatchIVs(PKM pk)
|
|
|
|
{
|
|
|
|
if (IVs.Count == 0)
|
|
|
|
return true; // nothing to check, IVs are random
|
|
|
|
if (Generation <= 2 && pk.Format > 2)
|
|
|
|
return true; // IVs are regenerated on VC transfer upward
|
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
return Legal.GetIsFixedIVSequenceValidSkipRand((int[])IVs, pk);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual bool IsMatchForm(PKM pk, EvoCriteria evo)
|
|
|
|
{
|
|
|
|
if (IsRandomUnspecificForm)
|
|
|
|
return true;
|
|
|
|
return Form == evo.Form || FormInfo.IsFormChangeable(Species, Form, pk.Form, pk.Format);
|
|
|
|
}
|
|
|
|
|
|
|
|
// override me if the encounter type has any eggs
|
|
|
|
protected virtual bool IsMatchEggLocation(PKM pk)
|
|
|
|
{
|
|
|
|
var expect = pk is PB8 ? Locations.Default8bNone : 0;
|
|
|
|
return pk.Egg_Location == expect;
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool IsMatchGender(PKM pk)
|
|
|
|
{
|
|
|
|
if (Gender == -1 || Gender == pk.Gender)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (Species == (int) Core.Species.Azurill && Generation == 4 && Location == 233 && pk.Gender == 0)
|
|
|
|
return EntityGender.GetFromPIDAndRatio(pk.PID, 0xBF) == 1;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual bool IsMatchLocation(PKM pk)
|
|
|
|
{
|
|
|
|
if (EggEncounter)
|
|
|
|
return true;
|
|
|
|
if (Location == 0)
|
|
|
|
return true;
|
|
|
|
if (!pk.HasOriginalMetLocation)
|
|
|
|
return true;
|
|
|
|
return Location == pk.Met_Location;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual bool IsMatchLevel(PKM pk, EvoCriteria evo)
|
|
|
|
{
|
|
|
|
return pk.Met_Level == Level;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual EncounterMatchRating GetMatchRating(PKM pk)
|
|
|
|
{
|
|
|
|
if (IsMatchPartial(pk))
|
|
|
|
return EncounterMatchRating.PartialMatch;
|
|
|
|
return IsMatchDeferred(pk);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Checks if the provided <see cref="pk"/> might not be the best match, or even a bad match due to minor reasons.
|
|
|
|
/// </summary>
|
|
|
|
protected virtual EncounterMatchRating IsMatchDeferred(PKM pk) => EncounterMatchRating.Match;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Checks if the provided <see cref="pk"/> is not an exact match due to minor reasons.
|
|
|
|
/// </summary>
|
|
|
|
protected virtual bool IsMatchPartial(PKM pk)
|
|
|
|
{
|
|
|
|
if (pk.Format >= 5 && pk.AbilityNumber == 4 && this.IsPartialMatchHidden(pk.Species, Species))
|
|
|
|
return true;
|
|
|
|
return pk.FatefulEncounter != Fateful;
|
2017-04-23 16:18:42 +00:00
|
|
|
}
|
2016-11-08 16:43:57 +00:00
|
|
|
}
|