mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-11 21:22:41 +00:00
Partial match HA species without a HA possible
A captured metapod cannot have hidden ability via ability patch, but a captured caterpie evolved into metapod can, assuming it existed as caterpie.
This commit is contained in:
parent
4456a9dc7a
commit
1ece844f78
6 changed files with 37 additions and 15 deletions
|
@ -203,8 +203,16 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
if (IsDeferredWurmple(pkm))
|
if (IsDeferredWurmple(pkm))
|
||||||
return EncounterMatchRating.PartialMatch;
|
return EncounterMatchRating.PartialMatch;
|
||||||
if (IsDeferredHiddenAbility(pkm.AbilityNumber == 4))
|
|
||||||
return EncounterMatchRating.Deferred;
|
if (pkm.Format >= 5)
|
||||||
|
{
|
||||||
|
bool isHidden = pkm.AbilityNumber == 4;
|
||||||
|
if (isHidden && this.IsPartialMatchHidden(Species))
|
||||||
|
return EncounterMatchRating.PartialMatch;
|
||||||
|
if (IsDeferredHiddenAbility(isHidden))
|
||||||
|
return EncounterMatchRating.Deferred;
|
||||||
|
}
|
||||||
|
|
||||||
return EncounterMatchRating.Match;
|
return EncounterMatchRating.Match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,9 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
public override EncounterMatchRating GetMatchRating(PKM pkm)
|
public override EncounterMatchRating GetMatchRating(PKM pkm)
|
||||||
{
|
{
|
||||||
if (IsDeferredWurmple(pkm))
|
if (IsDeferredSafari3(pkm.Ball == (int)Ball.Safari))
|
||||||
return EncounterMatchRating.PartialMatch;
|
return EncounterMatchRating.PartialMatch;
|
||||||
if (IsDeferredSafari3(pkm.Ball == (int) Ball.Safari))
|
return base.GetMatchRating(pkm);
|
||||||
return EncounterMatchRating.PartialMatch;
|
|
||||||
return EncounterMatchRating.Match;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsDeferredSafari3(bool IsSafariBall) => IsSafariBall != Locations.IsSafariZoneLocation3(Location);
|
private bool IsDeferredSafari3(bool IsSafariBall) => IsSafariBall != Locations.IsSafariZoneLocation3(Location);
|
||||||
|
|
|
@ -31,8 +31,6 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
public override EncounterMatchRating GetMatchRating(PKM pkm)
|
public override EncounterMatchRating GetMatchRating(PKM pkm)
|
||||||
{
|
{
|
||||||
if (IsDeferredWurmple(pkm))
|
|
||||||
return EncounterMatchRating.PartialMatch;
|
|
||||||
if ((pkm.Ball == (int)Ball.Safari) != Locations.IsSafariZoneLocation4(Location))
|
if ((pkm.Ball == (int)Ball.Safari) != Locations.IsSafariZoneLocation4(Location))
|
||||||
return EncounterMatchRating.PartialMatch;
|
return EncounterMatchRating.PartialMatch;
|
||||||
if ((pkm.Ball == (int)Ball.Sport) != (Area.Type == SlotType.BugContest))
|
if ((pkm.Ball == (int)Ball.Sport) != (Area.Type == SlotType.BugContest))
|
||||||
|
@ -41,7 +39,7 @@ namespace PKHeX.Core
|
||||||
if (pkm.Species != (int)Core.Species.Shedinja || pkm.Ball != (int)Ball.Poke)
|
if (pkm.Species != (int)Core.Species.Shedinja || pkm.Ball != (int)Ball.Poke)
|
||||||
return EncounterMatchRating.PartialMatch;
|
return EncounterMatchRating.PartialMatch;
|
||||||
}
|
}
|
||||||
return EncounterMatchRating.Match;
|
return base.GetMatchRating(pkm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
if (IsMatchPartial(pkm))
|
if (IsMatchPartial(pkm))
|
||||||
return EncounterMatchRating.PartialMatch;
|
return EncounterMatchRating.PartialMatch;
|
||||||
return EncounterMatchRating.Match;
|
return base.GetMatchRating(pkm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsMatchPartial(PKM pk)
|
private bool IsMatchPartial(PKM pk)
|
||||||
|
@ -70,9 +70,6 @@ namespace PKHeX.Core
|
||||||
if (PersonalTable.SWSH.GetFormEntry(Species, Form).BaseFriendship != pk.OT_Friendship)
|
if (PersonalTable.SWSH.GetFormEntry(Species, Form).BaseFriendship != pk.OT_Friendship)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Species == (int)Core.Species.Wurmple)
|
|
||||||
return !WurmpleUtil.IsWurmpleEvoValid(pk);
|
|
||||||
|
|
||||||
return Species switch
|
return Species switch
|
||||||
{
|
{
|
||||||
(int)Core.Species.Yamask when pk.Species != Species && Form == 1 => pk is IFormArgument { FormArgument: 0 },
|
(int)Core.Species.Yamask when pk.Species != Species && Form == 1 => pk is IFormArgument { FormArgument: 0 },
|
||||||
|
|
|
@ -305,6 +305,8 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
protected virtual bool IsMatchPartial(PKM pkm)
|
protected virtual bool IsMatchPartial(PKM pkm)
|
||||||
{
|
{
|
||||||
|
if (pkm.Format >= 5 && pkm.AbilityNumber == 4 && this.IsPartialMatchHidden(Species))
|
||||||
|
return true;
|
||||||
return pkm.FatefulEncounter != Fateful;
|
return pkm.FatefulEncounter != Fateful;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,27 @@
|
||||||
namespace PKHeX.Core
|
using static PKHeX.Core.Species;
|
||||||
|
|
||||||
|
namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
public interface IEncounterMatch
|
public interface IEncounterMatch
|
||||||
{
|
{
|
||||||
bool IsMatchExact(PKM pkm, DexLevel dl);
|
bool IsMatchExact(PKM pkm, DexLevel dl);
|
||||||
EncounterMatchRating GetMatchRating(PKM pkm);
|
EncounterMatchRating GetMatchRating(PKM pkm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static class EncounterMatchExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Some species do not have a Hidden Ability, but can be altered to have the HA slot via pre-evolution.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_">Match object</param>
|
||||||
|
/// <param name="species">Species ID</param>
|
||||||
|
/// <returns>True if it should not originate as this species.</returns>
|
||||||
|
public static bool IsPartialMatchHidden(this IEncounterMatch _, int species)
|
||||||
|
{
|
||||||
|
return species is (int)Metapod or (int)Kakuna
|
||||||
|
or (int)Pupitar
|
||||||
|
or (int)Silcoon or (int)Cascoon
|
||||||
|
or (int)Vibrava or (int)Flygon;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue