Revise naive ability deferral logic for gen9

Closes #4221

HA->1->2 requires a 2-step check
This commit is contained in:
Kurt 2024-03-17 14:44:54 -05:00
parent ea63d90ac4
commit 9e7046564c
6 changed files with 48 additions and 6 deletions

View file

@ -353,7 +353,14 @@ public sealed record EncounterDist9
}
else if (Ability.IsSingleValue(out int index) && 1 << index != num) // Fixed regular ability
{
if (Ability is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
var a = Ability;
if (a is OnlyHidden)
{
if (!AbilityVerifier.CanAbilityPatch(9, PersonalTable.SV.GetFormEntry(Species, Form), pk.Species))
return DeferredErrors;
a = num == 1 ? OnlyFirst : OnlySecond;
}
if (a is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
return DeferredErrors;
}
}

View file

@ -236,7 +236,14 @@ public sealed record EncounterFixed9
}
else if (Ability.IsSingleValue(out int index) && 1 << index != num) // Fixed regular ability
{
if (Ability is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
var a = Ability;
if (a is OnlyHidden)
{
if (!AbilityVerifier.CanAbilityPatch(9, PersonalTable.SV.GetFormEntry(Species, Form), pk.Species))
return EncounterMatchRating.DeferredErrors;
a = num == 1 ? OnlyFirst : OnlySecond;
}
if (a is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
return EncounterMatchRating.DeferredErrors;
}
}

View file

@ -365,7 +365,14 @@ public sealed record EncounterMight9
}
else if (Ability.IsSingleValue(out int index) && 1 << index != num) // Fixed regular ability
{
if (Ability is AbilityPermission.OnlyFirst or AbilityPermission.OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
var a = Ability;
if (a is AbilityPermission.OnlyHidden)
{
if (!AbilityVerifier.CanAbilityPatch(9, PersonalTable.SV.GetFormEntry(Species, Form), pk.Species))
return EncounterMatchRating.DeferredErrors;
a = num == 1 ? AbilityPermission.OnlyFirst : AbilityPermission.OnlySecond;
}
if (a is AbilityPermission.OnlyFirst or AbilityPermission.OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
return EncounterMatchRating.DeferredErrors;
}
}

View file

@ -217,7 +217,14 @@ public sealed record EncounterOutbreak9
}
else if (Ability.IsSingleValue(out int index) && 1 << index != num) // Fixed regular ability
{
if (Ability is AbilityPermission.OnlyFirst or AbilityPermission.OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
var a = Ability;
if (a is AbilityPermission.OnlyHidden)
{
if (!AbilityVerifier.CanAbilityPatch(9, PersonalTable.SV.GetFormEntry(Species, Form), pk.Species))
return EncounterMatchRating.DeferredErrors;
a = num == 1 ? AbilityPermission.OnlyFirst : AbilityPermission.OnlySecond;
}
if (a is AbilityPermission.OnlyFirst or AbilityPermission.OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
return EncounterMatchRating.DeferredErrors;
}
}

View file

@ -258,7 +258,14 @@ public sealed record EncounterStatic9(GameVersion Version)
}
else if (Ability.IsSingleValue(out int index) && 1 << index != num) // Fixed regular ability
{
if (Ability is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
var a = Ability;
if (a is OnlyHidden)
{
if (!AbilityVerifier.CanAbilityPatch(9, PersonalTable.SV.GetFormEntry(Species, Form), pk.Species))
return EncounterMatchRating.DeferredErrors;
a = num == 1 ? OnlyFirst : OnlySecond;
}
if (a is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
return EncounterMatchRating.DeferredErrors;
}
}

View file

@ -289,7 +289,14 @@ public sealed record EncounterTera9
}
else if (Ability.IsSingleValue(out int index) && 1 << index != num) // Fixed regular ability
{
if (Ability is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
var a = Ability;
if (a is OnlyHidden)
{
if (!AbilityVerifier.CanAbilityPatch(9, PersonalTable.SV.GetFormEntry(Species, Form), pk.Species))
return EncounterMatchRating.DeferredErrors;
a = num == 1 ? OnlyFirst : OnlySecond;
}
if (a is OnlyFirst or OnlySecond && !AbilityVerifier.CanAbilityCapsule(9, PersonalTable.SV.GetFormEntry(Species, Form)))
return EncounterMatchRating.DeferredErrors;
}
}