Explicitly implement IFixedAbilityNumber on all templates

This commit is contained in:
Kurt 2021-12-09 00:46:59 -08:00
parent 90956f3b05
commit 51c75dd102
13 changed files with 71 additions and 10 deletions

View file

@ -7,7 +7,7 @@ namespace PKHeX.Core
/// Wild Encounter Slot data
/// </summary>
/// <remarks>Wild encounter slots are found as random encounters in-game.</remarks>
public abstract record EncounterSlot : IEncounterable, ILocation, IEncounterMatch
public abstract record EncounterSlot : IEncounterable, ILocation, IEncounterMatch, IFixedAbilityNumber
{
public int Species { get; }
public int Form { get; }

View file

@ -482,7 +482,6 @@ namespace PKHeX.Core
private static int GetEncounterFixedAbilityNumber(IEncounterTemplate enc) => enc switch
{
IFixedAbilityNumber s => s.Ability,
EncounterSlot w => w.Ability,
_ => -1,
};
}

View file

@ -7,7 +7,7 @@ namespace PKHeX.Core
/// <summary>
/// Mystery Gift Template File
/// </summary>
public abstract class MysteryGift : IEncounterable, IMoveset, IRelearn, ILocation, IFixedBall
public abstract class MysteryGift : IEncounterable, IMoveset, IRelearn, ILocation, IFixedBall, IFixedAbilityNumber
{
/// <summary>
/// Determines whether or not the given length of bytes is valid for a mystery gift.
@ -113,6 +113,7 @@ namespace PKHeX.Core
// Properties
public virtual int Species { get => -1; set { } }
public abstract int Ability { get; }
public abstract bool GiftUsed { get; set; }
public abstract string CardTitle { get; set; }
public abstract int CardID { get; set; }

View file

@ -91,6 +91,7 @@ namespace PKHeX.Core
public override int TID { get => Gift.TID; set => Gift.TID = value; }
public override int SID { get => Gift.SID; set => Gift.SID = value; }
public override string OT_Name { get => Gift.OT_Name; set => Gift.OT_Name = value; }
public override int Ability => Gift.Ability;
// ILocation overrides
public override int Location { get => IsEgg ? 0 : Gift.EggLocation + 3000; set { } }

View file

@ -288,6 +288,15 @@ namespace PKHeX.Core
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
};
public override int Ability => AbilityType switch
{
0 => 1,
1 => 2,
2 => 4,
3 => 0,
_ => -1,
};
private void SetPID(PKM pk, int av)
{
if (PID != 0)

View file

@ -24,6 +24,8 @@ namespace PKHeX.Core
set { if (IsPokémon) PK.Ball = value; }
}
public override int Ability => IsManaphyEgg ? 0 : 1 + (int)(PK.PID & 1);
private enum GiftType
{
Pokémon = 1,
@ -174,7 +176,7 @@ namespace PKHeX.Core
pk4.Move1 = 294; pk4.Move1_PP = 20;
pk4.Move2 = 145; pk4.Move2_PP = 30;
pk4.Move3 = 346; pk4.Move3_PP = 15;
pk4.Ability = (int)Ability.Hydration;
pk4.Ability = (int)Core.Ability.Hydration;
pk4.FatefulEncounter = true;
pk4.Ball = (int)Core.Ball.Poke;
pk4.Version = GameVersion.Gen4.Contains(trainer.Game) ? trainer.Game : (int)GameVersion.D;

View file

@ -216,7 +216,7 @@ namespace PKHeX.Core
public int RelearnMove3 { get => BitConverter.ToUInt16(Data, CardStart + 0xDC); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, CardStart + 0xDC); }
public int RelearnMove4 { get => BitConverter.ToUInt16(Data, CardStart + 0xDE); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, CardStart + 0xDE); }
public int AV_HP { get => Data[CardStart + 0xE5]; set => Data[CardStart + 0xE5] = (byte)value; }
public int AV_HP { get => Data[CardStart + 0xE5]; set => Data[CardStart + 0xE5] = (byte)value; }
public int AV_ATK { get => Data[CardStart + 0xE6]; set => Data[CardStart + 0xE6] = (byte)value; }
public int AV_DEF { get => Data[CardStart + 0xE7]; set => Data[CardStart + 0xE7] = (byte)value; }
public int AV_SPE { get => Data[CardStart + 0xE8]; set => Data[CardStart + 0xE8] = (byte)value; }
@ -427,6 +427,15 @@ namespace PKHeX.Core
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
};
public override int Ability => AbilityType switch
{
0 => 1,
1 => 2,
2 => 4,
3 => 0,
_ => -1,
};
private void SetPID(PKM pk)
{
switch (PIDType)

View file

@ -214,7 +214,7 @@ namespace PKHeX.Core
Data[RibbonBytesOffset + byteIndex] = ribbonIndex;
}
public int IV_HP { get => Data[CardStart + 0x2B2]; set => Data[CardStart + 0x2B2] = (byte)value; }
public int IV_HP { get => Data[CardStart + 0x2B2]; set => Data[CardStart + 0x2B2] = (byte)value; }
public int IV_ATK { get => Data[CardStart + 0x2B3]; set => Data[CardStart + 0x2B3] = (byte)value; }
public int IV_DEF { get => Data[CardStart + 0x2B4]; set => Data[CardStart + 0x2B4] = (byte)value; }
public int IV_SPE { get => Data[CardStart + 0x2B5]; set => Data[CardStart + 0x2B5] = (byte)value; }
@ -223,7 +223,7 @@ namespace PKHeX.Core
public int OTGender { get => Data[CardStart + 0x2B8]; set => Data[CardStart + 0x2B8] = (byte)value; }
public int EV_HP { get => Data[CardStart + 0x2B9]; set => Data[CardStart + 0x2B9] = (byte)value; }
public int EV_HP { get => Data[CardStart + 0x2B9]; set => Data[CardStart + 0x2B9] = (byte)value; }
public int EV_ATK { get => Data[CardStart + 0x2BA]; set => Data[CardStart + 0x2BA] = (byte)value; }
public int EV_DEF { get => Data[CardStart + 0x2BB]; set => Data[CardStart + 0x2BB] = (byte)value; }
public int EV_SPE { get => Data[CardStart + 0x2BC]; set => Data[CardStart + 0x2BC] = (byte)value; }
@ -499,6 +499,15 @@ namespace PKHeX.Core
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
};
public override int Ability => AbilityType switch
{
0 => 1,
1 => 2,
2 => 4,
3 => 0,
_ => -1,
};
private uint GetPID(ITrainerID tr, byte type)
{
return type switch

View file

@ -72,6 +72,8 @@ namespace PKHeX.Core
init => _metLevel = value;
}
public override int Ability => 0; // 1/2
public override PKM ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria)
{
PK3 pk = new()

View file

@ -147,7 +147,7 @@ namespace PKHeX.Core
public int Nature { get => (sbyte)Data[0xA0]; set => Data[0xA0] = (byte)value; }
public override int Gender { get => Data[0xA1]; set => Data[0xA1] = (byte)value; }
public override int AbilityType { get => Data[0xA2]; set => Data[0xA2] = (byte)value; }
public override int AbilityType { get => Data[0xA2]; set => Data[0xA2] = (byte)value; }
public Shiny PIDType { get => (Shiny)Data[0xA3]; set => Data[0xA3] = (byte)value; }
public override int EggLocation { get => BitConverter.ToUInt16(Data, 0xA4); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xA4); }
public int MetLocation { get => BitConverter.ToUInt16(Data, 0xA6); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xA6); }
@ -416,6 +416,15 @@ namespace PKHeX.Core
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
};
public override int Ability => AbilityType switch
{
0 => 1,
1 => 2,
2 => 4,
3 => 0,
_ => -1,
};
private void SetPID(PKM pk)
{
switch (PIDType)

View file

@ -448,6 +448,15 @@ namespace PKHeX.Core
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
};
public override int Ability => AbilityType switch
{
0 => 1,
1 => 2,
2 => 4,
3 => 0,
_ => -1,
};
private void SetPID(PKM pk)
{
switch (PIDType)

View file

@ -210,7 +210,7 @@ namespace PKHeX.Core
Data[RibbonBytesOffset + byteIndex] = ribbonIndex;
}
public int IV_HP { get => Data[CardStart + 0x26C]; set => Data[CardStart + 0x26C] = (byte)value; }
public int IV_HP { get => Data[CardStart + 0x26C]; set => Data[CardStart + 0x26C] = (byte)value; }
public int IV_ATK { get => Data[CardStart + 0x26D]; set => Data[CardStart + 0x26D] = (byte)value; }
public int IV_DEF { get => Data[CardStart + 0x26E]; set => Data[CardStart + 0x26E] = (byte)value; }
public int IV_SPE { get => Data[CardStart + 0x26F]; set => Data[CardStart + 0x26F] = (byte)value; }
@ -219,7 +219,7 @@ namespace PKHeX.Core
public int OTGender { get => Data[CardStart + 0x272]; set => Data[CardStart + 0x272] = (byte)value; }
public int EV_HP { get => Data[CardStart + 0x273]; set => Data[CardStart + 0x273] = (byte)value; }
public int EV_HP { get => Data[CardStart + 0x273]; set => Data[CardStart + 0x273] = (byte)value; }
public int EV_ATK { get => Data[CardStart + 0x274]; set => Data[CardStart + 0x274] = (byte)value; }
public int EV_DEF { get => Data[CardStart + 0x275]; set => Data[CardStart + 0x275] = (byte)value; }
public int EV_SPE { get => Data[CardStart + 0x276]; set => Data[CardStart + 0x276] = (byte)value; }
@ -504,6 +504,15 @@ namespace PKHeX.Core
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
};
public override int Ability => AbilityType switch
{
0 => 1,
1 => 2,
2 => 4,
3 => 0,
_ => -1,
};
private uint GetPID(ITrainerID tr, byte type)
{
return type switch

View file

@ -19,6 +19,8 @@ namespace PKHeX.Core
public WR7() : this(new byte[Size]) { }
public WR7(byte[] data) : base(data) { }
public override int Ability => -1; // undefined
public uint Epoch
{
get => BitConverter.ToUInt32(Data, 0x00);