2018-03-31 07:43:41 +00:00
|
|
|
|
using System;
|
2020-12-29 06:22:52 +00:00
|
|
|
|
using static PKHeX.Core.Species;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Wild Encounter Slot data
|
|
|
|
|
/// </summary>
|
2020-11-27 19:51:02 +00:00
|
|
|
|
/// <remarks>Wild encounter slots are found as random encounters in-game.</remarks>
|
2022-03-07 07:25:47 +00:00
|
|
|
|
public abstract record EncounterSlot(EncounterArea Area, int Species, int Form, byte LevelMin, byte LevelMax) : IEncounterable, IEncounterMatch
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
public abstract int Generation { get; }
|
2020-03-20 20:33:15 +00:00
|
|
|
|
public bool EggEncounter => false;
|
2021-05-18 17:36:45 +00:00
|
|
|
|
public virtual bool IsShiny => false;
|
2020-08-21 23:35:49 +00:00
|
|
|
|
|
2021-12-09 09:08:46 +00:00
|
|
|
|
protected readonly EncounterArea Area = Area;
|
2020-08-30 18:08:21 +00:00
|
|
|
|
public GameVersion Version => Area.Version;
|
2020-08-30 22:44:13 +00:00
|
|
|
|
public int Location => Area.Location;
|
|
|
|
|
public int EggLocation => 0;
|
2022-01-06 00:46:23 +00:00
|
|
|
|
public virtual Ball FixedBall => Ball.None;
|
|
|
|
|
public virtual Shiny Shiny => Shiny.Random;
|
2020-08-21 23:35:49 +00:00
|
|
|
|
|
2021-08-05 22:18:43 +00:00
|
|
|
|
public bool IsFixedLevel => LevelMin == LevelMax;
|
|
|
|
|
public bool IsRandomLevel => LevelMin != LevelMax;
|
2020-08-21 23:35:49 +00:00
|
|
|
|
|
|
|
|
|
private protected const string wild = "Wild Encounter";
|
|
|
|
|
public string Name => wild;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
|
Fix flute level amp direction
The inputs to "IsLevelWithinRange" are the highest value the
lowest-level can be, and the lowest value the highest level can be...
seems confusing (hence the original error).
If a slot is 6-7, with a wild encounter (flute), we can go +/-3 from
6-7, which is 3-10.
With an encounter of level 5, the inputs are: 5+3, and 5-3 (8, 2).
Since 8>lvlmin and 2<lvlhi, we can get a level 5 pkm from the slot
(using a negative flute yielding a -1 adjustment).
I could probably refactor it to be a 3-input signature (lvl, lvlneg,
lvlpos), and have it do LevelMin - lvlneg <= lvl && lvl <= LevelMax +
lvlpos
I should probably refactor these methods to do minLevel & maxLevel (so
baseSpecies.Level to CurrentLevel for pkm that lost their original met
data) but nothing needs the extra logic at this time.
2019-09-20 05:37:56 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets if the specified level inputs are within range of the <see cref="LevelMin"/> and <see cref="LevelMax"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="lvl">Single level</param>
|
|
|
|
|
/// <returns>True if within slot's range, false if impossible.</returns>
|
2019-09-13 06:20:52 +00:00
|
|
|
|
public bool IsLevelWithinRange(int lvl) => LevelMin <= lvl && lvl <= LevelMax;
|
Fix flute level amp direction
The inputs to "IsLevelWithinRange" are the highest value the
lowest-level can be, and the lowest value the highest level can be...
seems confusing (hence the original error).
If a slot is 6-7, with a wild encounter (flute), we can go +/-3 from
6-7, which is 3-10.
With an encounter of level 5, the inputs are: 5+3, and 5-3 (8, 2).
Since 8>lvlmin and 2<lvlhi, we can get a level 5 pkm from the slot
(using a negative flute yielding a -1 adjustment).
I could probably refactor it to be a 3-input signature (lvl, lvlneg,
lvlpos), and have it do LevelMin - lvlneg <= lvl && lvl <= LevelMax +
lvlpos
I should probably refactor these methods to do minLevel & maxLevel (so
baseSpecies.Level to CurrentLevel for pkm that lost their original met
data) but nothing needs the extra logic at this time.
2019-09-20 05:37:56 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets if the specified level inputs are within range of the <see cref="LevelMin"/> and <see cref="LevelMax"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="min">Highest value the low end of levels can be</param>
|
|
|
|
|
/// <param name="max">Lowest value the high end of levels can be</param>
|
|
|
|
|
/// <returns>True if within slot's range, false if impossible.</returns>
|
2022-03-07 07:25:47 +00:00
|
|
|
|
public bool IsLevelWithinRange(byte min, byte max) => LevelMin <= max && min <= LevelMax;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
|
2019-09-20 05:54:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets if the specified level inputs are within range of the <see cref="LevelMin"/> and <see cref="LevelMax"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="lvl">Single level</param>
|
|
|
|
|
/// <param name="minDecrease">Highest value the low end of levels can be</param>
|
|
|
|
|
/// <param name="maxIncrease">Lowest value the high end of levels can be</param>
|
|
|
|
|
/// <returns>True if within slot's range, false if impossible.</returns>
|
|
|
|
|
public bool IsLevelWithinRange(int lvl, int minDecrease, int maxIncrease) => LevelMin - minDecrease <= lvl && lvl <= LevelMax + maxIncrease;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets if the specified level inputs are within range of the <see cref="LevelMin"/> and <see cref="LevelMax"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="min">Lowest level allowed</param>
|
|
|
|
|
/// <param name="max">Highest level allowed</param>
|
|
|
|
|
/// <param name="minDecrease">Highest value the low end of levels can be</param>
|
|
|
|
|
/// <param name="maxIncrease">Lowest value the high end of levels can be</param>
|
|
|
|
|
/// <returns>True if within slot's range, false if impossible.</returns>
|
2022-03-07 07:25:47 +00:00
|
|
|
|
public bool IsLevelWithinRange(byte min, byte max, int minDecrease, int maxIncrease) => LevelMin - minDecrease <= max && min <= LevelMax + maxIncrease;
|
2019-03-18 05:19:37 +00:00
|
|
|
|
|
2019-11-28 20:56:26 +00:00
|
|
|
|
public virtual string LongName
|
2017-02-15 06:06:15 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2021-07-30 21:05:23 +00:00
|
|
|
|
if (Area.Type == SlotType.Any)
|
2017-02-15 06:06:15 +00:00
|
|
|
|
return wild;
|
2021-07-30 21:05:23 +00:00
|
|
|
|
return $"{wild} {Area.Type.ToString().Replace('_', ' ')}";
|
2017-02-15 06:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-29 03:38:07 +00:00
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
public PKM ConvertToPKM(ITrainerInfo sav) => ConvertToPKM(sav, EncounterCriteria.Unrestricted);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
public PKM ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria)
|
2018-03-31 07:43:41 +00:00
|
|
|
|
{
|
2022-04-09 08:39:34 +00:00
|
|
|
|
var pk = EntityBlank.GetBlank(Generation, Version);
|
2020-06-17 02:46:22 +00:00
|
|
|
|
sav.ApplyTo(pk);
|
2020-07-19 18:32:40 +00:00
|
|
|
|
ApplyDetails(sav, criteria, pk);
|
|
|
|
|
return pk;
|
|
|
|
|
}
|
2018-04-01 03:37:36 +00:00
|
|
|
|
|
2020-07-19 18:32:40 +00:00
|
|
|
|
protected virtual void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)
|
|
|
|
|
{
|
|
|
|
|
var version = this.GetCompatibleVersion((GameVersion) sav.Game);
|
2021-01-31 18:19:12 +00:00
|
|
|
|
int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID) sav.Language, version);
|
2020-07-19 18:32:40 +00:00
|
|
|
|
int level = LevelMin;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
pk.Species = Species;
|
2022-02-05 08:47:17 +00:00
|
|
|
|
pk.Form = GetWildForm(pk, Form, sav);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
pk.Language = lang;
|
|
|
|
|
pk.CurrentLevel = level;
|
2018-04-28 23:30:56 +00:00
|
|
|
|
pk.Version = (int)version;
|
2019-09-19 02:58:23 +00:00
|
|
|
|
pk.Nickname = SpeciesName.GetSpeciesNameGeneration(Species, lang, Generation);
|
2020-08-30 17:23:22 +00:00
|
|
|
|
|
2022-02-05 01:35:15 +00:00
|
|
|
|
ApplyDetailsBall(pk);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
pk.Language = lang;
|
2021-05-05 15:43:32 +00:00
|
|
|
|
pk.OT_Friendship = pk.PersonalInfo.BaseFriendship;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
SetMetData(pk, level, Location);
|
2019-02-09 19:37:20 +00:00
|
|
|
|
SetPINGA(pk, criteria);
|
|
|
|
|
SetEncounterMoves(pk, version, level);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
SetFormatSpecificData(pk);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
|
|
|
|
if (pk.Format < 6)
|
2020-07-19 18:32:40 +00:00
|
|
|
|
return;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
2020-06-17 02:46:22 +00:00
|
|
|
|
sav.ApplyHandlingTrainerInfo(pk);
|
2021-11-25 03:29:02 +00:00
|
|
|
|
if (pk is IScaledSize s)
|
|
|
|
|
{
|
|
|
|
|
s.HeightScalar = PokeSizeUtil.GetRandomScalar();
|
|
|
|
|
s.WeightScalar = PokeSizeUtil.GetRandomScalar();
|
|
|
|
|
}
|
2018-03-31 07:43:41 +00:00
|
|
|
|
}
|
2018-04-29 16:31:13 +00:00
|
|
|
|
|
2022-02-05 01:35:15 +00:00
|
|
|
|
protected virtual void ApplyDetailsBall(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
var ball = FixedBall;
|
|
|
|
|
pk.Ball = (int)(ball == Ball.None ? Ball.Poke : ball);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected virtual void SetEncounterMoves(PKM pk, GameVersion version, int level)
|
2019-02-09 19:37:20 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
var moves = MoveLevelUp.GetEncounterMoves(pk, level, version);
|
2020-01-19 00:46:38 +00:00
|
|
|
|
pk.SetMoves(moves);
|
2019-02-09 19:37:20 +00:00
|
|
|
|
pk.SetMaximumPPCurrent(moves);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected virtual void SetFormatSpecificData(PKM pk) { }
|
2018-12-30 06:24:34 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
protected virtual void SetPINGA(PKM pk, EncounterCriteria criteria)
|
2018-12-30 06:24:34 +00:00
|
|
|
|
{
|
2021-02-01 05:42:24 +00:00
|
|
|
|
var pi = pk.PersonalInfo;
|
|
|
|
|
int gender = criteria.GetGender(-1, pi);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
int nature = (int)criteria.GetNature(Nature.Random);
|
2021-03-24 00:05:15 +00:00
|
|
|
|
var ability = criteria.GetAbilityFromNumber(Ability);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
|
2020-12-29 06:22:52 +00:00
|
|
|
|
if (Generation == 3 && Species == (int)Unown)
|
2020-09-04 02:00:46 +00:00
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, ability, gender);
|
|
|
|
|
ability ^= 1; // some nature-forms cannot have a certain PID-ability set, so just flip it as Unown doesn't have dual abilities.
|
2020-12-11 04:42:30 +00:00
|
|
|
|
} while (pk.Form != Form);
|
2020-09-04 02:00:46 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, ability, gender);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
pk.Gender = gender;
|
2020-06-27 16:46:23 +00:00
|
|
|
|
pk.StatNature = nature;
|
2018-12-30 06:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetMetData(PKM pk, int level, int location)
|
|
|
|
|
{
|
|
|
|
|
if (pk.Format <= 2 && Version != GameVersion.C)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pk.Met_Location = location;
|
|
|
|
|
pk.Met_Level = level;
|
|
|
|
|
|
|
|
|
|
if (pk.Format >= 4)
|
|
|
|
|
pk.MetDate = DateTime.Today;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 05:41:52 +00:00
|
|
|
|
public bool IsRandomUnspecificForm => Form >= FormDynamic;
|
2020-11-27 19:51:02 +00:00
|
|
|
|
private const int FormDynamic = FormVivillon;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
protected internal const int FormVivillon = 30;
|
|
|
|
|
protected internal const int FormRandom = 31;
|
2020-11-27 19:51:02 +00:00
|
|
|
|
|
2020-12-11 04:42:30 +00:00
|
|
|
|
private static int GetWildForm(PKM pk, int form, ITrainerInfo sav)
|
2018-05-10 02:21:44 +00:00
|
|
|
|
{
|
2020-11-27 19:51:02 +00:00
|
|
|
|
if (form < FormDynamic) // specified form
|
2019-10-05 03:10:50 +00:00
|
|
|
|
return form;
|
2021-08-01 05:41:52 +00:00
|
|
|
|
|
2020-11-27 19:51:02 +00:00
|
|
|
|
if (form == FormRandom) // flagged as totally random
|
2021-08-01 05:41:52 +00:00
|
|
|
|
{
|
|
|
|
|
if (pk.Species == (int)Minior)
|
|
|
|
|
return 7 + Util.Rand.Next(7);
|
2020-12-11 04:42:30 +00:00
|
|
|
|
return Util.Rand.Next(pk.PersonalInfo.FormCount);
|
2021-08-01 05:41:52 +00:00
|
|
|
|
}
|
2019-09-10 07:21:51 +00:00
|
|
|
|
|
2020-12-29 06:22:52 +00:00
|
|
|
|
int species = pk.Species;
|
|
|
|
|
if (species is >= (int)Scatterbug and <= (int)Vivillon)
|
2020-07-31 20:53:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (sav is IRegionOrigin o)
|
2021-08-03 02:43:57 +00:00
|
|
|
|
return Vivillon3DS.GetPattern(o.Country, o.Region);
|
2020-07-31 20:53:42 +00:00
|
|
|
|
}
|
2018-05-10 02:21:44 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
public virtual string GetConditionString(out bool valid)
|
2018-04-29 16:31:13 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
valid = true;
|
|
|
|
|
return LegalityCheckStrings.LEncCondition;
|
2018-04-29 16:31:13 +00:00
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
public bool IsMatchExact(PKM pkm, DexLevel dl) => true; // Matched by Area
|
|
|
|
|
|
|
|
|
|
public virtual EncounterMatchRating GetMatchRating(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (IsDeferredWurmple(pkm))
|
|
|
|
|
return EncounterMatchRating.PartialMatch;
|
2021-01-31 21:05:36 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Format >= 5)
|
|
|
|
|
{
|
|
|
|
|
bool isHidden = pkm.AbilityNumber == 4;
|
2021-02-02 04:45:48 +00:00
|
|
|
|
if (isHidden && this.IsPartialMatchHidden(pkm.Species, Species))
|
2021-01-31 21:05:36 +00:00
|
|
|
|
return EncounterMatchRating.PartialMatch;
|
|
|
|
|
if (IsDeferredHiddenAbility(isHidden))
|
|
|
|
|
return EncounterMatchRating.Deferred;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
return EncounterMatchRating.Match;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual HiddenAbilityPermission IsHiddenAbilitySlot() => HiddenAbilityPermission.Never;
|
|
|
|
|
|
2022-01-09 06:34:04 +00:00
|
|
|
|
public AbilityPermission Ability => IsHiddenAbilitySlot() switch
|
2021-02-01 05:42:24 +00:00
|
|
|
|
{
|
2022-01-09 06:34:04 +00:00
|
|
|
|
HiddenAbilityPermission.Never => AbilityPermission.Any12,
|
|
|
|
|
HiddenAbilityPermission.Always => AbilityPermission.OnlyHidden,
|
|
|
|
|
_ => AbilityPermission.Any12H,
|
2021-02-01 05:42:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private bool IsDeferredWurmple(PKM pkm) => Species == (int)Wurmple && pkm.Species != (int)Wurmple && !WurmpleUtil.IsWurmpleEvoValid(pkm);
|
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
|
|
|
|
|
|
|
|
|
private bool IsDeferredHiddenAbility(bool IsHidden) => IsHiddenAbilitySlot() switch
|
|
|
|
|
{
|
|
|
|
|
HiddenAbilityPermission.Never => IsHidden,
|
|
|
|
|
HiddenAbilityPermission.Always => !IsHidden,
|
|
|
|
|
_ => false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected enum HiddenAbilityPermission
|
|
|
|
|
{
|
|
|
|
|
Always,
|
|
|
|
|
Never,
|
|
|
|
|
Possible,
|
|
|
|
|
}
|
2016-11-08 16:43:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|