mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Pass encounter object to innermost ability verifier
Fixes stuff for format3 CXD encounters as the side-games applied ability bits regardless of a second ability existing.
This commit is contained in:
parent
70e10478dd
commit
69a907c5e7
1 changed files with 10 additions and 9 deletions
|
@ -126,7 +126,7 @@ namespace PKHeX.Core
|
|||
6 => VerifyAbility6(data, enc),
|
||||
7 => VerifyAbility7(data, enc),
|
||||
>=8 => VALID,
|
||||
_ => CheckMatch(data.pkm, abilities, gen, AbilityState.CanMismatch)
|
||||
_ => CheckMatch(data.pkm, abilities, gen, AbilityState.CanMismatch, enc)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ namespace PKHeX.Core
|
|||
if (gen == 5)
|
||||
return VerifyAbility5(data, enc, abilities);
|
||||
|
||||
return CheckMatch(pkm, abilities, gen, state);
|
||||
return CheckMatch(pkm, abilities, gen, state, enc);
|
||||
}
|
||||
|
||||
private CheckResult VerifyFixedAbility(LegalityAnalysis data, IReadOnlyList<int> abilities, AbilityState state, int encounterAbility, int abilIndex)
|
||||
|
@ -187,7 +187,7 @@ namespace PKHeX.Core
|
|||
return INVALID;
|
||||
}
|
||||
|
||||
return CheckMatch(pkm, abilities, enc.Generation, AbilityState.MustMatch);
|
||||
return CheckMatch(pkm, abilities, enc.Generation, AbilityState.MustMatch, enc);
|
||||
}
|
||||
|
||||
if (encounterAbility == 1 << abilIndex)
|
||||
|
@ -197,7 +197,7 @@ namespace PKHeX.Core
|
|||
return VALID;
|
||||
|
||||
if (state == AbilityState.CanMismatch || encounterAbility == 0)
|
||||
return CheckMatch(pkm, abilities, enc.Generation, AbilityState.MustMatch);
|
||||
return CheckMatch(pkm, abilities, enc.Generation, AbilityState.MustMatch, enc);
|
||||
|
||||
if (IsAbilityCapsuleModified(pkm, abilities, encounterAbility))
|
||||
return GetValid(LAbilityCapsuleUsed);
|
||||
|
@ -318,14 +318,14 @@ namespace PKHeX.Core
|
|||
// Gen3-5 transfer with same ability -> 1st ability that matches
|
||||
if (pkm.AbilityNumber == 1)
|
||||
return VALID;
|
||||
return CheckMatch(pkm, abilities, 4, AbilityState.MustMatch); // evolved, must match
|
||||
return CheckMatch(pkm, abilities, 4, AbilityState.MustMatch, pcd); // evolved, must match
|
||||
}
|
||||
if (pkm.AbilityNumber < 4) // Ability Capsule can change between 1/2
|
||||
return GetValid(LAbilityCapsuleUsed);
|
||||
}
|
||||
|
||||
if (pcd.Species != pkm.Species)
|
||||
return CheckMatch(pkm, abilities, 4, AbilityState.MustMatch); // evolved, must match
|
||||
return CheckMatch(pkm, abilities, 4, AbilityState.MustMatch, pcd); // evolved, must match
|
||||
|
||||
// Edge case (PID ability gift mismatch) -- must match gift ability.
|
||||
return pkm.Ability == pcd.Gift.PK.Ability ? VALID : INVALID;
|
||||
|
@ -340,7 +340,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
EncounterSlot5 w when pkm.AbilityNumber == 4 != w.IsHiddenGrotto => GetInvalid(w.IsHiddenGrotto ? LAbilityMismatchGrotto : LAbilityHiddenFail),
|
||||
EncounterEgg e when pkm.AbilityNumber == 4 && AbilityBreedLegality.BanHidden5.Contains(e.Species) => GetInvalid(LAbilityHiddenUnavailable),
|
||||
_ => CheckMatch(data.pkm, abilities, 5, pkm.Format == 5 ? AbilityState.MustMatch : AbilityState.CanMismatch)
|
||||
_ => CheckMatch(data.pkm, abilities, 5, pkm.Format == 5 ? AbilityState.MustMatch : AbilityState.CanMismatch, enc)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,8 @@ namespace PKHeX.Core
|
|||
/// <param name="abilities">Current abilities</param>
|
||||
/// <param name="gen">Generation</param>
|
||||
/// <param name="state">Permissive to allow ability to deviate under special circumstances</param>
|
||||
private CheckResult CheckMatch(PKM pkm, IReadOnlyList<int> abilities, int gen, AbilityState state)
|
||||
/// <param name="enc">Encounter template the <see cref="pkm"/> was matched to.</param>
|
||||
private CheckResult CheckMatch(PKM pkm, IReadOnlyList<int> abilities, int gen, AbilityState state, IEncounterTemplate enc)
|
||||
{
|
||||
if (gen is (3 or 4) && pkm.AbilityNumber == 4)
|
||||
return GetInvalid(LAbilityHiddenUnavailable);
|
||||
|
@ -402,7 +403,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
// Must not have the Ability bit flag set.
|
||||
// Some shadow stuff with single-ability might have the flag set anyways?
|
||||
if (abit && !(pkm is IShadowPKM {ShadowID: not 0}))
|
||||
if (abit && enc is not EncounterStaticShadow)
|
||||
return GetInvalid(LAbilityMismatchFlag, CheckIdentifier.PID);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue