More deferral tweaks for non-HA having HA

This commit is contained in:
Kurt 2021-04-22 13:47:33 -07:00
parent b049c82284
commit f66662b8db
4 changed files with 21 additions and 17 deletions

View file

@ -77,6 +77,10 @@ namespace PKHeX.Core
if (Location is 76 && ((EncounterArea8)Area).PermitCrossover)
return EncounterMatchRating.PartialMatch;
bool isHidden = pkm.AbilityNumber == 4;
if (isHidden && this.IsPartialMatchHidden(pkm.Species, Species))
return EncounterMatchRating.PartialMatch;
if (pkm is IRibbonSetMark8 m)
{
if (m.RibbonMarkCurry && (Weather & AreaWeather8.All) == 0)

View file

@ -46,13 +46,15 @@ namespace PKHeX.Core
{
if (Ability != -1) // Any
{
bool CanBeHidden() => ((PersonalInfoSWSH) PersonalTable.SWSH.GetFormEntry(Species, Form)).HasHiddenAbility;
// HA-Only is a strict match. Ability Capsule and Patch can potentially change these.
if (Ability == 0 && pkm.AbilityNumber == 4)
return true; // 0/1
return !CanBeHidden(); // 0/1
if (Ability == 1 && pkm.AbilityNumber != 1)
return true; // 0
return pkm.AbilityNumber != 4 || !CanBeHidden(); // 0
if (Ability == 2 && pkm.AbilityNumber != 2)
return true; // 1
return pkm.AbilityNumber != 4 || !CanBeHidden(); // 1
}
return base.IsMatchDeferred(pkm);

View file

@ -69,8 +69,15 @@ namespace PKHeX.Core
if (format >= 8) // Ability Patch
{
if (pkm.AbilityNumber == 4 && CanAbilityPatch(format, abilities, pkm.Species))
return GetValid(LAbilityPatchUsed);
if (pkm.AbilityNumber == 4)
{
if (CanAbilityPatch(format, abilities, pkm.Species))
return GetValid(LAbilityPatchUsed);
var e = data.EncounterOriginal;
if (e.Species != pkm.Species && CanAbilityPatch(format, PKX.Personal.GetFormEntry(e.Species, e.Form).Abilities, e.Species))
return GetValid(LAbilityPatchUsed);
}
}
var enc = data.EncounterMatch;
@ -118,7 +125,7 @@ namespace PKHeX.Core
5 => VerifyAbility5(data, enc, abilities),
6 => VerifyAbility6(data, enc),
7 => VerifyAbility7(data, enc),
8 => VerifyAbility8(data, enc),
>=8 => VALID,
_ => CheckMatch(data.pkm, abilities, gen, AbilityState.CanMismatch)
};
}
@ -369,17 +376,6 @@ namespace PKHeX.Core
return VALID;
}
private CheckResult VerifyAbility8(LegalityAnalysis data, IEncounterable enc)
{
var pkm = data.pkm;
if (enc is EncounterSlot && pkm.AbilityNumber == 4)
return GetInvalid(LAbilityHiddenUnavailable);
//if (BreedLegality.Ban_NoHidden8.Contains(pkm.SpecForm) && pkm.AbilityNumber == 4)
// return GetInvalid(LAbilityHiddenUnavailable);
return VALID;
}
/// <summary>
/// Final checks assuming nothing else has flagged the ability.
/// </summary>

View file

@ -135,5 +135,7 @@ namespace PKHeX.Core
/// Checks if the entry shows up in any of the built-in Pokédex.
/// </summary>
public bool IsInDex => PokeDexIndex != 0 || ArmorDexIndex != 0 || CrownDexIndex != 0;
public bool HasHiddenAbility => AbilityH != Ability1;
}
}