mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Make RefreshAbility virtual, add overrides for gen3&5
Gen5: set HA bit if hidden ability Gen3: prevent setting AbilityBit if it doesn't have 2 distinct abilities Failed test now passes; all tests are passing!
This commit is contained in:
parent
fefc38bacb
commit
5bc5b611cb
3 changed files with 14 additions and 3 deletions
|
@ -316,6 +316,12 @@ namespace PKHeX.Core
|
|||
return false;
|
||||
}
|
||||
|
||||
public override void RefreshAbility(int n)
|
||||
{
|
||||
base.RefreshAbility(n);
|
||||
HiddenAbility = n == 2;
|
||||
}
|
||||
|
||||
public PK6 ConvertToPK6()
|
||||
{
|
||||
PK6 pk6 = new PK6 // Convert away!
|
||||
|
|
|
@ -710,14 +710,12 @@ namespace PKHeX.Core
|
|||
/// Applies the desired Ability option.
|
||||
/// </summary>
|
||||
/// <param name="n">Ability Number (0/1/2)</param>
|
||||
public void RefreshAbility(int n)
|
||||
public virtual void RefreshAbility(int n)
|
||||
{
|
||||
AbilityNumber = 1 << n;
|
||||
var abilities = PersonalInfo.Abilities;
|
||||
if ((uint)n < abilities.Count)
|
||||
Ability = abilities[n];
|
||||
if (this is PK5 pk5)
|
||||
pk5.HiddenAbility = n == 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -42,6 +42,13 @@
|
|||
public sealed override int AbilityNumber { get => 1 << (AbilityBit ? 1 : 0); set => AbilityBit = value > 1; } // [0,1]->[1,2] ; [1,x]->[0,1]
|
||||
public abstract bool AbilityBit { get; set; }
|
||||
|
||||
public sealed override void RefreshAbility(int n)
|
||||
{
|
||||
if (n == 1 && !((PersonalInfoG3)PersonalInfo).HasSecondAbility)
|
||||
n = 0;
|
||||
base.RefreshAbility(n & 1);
|
||||
}
|
||||
|
||||
public abstract bool RibbonEarth { get; set; }
|
||||
public abstract bool RibbonNational { get; set; }
|
||||
public abstract bool RibbonCountry { get; set; }
|
||||
|
|
Loading…
Add table
Reference in a new issue