seal hunting

Mark things as sealed as they shouldn't be inherited from or overriden in a derived class.
This commit is contained in:
Kurt
2020-09-07 13:51:13 -07:00
parent 0111c3dd6f
commit 5d3bc289b6
61 changed files with 305 additions and 320 deletions

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
public class EventVarGroup
public sealed class EventVarGroup
{
public readonly EventVarType Type;
public readonly List<EventVar> Vars = new List<EventVar>();

View File

@@ -68,7 +68,7 @@ private abstract class SlotReversion
public abstract void Revert(SaveFile sav);
}
private class PartyReversion : SlotReversion
private sealed class PartyReversion : SlotReversion
{
private readonly IList<PKM> Party;
public PartyReversion(ISlotInfo info, SaveFile s) : base(info) => Party = s.PartyData;
@@ -76,7 +76,7 @@ private class PartyReversion : SlotReversion
public override void Revert(SaveFile sav) => sav.PartyData = Party;
}
private class SingleSlotReversion : SlotReversion
private sealed class SingleSlotReversion : SlotReversion
{
private readonly PKM Entity;
public SingleSlotReversion(ISlotInfo info, SaveFile sav) : base(info) => Entity = info.Read(sav);

View File

@@ -2,7 +2,7 @@ namespace PKHeX.Core
{
public class EncounterSlot3 : EncounterSlot, IMagnetStatic, INumberedSlot
{
public override int Generation => 3;
public sealed override int Generation => 3;
public int StaticIndex { get; set; }
public int MagnetPullIndex { get; set; }

View File

@@ -4,7 +4,6 @@ namespace PKHeX.Core
{
internal sealed class EncounterSlot3Swarm : EncounterSlot3, IMoveset
{
public override int Generation => 3;
public IReadOnlyList<int> Moves { get; }
public EncounterSlot3Swarm(EncounterArea3 area, int species, int min, int max, int slot,

View File

@@ -5,7 +5,7 @@ namespace PKHeX.Core
{
public class EncounterStatic2 : EncounterStatic
{
public override int Generation => 2;
public sealed override int Generation => 2;
public sealed override int Level { get; set; }
public EncounterStatic2(int species, int level)

View File

@@ -5,7 +5,7 @@ namespace PKHeX.Core
{
public class EncounterStatic3 : EncounterStatic
{
public override int Generation => 3;
public sealed override int Generation => 3;
public bool Roaming { get; set; }
protected override bool IsMatchEggLocation(PKM pkm)

View File

@@ -2,7 +2,7 @@
{
public class EncounterStatic4 : EncounterStatic
{
public override int Generation => 4;
public sealed override int Generation => 4;
protected sealed override bool IsMatchEggLocation(PKM pkm)
{

View File

@@ -4,7 +4,7 @@ namespace PKHeX.Core
{
public class EncounterStatic5 : EncounterStatic
{
public override int Generation => 5;
public sealed override int Generation => 5;
public bool Roaming { get; set; }
public sealed override bool IsMatchDeferred(PKM pkm)

View File

@@ -2,7 +2,7 @@
{
public class EncounterStatic8 : EncounterStatic, IGigantamax
{
public override int Generation => 8;
public sealed override int Generation => 8;
public bool CanGigantamax { get; set; }
protected override bool IsMatchLevel(PKM pkm, DexLevel evo)

View File

@@ -3,7 +3,7 @@
namespace PKHeX.Core
{
public class EncounterTrade8 : EncounterTrade, IDynamaxLevel, IRelearn, IMemoryOT
public sealed class EncounterTrade8 : EncounterTrade, IDynamaxLevel, IRelearn, IMemoryOT
{
public override int Generation => 8;

View File

@@ -4,7 +4,7 @@
namespace PKHeX.Core
{
internal class EggInfoSource
internal sealed class EggInfoSource
{
public EggInfoSource(PKM pkm, EncounterEgg e)
{

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
internal class LearnInfo
internal sealed class LearnInfo
{
public bool MixedGen12NonTradeback { get; set; }
public List<int> Gen1Moves { get; } = new List<int>();

View File

@@ -3,7 +3,7 @@
namespace PKHeX.Core
{
internal class MoveParseSource
internal sealed class MoveParseSource
{
private static readonly int[] Empty = Array.Empty<int>();
public IReadOnlyList<int> CurrentMoves { get; set; } = Empty;

View File

@@ -1,6 +1,6 @@
namespace PKHeX.Core
{
public class PIDIV
public sealed class PIDIV
{
public static readonly PIDIV None = new PIDIV { NoSeed = true, Type = PIDType.None };
@@ -17,10 +17,4 @@ public class PIDIV
/// <summary> Type of PIDIV correlation </summary>
public PIDType Type;
}
public sealed class PIDIVTSV : PIDIV
{
public int TSV1 { get; internal set; } = -1;
public int TSV2 { get; internal set; } = -1;
}
}

View File

@@ -6,7 +6,7 @@ namespace PKHeX.Core
{
public static partial class Legal
{
private class CountryTable
private sealed class CountryTable
{
public readonly byte BaseForm;
public readonly byte CountryID;
@@ -20,7 +20,7 @@ internal CountryTable(byte form, byte country, params FormSubregionTable[] subs)
}
}
private class FormSubregionTable
private sealed class FormSubregionTable
{
public readonly byte Form;
public readonly byte[] Regions;

View File

@@ -3,7 +3,7 @@
/// <summary>
/// Verifies the Contest stat details.
/// </summary>
public class ContestStatVerifier : Verifier
public sealed class ContestStatVerifier : Verifier
{
protected override CheckIdentifier Identifier => CheckIdentifier.Memory;
public override void Verify(LegalityAnalysis data)

View File

@@ -3,7 +3,7 @@
/// <summary>
/// Legality Check Parse object containing information about a single ribbon.
/// </summary>
internal class RibbonResult
internal sealed class RibbonResult
{
/// <summary>Ribbon Display Name</summary>
public string Name { get; private set; }

View File

@@ -353,7 +353,7 @@ public override int Ball
protected override ushort CalculateChecksum()
{
ushort chk = 0;
for (int i = 8; i < SIZE_STORED; i += 2)
for (int i = 8; i < PokeCrypto.SIZE_4STORED; i += 2)
chk += BigEndian.ToUInt16(Data, i);
return chk;
}

View File

@@ -23,7 +23,7 @@ public sealed class CK3 : G3PKM, IShadowPKM
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
public override byte[] Data { get; }
public CK3(byte[] data) => Data = data;
public CK3() => Data = new byte[SIZE_PARTY];
public CK3() => Data = new byte[PokeCrypto.SIZE_3CSTORED];
public override PKM Clone() => new CK3((byte[])Data.Clone()) {Identifier = Identifier};
private string GetString(int Offset, int Count) => StringConverter3.GetBEString3(Data, Offset, Count);

View File

@@ -100,6 +100,13 @@ private void SetSpeciesValues(int value)
public override int PKRS_Strain { get => 0; set { } }
public override int PKRS_Days { get => 0; set { } }
public override bool CanHoldItem(IReadOnlyList<ushort> valid) => false;
public override int Met_Location { get => 0; set { } }
public override int OT_Gender { get => 0; set { } }
public override int Met_Level { get => 0; set { } }
public override int CurrentFriendship { get => 0; set { } }
public override bool IsEgg { get => false; set { } }
public override int HeldItem { get => 0; set { } }
public override int OT_Friendship { get => 0; set { } }
// Maximums
public override int MaxMoveID => Legal.MaxMoveID_1;

View File

@@ -189,9 +189,6 @@ public override bool IsEgg
public override int Stat_SPD { get => BitConverter.ToUInt16(Data, 0x62); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x62); }
#endregion
// Generated Attributes
public override bool Japanese => IsEgg || Language == (int)LanguageID.Japanese;
protected override byte[] Encrypt()
{
RefreshChecksum();

View File

@@ -6,37 +6,37 @@
public abstract class G3PKM : PKM, IRibbonSetEvent3, IRibbonSetCommon3, IRibbonSetUnique3, IRibbonSetOnly3, IContestStats
{
// Maximums
public override int MaxMoveID => Legal.MaxMoveID_3;
public override int MaxSpeciesID => Legal.MaxSpeciesID_3;
public override int MaxAbilityID => Legal.MaxAbilityID_3;
public override int MaxItemID => Legal.MaxItemID_3;
public override int MaxBallID => Legal.MaxBallID_3;
public override int MaxGameID => Legal.MaxGameID_3;
public override int MaxIV => 31;
public override int MaxEV => 255;
public override int OTLength => 7;
public override int NickLength => 10;
public sealed override int MaxMoveID => Legal.MaxMoveID_3;
public sealed override int MaxSpeciesID => Legal.MaxSpeciesID_3;
public sealed override int MaxAbilityID => Legal.MaxAbilityID_3;
public sealed override int MaxItemID => Legal.MaxItemID_3;
public sealed override int MaxBallID => Legal.MaxBallID_3;
public sealed override int MaxGameID => Legal.MaxGameID_3;
public sealed override int MaxIV => 31;
public sealed override int MaxEV => 255;
public sealed override int OTLength => 7;
public sealed override int NickLength => 10;
// Generated Attributes
public override int PSV => (int)((PID >> 16 ^ (PID & 0xFFFF)) >> 3);
public override int TSV => (TID ^ SID) >> 3;
public override bool Japanese => Language == (int)LanguageID.Japanese;
public override bool WasEvent => Met_Location == 255; // Fateful
public override bool WasGiftEgg => IsEgg && Met_Location == 253; // Gift Egg, indistinguible from normal eggs after hatch
public override bool WasEventEgg => IsEgg && Met_Location == 255; // Event Egg, indistinguible from normal eggs after hatch
public sealed override int PSV => (int)((PID >> 16 ^ (PID & 0xFFFF)) >> 3);
public sealed override int TSV => (TID ^ SID) >> 3;
public sealed override bool Japanese => Language == (int)LanguageID.Japanese;
public sealed override bool WasEvent => Met_Location == 255; // Fateful
public sealed override bool WasGiftEgg => IsEgg && Met_Location == 253; // Gift Egg, indistinguible from normal eggs after hatch
public sealed override bool WasEventEgg => IsEgg && Met_Location == 255; // Event Egg, indistinguible from normal eggs after hatch
public override int Ability { get { var pi = (PersonalInfoG3)PersonalInfo; return AbilityBit && pi.Ability2 != 0 ? pi.Ability2 : pi.Ability1; } set { } }
public override uint EncryptionConstant { get => PID; set { } }
public override int Nature { get => (int)(PID % 25); set { } }
public override int AltForm { get => Species == (int)Core.Species.Unown ? PKX.GetUnownForm(PID) : 0; set { } }
public override bool IsNicknamed { get => SpeciesName.IsNicknamed(Species, Nickname, Language, 3); set { } }
public override int Gender { get => PKX.GetGenderFromPID(Species, PID); set { } }
public override int Characteristic => -1;
public override int CurrentFriendship { get => OT_Friendship; set => OT_Friendship = value; }
public override int CurrentHandler { get => 0; set { } }
public override int Egg_Location { get => 0; set { } }
public sealed override int Ability { get { var pi = (PersonalInfoG3)PersonalInfo; return AbilityBit && pi.Ability2 != 0 ? pi.Ability2 : pi.Ability1; } set { } }
public sealed override uint EncryptionConstant { get => PID; set { } }
public sealed override int Nature { get => (int)(PID % 25); set { } }
public sealed override int AltForm { get => Species == (int)Core.Species.Unown ? PKX.GetUnownForm(PID) : 0; set { } }
public sealed override bool IsNicknamed { get => SpeciesName.IsNicknamed(Species, Nickname, Language, 3); set { } }
public sealed override int Gender { get => PKX.GetGenderFromPID(Species, PID); set { } }
public sealed override int Characteristic => -1;
public sealed override int CurrentFriendship { get => OT_Friendship; set => OT_Friendship = value; }
public sealed override int CurrentHandler { get => 0; set { } }
public sealed override int Egg_Location { get => 0; set { } }
public override int AbilityNumber { get => 1 << (AbilityBit ? 1 : 0); set => AbilityBit = value > 1; } // [0,1]->[1,2] ; [1,x]->[0,1]
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 abstract bool RibbonEarth { get; set; }

View File

@@ -3,21 +3,21 @@
public abstract class G4PKM : PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetUnique3, IRibbonSetUnique4, IRibbonSetCommon3, IRibbonSetCommon4, IContestStats
{
// Maximums
public override int MaxMoveID => Legal.MaxMoveID_4;
public override int MaxSpeciesID => Legal.MaxSpeciesID_4;
public override int MaxAbilityID => Legal.MaxAbilityID_4;
public override int MaxItemID => Legal.MaxItemID_4_HGSS;
public override int MaxBallID => Legal.MaxBallID_4;
public override int MaxGameID => Legal.MaxGameID_4;
public override int MaxIV => 31;
public override int MaxEV => 255;
public override int OTLength => 7;
public override int NickLength => 10;
public sealed override int MaxMoveID => Legal.MaxMoveID_4;
public sealed override int MaxSpeciesID => Legal.MaxSpeciesID_4;
public sealed override int MaxAbilityID => Legal.MaxAbilityID_4;
public sealed override int MaxItemID => Legal.MaxItemID_4_HGSS;
public sealed override int MaxBallID => Legal.MaxBallID_4;
public sealed override int MaxGameID => Legal.MaxGameID_4;
public sealed override int MaxIV => 31;
public sealed override int MaxEV => 255;
public sealed override int OTLength => 7;
public sealed override int NickLength => 10;
public override int PSV => (int)((PID >> 16 ^ (PID & 0xFFFF)) >> 3);
public override int TSV => (TID ^ SID) >> 3;
public sealed override int PSV => (int)((PID >> 16 ^ (PID & 0xFFFF)) >> 3);
public sealed override int TSV => (TID ^ SID) >> 3;
public override int Characteristic
public sealed override int Characteristic
{
get
{
@@ -35,19 +35,19 @@ public override int Characteristic
}
// Trash Bytes
public override byte[] Nickname_Trash { get => GetData(0x48, 22); set { if (value.Length == 22) value.CopyTo(Data, 0x48); } }
public override byte[] OT_Trash { get => GetData(0x68, 16); set { if (value.Length == 16) value.CopyTo(Data, 0x68); } }
public sealed override byte[] Nickname_Trash { get => GetData(0x48, 22); set { if (value.Length == 22) value.CopyTo(Data, 0x48); } }
public sealed override byte[] OT_Trash { get => GetData(0x68, 16); set { if (value.Length == 16) value.CopyTo(Data, 0x68); } }
// Future Attributes
public override uint EncryptionConstant { get => PID; set { } }
public override int Nature { get => (int)(PID % 25); set { } }
public override int CurrentFriendship { get => OT_Friendship; set => OT_Friendship = value; }
public override int CurrentHandler { get => 0; set { } }
public override int AbilityNumber { get => 1 << PIDAbility; set { } }
public sealed override uint EncryptionConstant { get => PID; set { } }
public sealed override int Nature { get => (int)(PID % 25); set { } }
public sealed override int CurrentFriendship { get => OT_Friendship; set => OT_Friendship = value; }
public sealed override int CurrentHandler { get => 0; set { } }
public sealed override int AbilityNumber { get => 1 << PIDAbility; set { } }
// Legality Extensions
public override bool WasEvent => (Met_Location >= 3000 && Met_Location <= 3076) || FatefulEncounter;
public override bool WasEventEgg => WasEgg && Species == (int)Core.Species.Manaphy; // Manaphy was the only generation 4 released event egg
public sealed override bool WasEvent => (Met_Location >= 3000 && Met_Location <= 3076) || FatefulEncounter;
public sealed override bool WasEventEgg => WasEgg && Species == (int)Core.Species.Manaphy; // Manaphy was the only generation 4 released event egg
public abstract int ShinyLeaf { get; set; }

View File

@@ -9,11 +9,11 @@ public abstract class G6PKM : PKM
public override int SIZE_STORED => PokeCrypto.SIZE_6STORED;
// Trash Bytes
public override byte[] Nickname_Trash { get => GetData(0x40, 24); set { if (value.Length == 24) value.CopyTo(Data, 0x40); } }
public override byte[] HT_Trash { get => GetData(0x78, 24); set { if (value.Length == 24) value.CopyTo(Data, 0x78); } }
public override byte[] OT_Trash { get => GetData(0xB0, 24); set { if (value.Length == 24) value.CopyTo(Data, 0xB0); } }
public sealed override byte[] Nickname_Trash { get => GetData(0x40, 24); set { if (value.Length == 24) value.CopyTo(Data, 0x40); } }
public sealed override byte[] HT_Trash { get => GetData(0x78, 24); set { if (value.Length == 24) value.CopyTo(Data, 0x78); } }
public sealed override byte[] OT_Trash { get => GetData(0xB0, 24); set { if (value.Length == 24) value.CopyTo(Data, 0xB0); } }
protected override ushort CalculateChecksum()
protected sealed override ushort CalculateChecksum()
{
ushort chk = 0;
for (int i = 8; i < PokeCrypto.SIZE_6STORED; i += 2) // don't use SIZE_STORED property; pb7 overrides stored size
@@ -22,7 +22,7 @@ protected override ushort CalculateChecksum()
}
// Simple Generated Attributes
public override int CurrentFriendship
public sealed override int CurrentFriendship
{
get => CurrentHandler == 0 ? OT_Friendship : HT_Friendship;
set { if (CurrentHandler == 0) OT_Friendship = value; else HT_Friendship = value; }
@@ -34,12 +34,12 @@ public int OppositeFriendship
set { if (CurrentHandler == 1) OT_Friendship = value; else HT_Friendship = value; }
}
public override int PSV => (int)((PID >> 16 ^ (PID & 0xFFFF)) >> 4);
public override int TSV => (TID ^ SID) >> 4;
public override bool IsUntraded => Data[0x78] == 0 && Data[0x78 + 1] == 0 && Format == GenNumber; // immediately terminated HT_Name data (\0)
public sealed override int PSV => (int)((PID >> 16 ^ (PID & 0xFFFF)) >> 4);
public sealed override int TSV => (TID ^ SID) >> 4;
public sealed override bool IsUntraded => Data[0x78] == 0 && Data[0x78 + 1] == 0 && Format == GenNumber; // immediately terminated HT_Name data (\0)
// Complex Generated Attributes
public override int Characteristic
public sealed override int Characteristic
{
get
{
@@ -57,7 +57,7 @@ public override int Characteristic
}
// Methods
protected override byte[] Encrypt()
protected sealed override byte[] Encrypt()
{
RefreshChecksum();
return PokeCrypto.EncryptArray6(Data);
@@ -110,15 +110,15 @@ public void Trade(ITrainerInfo tr, int Day = 1, int Month = 1, int Year = 2015)
protected abstract void TradeHT(ITrainerInfo tr);
// Legality Properties
public override bool WasLink => Met_Location == Locations.LinkGift6 && Gen6;
public override bool WasEvent => Locations.IsEventLocation5(Met_Location) || FatefulEncounter;
public override bool WasEventEgg => GenNumber < 5 ? base.WasEventEgg : (Locations.IsEventLocation5(Egg_Location) || (FatefulEncounter && Egg_Location == Locations.LinkTrade6)) && Met_Level == 1;
public sealed override bool WasLink => Met_Location == Locations.LinkGift6 && Gen6;
public sealed override bool WasEvent => Locations.IsEventLocation5(Met_Location) || FatefulEncounter;
public sealed override bool WasEventEgg => GenNumber < 5 ? base.WasEventEgg : (Locations.IsEventLocation5(Egg_Location) || (FatefulEncounter && Egg_Location == Locations.LinkTrade6)) && Met_Level == 1;
// Maximums
public override int MaxIV => 31;
public override int MaxEV => 252;
public override int OTLength => 12;
public override int NickLength => 12;
public sealed override int MaxIV => 31;
public sealed override int MaxEV => 252;
public sealed override int OTLength => 12;
public sealed override int NickLength => 12;
}
public interface ISuperTrain

View File

@@ -9,16 +9,16 @@ public abstract class GBPKM : PKM
internal const int STRLEN_J = 6;
internal const int STRLEN_U = 11;
public override int MaxBallID => -1;
public override int MaxGameID => -1;
public override int MaxIV => 15;
public override int MaxEV => ushort.MaxValue;
public override int OTLength => Japanese ? 5 : 7;
public override int NickLength => Japanese ? 5 : 10;
public sealed override int MaxBallID => -1;
public sealed override int MaxGameID => -1;
public sealed override int MaxIV => 15;
public sealed override int MaxEV => ushort.MaxValue;
public sealed override int OTLength => Japanese ? 5 : 7;
public sealed override int NickLength => Japanese ? 5 : 10;
public override IReadOnlyList<ushort> ExtraBytes => Array.Empty<ushort>();
public sealed override IReadOnlyList<ushort> ExtraBytes => Array.Empty<ushort>();
public override string FileNameWithoutExtension
public sealed override string FileNameWithoutExtension
{
get
{
@@ -29,8 +29,8 @@ public override string FileNameWithoutExtension
}
private int StringLength => Japanese ? STRLEN_J : STRLEN_U;
public override bool Japanese => otname.Length == STRLEN_J;
public override byte[] Data { get; }
public sealed override bool Japanese => otname.Length == STRLEN_J;
public sealed override byte[] Data { get; }
protected GBPKM(byte[] data, bool jp = false)
{
@@ -51,17 +51,17 @@ protected GBPKM(byte[] data, bool jp = false)
internal byte[] nick;
// Trash Bytes
public override byte[] Nickname_Trash { get => nick; set { if (value.Length == nick.Length) nick = value; } }
public override byte[] OT_Trash { get => otname; set { if (value.Length == otname.Length) otname = value; } }
public sealed override byte[] Nickname_Trash { get => nick; set { if (value.Length == nick.Length) nick = value; } }
public sealed override byte[] OT_Trash { get => otname; set { if (value.Length == otname.Length) otname = value; } }
public override byte[] EncryptedPartyData => Encrypt();
public override byte[] EncryptedBoxData => Encrypt();
public override byte[] DecryptedBoxData => Encrypt();
public override byte[] DecryptedPartyData => Encrypt();
public sealed override byte[] EncryptedPartyData => Encrypt();
public sealed override byte[] EncryptedBoxData => Encrypt();
public sealed override byte[] DecryptedBoxData => Encrypt();
public sealed override byte[] DecryptedPartyData => Encrypt();
private bool? _isnicknamed;
public override bool IsNicknamed
public sealed override bool IsNicknamed
{
get => _isnicknamed ??= !nick.SequenceEqual(GetNonNickname(GuessedLanguage()));
set
@@ -81,7 +81,7 @@ protected bool IsNicknamedBank
}
}
public override int Language
public sealed override int Language
{
get
{
@@ -109,7 +109,7 @@ public override int Language
}
}
public override string Nickname
public sealed override string Nickname
{
get
{
@@ -126,7 +126,7 @@ public override string Nickname
}
}
public override string OT_Name
public sealed override string OT_Name
{
get
{
@@ -137,7 +137,7 @@ public override string OT_Name
set => GetStringSpecial(value, StringLength).CopyTo(otname, 0);
}
public override int Gender
public sealed override int Gender
{
get
{
@@ -154,37 +154,30 @@ public override int Gender
}
#region Future, Unused Attributes
public override bool IsGenderValid() => true; // not a separate property, derived via IVs
public override uint EncryptionConstant { get => 0; set { } }
public override uint PID { get => 0; set { } }
public override int Met_Level { get => 0; set { } }
public override int Nature { get => 0; set { } }
public override bool IsEgg { get => false; set { } }
public override int HeldItem { get => 0; set { } }
public override ushort Sanity { get => 0; set { } }
public override bool ChecksumValid => true;
public override ushort Checksum { get => 0; set { } }
public override bool FatefulEncounter { get => false; set { } }
public override int TSV => 0x0000;
public override int PSV => 0xFFFF;
public override int Characteristic => -1;
public override int MarkValue { get => 0; protected set { } }
public override int CurrentFriendship { get => 0; set { } }
public override int Ability { get => -1; set { } }
public override int CurrentHandler { get => 0; set { } }
public override int Met_Location { get => 0; set { } }
public override int Egg_Location { get => 0; set { } }
public override int OT_Friendship { get => 0; set { } }
public override int OT_Gender { get => 0; set { } }
public override int Ball { get => 0; set { } }
public override int SID { get => 0; set { } }
public sealed override bool IsGenderValid() => true; // not a separate property, derived via IVs
public sealed override uint EncryptionConstant { get => 0; set { } }
public sealed override uint PID { get => 0; set { } }
public sealed override int Nature { get => 0; set { } }
public sealed override ushort Sanity { get => 0; set { } }
public sealed override bool ChecksumValid => true;
public sealed override ushort Checksum { get => 0; set { } }
public sealed override bool FatefulEncounter { get => false; set { } }
public sealed override int TSV => 0x0000;
public sealed override int PSV => 0xFFFF;
public sealed override int Characteristic => -1;
public sealed override int MarkValue { get => 0; protected set { } }
public sealed override int Ability { get => -1; set { } }
public sealed override int CurrentHandler { get => 0; set { } }
public sealed override int Egg_Location { get => 0; set { } }
public sealed override int Ball { get => 0; set { } }
public sealed override int SID { get => 0; set { } }
#endregion
public override bool IsShiny => IV_DEF == 10 && IV_SPE == 10 && IV_SPC == 10 && (IV_ATK & 2) == 2;
public sealed override bool IsShiny => IV_DEF == 10 && IV_SPE == 10 && IV_SPC == 10 && (IV_ATK & 2) == 2;
private int HPVal => GetHiddenPowerBitVal(new[] { IV_SPC, IV_SPE, IV_DEF, IV_ATK });
public override int HPPower => (((5 * HPVal) + (IV_SPC % 4)) / 2) + 31;
public sealed override int HPPower => (((5 * HPVal) + (IV_SPC % 4)) / 2) + 31;
public override int HPType
public sealed override int HPType
{
get => ((IV_ATK & 3) << 2) | (IV_DEF & 3); set
{
@@ -193,7 +186,7 @@ public override int HPType
}
}
public override int AltForm
public sealed override int AltForm
{
get
{
@@ -259,7 +252,7 @@ protected int TransferLanguage(int destLanguage)
return GuessedLanguage(destLanguage);
}
public override ushort[] GetStats(PersonalInfo p)
public sealed override ushort[] GetStats(PersonalInfo p)
{
var lv = Stat_Level;
ushort[] stats =
@@ -281,7 +274,7 @@ protected static ushort GetStat(int BV, int IV, int EV, int LV)
return (ushort)((((2 * (BV + IV)) + EV) * LV / 100) + 5);
}
public override int GetMovePP(int move, int ppUpCount)
public sealed override int GetMovePP(int move, int ppUpCount)
{
var pp = base.GetMovePP(move, 0);
return pp + (ppUpCount * Math.Min(7, pp / 5));
@@ -290,7 +283,7 @@ public override int GetMovePP(int move, int ppUpCount)
/// <summary>
/// Applies <see cref="PKM.IVs"/> to the <see cref="PKM"/> to make it shiny.
/// </summary>
public override void SetShiny()
public sealed override void SetShiny()
{
IV_ATK |= 2;
IV_DEF = 10;

View File

@@ -22,7 +22,7 @@ public sealed class XK3 : G3PKM, IShadowPKM
public override PersonalInfo PersonalInfo => PersonalTable.RS[Species];
public override byte[] Data { get; }
public XK3(byte[] data) => Data = data;
public XK3() => Data = new byte[SIZE_PARTY];
public XK3() => Data = new byte[PokeCrypto.SIZE_3XSTORED];
public override PKM Clone() => new XK3((byte[])Data.Clone()){Identifier = Identifier, Purification = Purification};
private string GetString(int Offset, int Count) => StringConverter3.GetBEString3(Data, Offset, Count);

View File

@@ -24,50 +24,50 @@ public override byte[] Write()
return Data;
}
public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; }
public override int ATK { get => Data[0x01]; set => Data[0x01] = (byte)value; }
public override int DEF { get => Data[0x02]; set => Data[0x02] = (byte)value; }
public override int SPE { get => Data[0x03]; set => Data[0x03] = (byte)value; }
public override int SPA { get => Data[0x04]; set => Data[0x04] = (byte)value; }
public override int SPD { get => Data[0x05]; set => Data[0x05] = (byte)value; }
public override int Type1 { get => Data[0x06]; set => Data[0x06] = (byte)value; }
public override int Type2 { get => Data[0x07]; set => Data[0x07] = (byte)value; }
public override int CatchRate { get => Data[0x08]; set => Data[0x08] = (byte)value; }
public override int EvoStage { get => Data[0x09]; set => Data[0x09] = (byte)value; }
public sealed override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; }
public sealed override int ATK { get => Data[0x01]; set => Data[0x01] = (byte)value; }
public sealed override int DEF { get => Data[0x02]; set => Data[0x02] = (byte)value; }
public sealed override int SPE { get => Data[0x03]; set => Data[0x03] = (byte)value; }
public sealed override int SPA { get => Data[0x04]; set => Data[0x04] = (byte)value; }
public sealed override int SPD { get => Data[0x05]; set => Data[0x05] = (byte)value; }
public sealed override int Type1 { get => Data[0x06]; set => Data[0x06] = (byte)value; }
public sealed override int Type2 { get => Data[0x07]; set => Data[0x07] = (byte)value; }
public sealed override int CatchRate { get => Data[0x08]; set => Data[0x08] = (byte)value; }
public sealed override int EvoStage { get => Data[0x09]; set => Data[0x09] = (byte)value; }
private int EVYield { get => BitConverter.ToUInt16(Data, 0x0A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); }
public override int EV_HP { get => EVYield >> 0 & 0x3; set => EVYield = (EVYield & ~(0x3 << 0)) | (value & 0x3) << 0; }
public override int EV_ATK { get => EVYield >> 2 & 0x3; set => EVYield = (EVYield & ~(0x3 << 2)) | (value & 0x3) << 2; }
public override int EV_DEF { get => EVYield >> 4 & 0x3; set => EVYield = (EVYield & ~(0x3 << 4)) | (value & 0x3) << 4; }
public override int EV_SPE { get => EVYield >> 6 & 0x3; set => EVYield = (EVYield & ~(0x3 << 6)) | (value & 0x3) << 6; }
public override int EV_SPA { get => EVYield >> 8 & 0x3; set => EVYield = (EVYield & ~(0x3 << 8)) | (value & 0x3) << 8; }
public override int EV_SPD { get => EVYield >> 10 & 0x3; set => EVYield = (EVYield & ~(0x3 << 10)) | (value & 0x3) << 10; }
public sealed override int EV_HP { get => EVYield >> 0 & 0x3; set => EVYield = (EVYield & ~(0x3 << 0)) | (value & 0x3) << 0; }
public sealed override int EV_ATK { get => EVYield >> 2 & 0x3; set => EVYield = (EVYield & ~(0x3 << 2)) | (value & 0x3) << 2; }
public sealed override int EV_DEF { get => EVYield >> 4 & 0x3; set => EVYield = (EVYield & ~(0x3 << 4)) | (value & 0x3) << 4; }
public sealed override int EV_SPE { get => EVYield >> 6 & 0x3; set => EVYield = (EVYield & ~(0x3 << 6)) | (value & 0x3) << 6; }
public sealed override int EV_SPA { get => EVYield >> 8 & 0x3; set => EVYield = (EVYield & ~(0x3 << 8)) | (value & 0x3) << 8; }
public sealed override int EV_SPD { get => EVYield >> 10 & 0x3; set => EVYield = (EVYield & ~(0x3 << 10)) | (value & 0x3) << 10; }
public bool Telekenesis { get => (EVYield >> 12 & 1) == 1; set => EVYield = (EVYield & ~(0x1 << 12)) | (value ? 1 : 0) << 12; }
public int Item1 { get => BitConverter.ToInt16(Data, 0x0C); set => BitConverter.GetBytes((short)value).CopyTo(Data, 0x0C); }
public int Item2 { get => BitConverter.ToInt16(Data, 0x0E); set => BitConverter.GetBytes((short)value).CopyTo(Data, 0x0E); }
public int Item3 { get => BitConverter.ToInt16(Data, 0x10); set => BitConverter.GetBytes((short)value).CopyTo(Data, 0x10); }
public override int Gender { get => Data[0x12]; set => Data[0x12] = (byte)value; }
public override int HatchCycles { get => Data[0x13]; set => Data[0x13] = (byte)value; }
public override int BaseFriendship { get => Data[0x14]; set => Data[0x14] = (byte)value; }
public override int EXPGrowth { get => Data[0x15]; set => Data[0x15] = (byte)value; }
public override int EggGroup1 { get => Data[0x16]; set => Data[0x16] = (byte)value; }
public override int EggGroup2 { get => Data[0x17]; set => Data[0x17] = (byte)value; }
public sealed override int Gender { get => Data[0x12]; set => Data[0x12] = (byte)value; }
public sealed override int HatchCycles { get => Data[0x13]; set => Data[0x13] = (byte)value; }
public sealed override int BaseFriendship { get => Data[0x14]; set => Data[0x14] = (byte)value; }
public sealed override int EXPGrowth { get => Data[0x15]; set => Data[0x15] = (byte)value; }
public sealed override int EggGroup1 { get => Data[0x16]; set => Data[0x16] = (byte)value; }
public sealed override int EggGroup2 { get => Data[0x17]; set => Data[0x17] = (byte)value; }
public int Ability1 { get => Data[0x18]; set => Data[0x18] = (byte)value; }
public int Ability2 { get => Data[0x19]; set => Data[0x19] = (byte)value; }
public int AbilityH { get => Data[0x1A]; set => Data[0x1A] = (byte)value; }
public override int EscapeRate { get => Data[0x1B]; set => Data[0x1B] = (byte)value; }
public sealed override int EscapeRate { get => Data[0x1B]; set => Data[0x1B] = (byte)value; }
protected internal override int FormStatsIndex { get => BitConverter.ToUInt16(Data, 0x1C); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1C); }
public override int FormeSprite { get => BitConverter.ToUInt16(Data, 0x1E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1E); }
public override int FormeCount { get => Data[0x20]; set => Data[0x20] = (byte)value; }
public override int Color { get => Data[0x21] & 0x3F; set => Data[0x21] = (byte)((Data[0x21] & 0xC0) | (value & 0x3F)); }
public sealed override int FormeSprite { get => BitConverter.ToUInt16(Data, 0x1E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1E); }
public sealed override int FormeCount { get => Data[0x20]; set => Data[0x20] = (byte)value; }
public sealed override int Color { get => Data[0x21] & 0x3F; set => Data[0x21] = (byte)((Data[0x21] & 0xC0) | (value & 0x3F)); }
public bool SpriteFlip { get => ((Data[0x21] >> 6) & 1) == 1; set => Data[0x21] = (byte)((Data[0x21] & ~0x40) | (value ? 0x40 : 0)); }
public bool SpriteForme { get => ((Data[0x21] >> 7) & 1) == 1; set => Data[0x21] = (byte)((Data[0x21] & ~0x80) | (value ? 0x80 : 0)); }
public override int BaseEXP { get => BitConverter.ToUInt16(Data, 0x22); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x22); }
public override int Height { get => BitConverter.ToUInt16(Data, 0x24); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x24); }
public override int Weight { get => BitConverter.ToUInt16(Data, 0x26); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x26); }
public sealed override int BaseEXP { get => BitConverter.ToUInt16(Data, 0x22); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x22); }
public sealed override int Height { get => BitConverter.ToUInt16(Data, 0x24); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x24); }
public sealed override int Weight { get => BitConverter.ToUInt16(Data, 0x26); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x26); }
public override IReadOnlyList<int> Items
public sealed override IReadOnlyList<int> Items
{
get => new[] { Item1, Item2, Item3 };
set
@@ -79,7 +79,7 @@ public override IReadOnlyList<int> Items
}
}
public override IReadOnlyList<int> Abilities
public sealed override IReadOnlyList<int> Abilities
{
get => new[] { Ability1, Ability2, AbilityH };
set
@@ -91,7 +91,7 @@ public override IReadOnlyList<int> Abilities
}
}
public override int GetAbilityIndex(int abilityID) => abilityID == Ability1 ? 0 : abilityID == Ability2 ? 1 : abilityID == AbilityH ? 2 : -1;
public sealed override int GetAbilityIndex(int abilityID) => abilityID == Ability1 ? 0 : abilityID == Ability2 ? 1 : abilityID == AbilityH ? 2 : -1;
public bool HasHiddenAbility => AbilityH != Ability1;
}

View File

@@ -16,38 +16,38 @@ public PersonalInfoG3(byte[] data) : base(data)
public override byte[] Write() => Data;
public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; }
public override int ATK { get => Data[0x01]; set => Data[0x01] = (byte)value; }
public override int DEF { get => Data[0x02]; set => Data[0x02] = (byte)value; }
public override int SPE { get => Data[0x03]; set => Data[0x03] = (byte)value; }
public override int SPA { get => Data[0x04]; set => Data[0x04] = (byte)value; }
public override int SPD { get => Data[0x05]; set => Data[0x05] = (byte)value; }
public override int Type1 { get => Data[0x06]; set => Data[0x06] = (byte)value; }
public override int Type2 { get => Data[0x07]; set => Data[0x07] = (byte)value; }
public override int CatchRate { get => Data[0x08]; set => Data[0x08] = (byte)value; }
public override int BaseEXP { get => Data[0x09]; set => Data[0x09] = (byte)value; }
public sealed override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; }
public sealed override int ATK { get => Data[0x01]; set => Data[0x01] = (byte)value; }
public sealed override int DEF { get => Data[0x02]; set => Data[0x02] = (byte)value; }
public sealed override int SPE { get => Data[0x03]; set => Data[0x03] = (byte)value; }
public sealed override int SPA { get => Data[0x04]; set => Data[0x04] = (byte)value; }
public sealed override int SPD { get => Data[0x05]; set => Data[0x05] = (byte)value; }
public sealed override int Type1 { get => Data[0x06]; set => Data[0x06] = (byte)value; }
public sealed override int Type2 { get => Data[0x07]; set => Data[0x07] = (byte)value; }
public sealed override int CatchRate { get => Data[0x08]; set => Data[0x08] = (byte)value; }
public sealed override int BaseEXP { get => Data[0x09]; set => Data[0x09] = (byte)value; }
private int EVYield { get => BitConverter.ToUInt16(Data, 0x0A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); }
public override int EV_HP { get => EVYield >> 0 & 0x3; set => EVYield = (EVYield & ~(0x3 << 0)) | (value & 0x3) << 0; }
public override int EV_ATK { get => EVYield >> 2 & 0x3; set => EVYield = (EVYield & ~(0x3 << 2)) | (value & 0x3) << 2; }
public override int EV_DEF { get => EVYield >> 4 & 0x3; set => EVYield = (EVYield & ~(0x3 << 4)) | (value & 0x3) << 4; }
public override int EV_SPE { get => EVYield >> 6 & 0x3; set => EVYield = (EVYield & ~(0x3 << 6)) | (value & 0x3) << 6; }
public override int EV_SPA { get => EVYield >> 8 & 0x3; set => EVYield = (EVYield & ~(0x3 << 8)) | (value & 0x3) << 8; }
public override int EV_SPD { get => EVYield >> 10 & 0x3; set => EVYield = (EVYield & ~(0x3 << 10)) | (value & 0x3) << 10; }
public sealed override int EV_HP { get => EVYield >> 0 & 0x3; set => EVYield = (EVYield & ~(0x3 << 0)) | (value & 0x3) << 0; }
public sealed override int EV_ATK { get => EVYield >> 2 & 0x3; set => EVYield = (EVYield & ~(0x3 << 2)) | (value & 0x3) << 2; }
public sealed override int EV_DEF { get => EVYield >> 4 & 0x3; set => EVYield = (EVYield & ~(0x3 << 4)) | (value & 0x3) << 4; }
public sealed override int EV_SPE { get => EVYield >> 6 & 0x3; set => EVYield = (EVYield & ~(0x3 << 6)) | (value & 0x3) << 6; }
public sealed override int EV_SPA { get => EVYield >> 8 & 0x3; set => EVYield = (EVYield & ~(0x3 << 8)) | (value & 0x3) << 8; }
public sealed override int EV_SPD { get => EVYield >> 10 & 0x3; set => EVYield = (EVYield & ~(0x3 << 10)) | (value & 0x3) << 10; }
public int Item1 { get => BitConverter.ToInt16(Data, 0xC); set => BitConverter.GetBytes((short)value).CopyTo(Data, 0xC); }
public int Item2 { get => BitConverter.ToInt16(Data, 0xE); set => BitConverter.GetBytes((short)value).CopyTo(Data, 0xE); }
public override int Gender { get => Data[0x10]; set => Data[0x10] = (byte)value; }
public override int HatchCycles { get => Data[0x11]; set => Data[0x11] = (byte)value; }
public override int BaseFriendship { get => Data[0x12]; set => Data[0x12] = (byte)value; }
public override int EXPGrowth { get => Data[0x13]; set => Data[0x13] = (byte)value; }
public override int EggGroup1 { get => Data[0x14]; set => Data[0x14] = (byte)value; }
public override int EggGroup2 { get => Data[0x15]; set => Data[0x15] = (byte)value; }
public sealed override int Gender { get => Data[0x10]; set => Data[0x10] = (byte)value; }
public sealed override int HatchCycles { get => Data[0x11]; set => Data[0x11] = (byte)value; }
public sealed override int BaseFriendship { get => Data[0x12]; set => Data[0x12] = (byte)value; }
public sealed override int EXPGrowth { get => Data[0x13]; set => Data[0x13] = (byte)value; }
public sealed override int EggGroup1 { get => Data[0x14]; set => Data[0x14] = (byte)value; }
public sealed override int EggGroup2 { get => Data[0x15]; set => Data[0x15] = (byte)value; }
public int Ability1 { get => Data[0x16]; set => Data[0x16] = (byte)value; }
public int Ability2 { get => Data[0x17]; set => Data[0x17] = (byte)value; }
public override int EscapeRate { get => Data[0x18]; set => Data[0x18] = (byte)value; }
public override int Color { get => Data[0x19] & 0x7F; set => Data[0x19] = (byte)((Data[0x19] & 0x80) | value); }
public sealed override int EscapeRate { get => Data[0x18]; set => Data[0x18] = (byte)value; }
public sealed override int Color { get => Data[0x19] & 0x7F; set => Data[0x19] = (byte)((Data[0x19] & 0x80) | value); }
public bool NoFlip { get => Data[0x19] >> 7 == 1; set => Data[0x19] = (byte)(Color | (value ? 0x80 : 0)); }
public override IReadOnlyList<int> Items
public sealed override IReadOnlyList<int> Items
{
get => new[] { Item1, Item2 };
set
@@ -58,7 +58,7 @@ public override IReadOnlyList<int> Items
}
}
public override IReadOnlyList<int> Abilities
public sealed override IReadOnlyList<int> Abilities
{
get => new[] { Ability1, Ability2 };
set
@@ -69,7 +69,7 @@ public override IReadOnlyList<int> Abilities
}
}
public override int GetAbilityIndex(int abilityID) => abilityID == Ability1 ? 0 : abilityID == Ability2 ? 1 : -1;
public sealed override int GetAbilityIndex(int abilityID) => abilityID == Ability1 ? 0 : abilityID == Ability2 ? 1 : -1;
public bool HasSecondAbility => Ability1 != Ability2;
}

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
public class SaveBlockAccessor5B2W2 : ISaveBlockAccessor<BlockInfoNDS>, ISaveBlock5BW, ISaveBlock5B2W2
public sealed class SaveBlockAccessor5B2W2 : ISaveBlockAccessor<BlockInfoNDS>, ISaveBlock5BW, ISaveBlock5B2W2
{
public static readonly BlockInfoNDS[] BlocksB2W2 =
{

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
public class SaveBlockAccessor5BW : ISaveBlockAccessor<BlockInfoNDS>, ISaveBlock5BW
public sealed class SaveBlockAccessor5BW : ISaveBlockAccessor<BlockInfoNDS>, ISaveBlock5BW
{
// Offset, Length, chkOffset, ChkMirror
public static readonly BlockInfoNDS[] BlocksBW =

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
public class SaveBlockAccessor6AO : ISaveBlockAccessor<BlockInfo6>, ISaveBlock6Main
public sealed class SaveBlockAccessor6AO : ISaveBlockAccessor<BlockInfo6>, ISaveBlock6Main
{
public const int boAO = SaveUtil.SIZE_G6ORAS - 0x200;

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
public class SaveBlockAccessor6AODemo : ISaveBlockAccessor<BlockInfo6>, ISaveBlock6Core
public sealed class SaveBlockAccessor6AODemo : ISaveBlockAccessor<BlockInfo6>, ISaveBlock6Core
{
public const int boAOdemo = SaveUtil.SIZE_G6ORASDEMO - 0x200;

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
public class SaveBlockAccessor6XY : ISaveBlockAccessor<BlockInfo6>, ISaveBlock6XY
public sealed class SaveBlockAccessor6XY : ISaveBlockAccessor<BlockInfo6>, ISaveBlock6XY
{
public const int boXY = SaveUtil.SIZE_G6XY - 0x200;

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
public class SaveBlockAccessor7b : ISaveBlockAccessor<BlockInfo7b>
public sealed class SaveBlockAccessor7b : ISaveBlockAccessor<BlockInfo7b>
{
private const int boGG = 0xB8800 - 0x200; // nowhere near 1MB (savedata.bin size)

View File

@@ -5,7 +5,7 @@
namespace PKHeX.Core
{
public class SaveBlockAccessor8SWSH : SCBlockAccessor, ISaveBlock8Main
public sealed class SaveBlockAccessor8SWSH : SCBlockAccessor, ISaveBlock8Main
{
public override IReadOnlyList<SCBlock> BlockInfo { get; }
public Box8 BoxInfo { get; }

View File

@@ -4,7 +4,7 @@
namespace PKHeX.WinForms
{
public class SaveBlockMetadata<T>
public sealed class SaveBlockMetadata<T>
{
private readonly Dictionary<SaveBlock, string> BlockList;

View File

@@ -3,7 +3,7 @@
namespace PKHeX.Core
{
public class SCBlockCompare
public sealed class SCBlockCompare
{
private readonly List<string> AddedKeys = new List<string>();
private readonly List<string> RemovedKeys = new List<string>();

View File

@@ -10,7 +10,7 @@ namespace PKHeX.Core
/// <summary>
/// Provides reflection utility for manipulating blocks, providing block names and value wrapping.
/// </summary>
public class SCBlockMetadata
public sealed class SCBlockMetadata
{
private readonly Dictionary<SaveBlock, string> BlockList;
private readonly Dictionary<uint, string> ValueList;
@@ -128,7 +128,7 @@ private string GetBlockHint(SCBlock z, int i)
};
}
private class WrappedValueView<T> where T : struct
private sealed class WrappedValueView<T> where T : struct
{
private readonly SCBlock Parent;
private T _value;

View File

@@ -24,40 +24,40 @@ protected BulkStorage(byte[] data, Type t, int start, int slotsPerBox = 30) : ba
protected override string BAKText => $"{Checksums.CRC16(Data, Box, Data.Length - Box):X4}";
public override string Filter { get; } = "All Files|*.*";
public override string Extension { get; } = ".bin";
public override bool ChecksumsValid { get; } = true;
public override string ChecksumInfo { get; } = "No Info.";
public sealed override bool ChecksumsValid { get; } = true;
public sealed override string ChecksumInfo { get; } = "No Info.";
private readonly PKM blank;
public override Type PKMType => blank.GetType();
public override PKM BlankPKM => blank.Clone();
public sealed override Type PKMType => blank.GetType();
public sealed override PKM BlankPKM => blank.Clone();
protected override PKM GetPKM(byte[] data) => PKMConverter.GetPKMfromBytes(data, prefer: Generation) ?? blank;
protected override byte[] DecryptPKM(byte[] data) => GetPKM(data).Data;
protected override int SIZE_STORED => blank.SIZE_STORED;
protected override int SIZE_PARTY => blank.SIZE_PARTY;
public override int MaxEV => blank.MaxEV;
public override int Generation => blank.Format;
public override int MaxMoveID => blank.MaxMoveID;
public override int MaxSpeciesID => blank.MaxSpeciesID;
public override int MaxAbilityID => blank.MaxAbilityID;
public override int MaxItemID => blank.MaxItemID;
public override int MaxBallID => blank.MaxBallID;
public override int MaxGameID => blank.MaxGameID;
public override int OTLength => blank.OTLength;
public override int NickLength => blank.NickLength;
public sealed override int MaxEV => blank.MaxEV;
public sealed override int Generation => blank.Format;
public sealed override int MaxMoveID => blank.MaxMoveID;
public sealed override int MaxSpeciesID => blank.MaxSpeciesID;
public sealed override int MaxAbilityID => blank.MaxAbilityID;
public sealed override int MaxItemID => blank.MaxItemID;
public sealed override int MaxBallID => blank.MaxBallID;
public sealed override int MaxGameID => blank.MaxGameID;
public sealed override int OTLength => blank.OTLength;
public sealed override int NickLength => blank.NickLength;
public bool IsBigEndian => blank is BK4 || blank is XK3 || blank is CK3;
private readonly Func<byte[], int, bool> GetIsPKMPresent;
public override bool IsPKMPresent(byte[] data, int offset) => GetIsPKMPresent(data, offset);
public sealed override bool IsPKMPresent(byte[] data, int offset) => GetIsPKMPresent(data, offset);
public override int BoxCount { get; }
protected override void SetChecksums() { }
public override int GetBoxOffset(int box) => Box + (box * (SlotsPerBox * SIZE_STORED));
public override string GetBoxName(int box) => $"Box {box + 1:d2}";
public override void SetBoxName(int box, string value) { }
public override int GetPartyOffset(int slot) => int.MinValue;
public sealed override void SetBoxName(int box, string value) { }
public sealed override int GetPartyOffset(int slot) => int.MinValue;
public override string GetString(byte[] data, int offset, int length)
=> StringConverter.GetString(data, Generation, blank.Japanese, IsBigEndian, length, offset);

View File

@@ -1,6 +1,6 @@
namespace PKHeX.Core
{
internal class SAV1Offsets
internal sealed class SAV1Offsets
{
public static readonly SAV1Offsets INT = GetINT();
public static readonly SAV1Offsets JPN = GetJPN();

View File

@@ -2,7 +2,7 @@
namespace PKHeX.Core
{
internal class SAV2Offsets
internal sealed class SAV2Offsets
{
public SAV2Offsets(SAV2 sav)
{

View File

@@ -1,6 +1,6 @@
namespace PKHeX.Core
{
public class Fashion6XY : SaveBlock
public sealed class Fashion6XY : SaveBlock
{
public Fashion6XY(SAV6XY sav, int offset) : base(sav) => Offset = offset;

View File

@@ -0,0 +1,13 @@
using System;
namespace PKHeX.Core
{
public sealed class MaisonBlock : SaveBlock
{
public MaisonBlock(SAV6XY sav, int offset) : base(sav) => Offset = offset;
public MaisonBlock(SAV6AO sav, int offset) : base(sav) => Offset = offset;
public ushort GetMaisonStat(int index) { return BitConverter.ToUInt16(Data, Offset + 0x1C0 + (2 * index)); }
public void SetMaisonStat(int index, ushort value) { BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x1C0 + (2 * index)); }
}
}

View File

@@ -2,16 +2,7 @@
namespace PKHeX.Core
{
public class MaisonBlock : SaveBlock
{
public MaisonBlock(SAV6XY sav, int offset) : base(sav) => Offset = offset;
public MaisonBlock(SAV6AO sav, int offset) : base(sav) => Offset = offset;
public ushort GetMaisonStat(int index) { return BitConverter.ToUInt16(Data, Offset + 0x1C0 + (2 * index)); }
public void SetMaisonStat(int index, ushort value) { BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x1C0 + (2 * index)); }
}
public class SuperTrainBlock : SaveBlock
public sealed class SuperTrainBlock : SaveBlock
{
public SuperTrainBlock(SAV6XY sav, int offset) : base(sav) => Offset = offset;
public SuperTrainBlock(SAV6AO sav, int offset) : base(sav) => Offset = offset;
@@ -291,7 +282,7 @@ public void UnlockAllStages(bool dist)
public void ClearBlock() => Array.Clear(Data, Offset, 0x318);
}
public class SuperTrainingSpeciesRecord
public sealed class SuperTrainingSpeciesRecord
{
private readonly byte[] Data;
private readonly int Offset;
@@ -346,4 +337,4 @@ public void LoadFrom(PKM pkm)
Gender = (byte)pkm.Gender;
}
}
}
}

View File

@@ -96,7 +96,7 @@ public BattleTreeTrainer[] ScoutedTrainers
}
[TypeConverter(typeof(ValueTypeTypeConverter))]
public class BattleTreeTrainer
public sealed class BattleTreeTrainer
{
public short ID { get; set; }
public BattleTreePokemon Poke1 { get; set; }
@@ -113,7 +113,7 @@ public BattleTreeTrainer(short id, BattleTreePokemon poke1, BattleTreePokemon po
}
[TypeConverter(typeof(ValueTypeTypeConverter))]
public class BattleTreePokemon
public sealed class BattleTreePokemon
{
public short ID { get; set; }
public sbyte AbilityIndex { get; set; }

View File

@@ -50,7 +50,7 @@ public string[] DumpAll()
}
}
public class RaidSpawnDetail
public sealed class RaidSpawnDetail
{
public const int SIZE = 0x18;
@@ -210,33 +210,4 @@ public enum RaidType : byte
Event = 5,
DynamaxCrystal = 6,
}
public class TypeConverterU64 : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string) && value is ulong)
return $"{value:X16}"; // no 0x prefix
return base.ConvertTo(context, culture, value, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (!(value is string input))
return base.ConvertFrom(context, culture, value);
if (input.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
input = input.Substring(2);
return ulong.TryParse(input, System.Globalization.NumberStyles.HexNumber, culture, out var result) ? result : 0ul;
}
}
}

View File

@@ -32,7 +32,7 @@ public void LoadTeamData(IList<PKM> party)
}
}
public class TitleScreen8Poke
public sealed class TitleScreen8Poke
{
public const int SIZE = 0x28;
private readonly byte[] Data;

View File

@@ -266,7 +266,7 @@ public uint TimestampPrinted
}
}
public class TrainerCard8Poke
public sealed class TrainerCard8Poke
{
public const int SIZE = 0x1C;
private readonly byte[] Data;

View File

@@ -25,7 +25,7 @@ public MysteryGiftAlbum(DataMysteryGift[] gifts, bool[] flags)
}
}
public class EncryptedMysteryGiftAlbum : MysteryGiftAlbum
public sealed class EncryptedMysteryGiftAlbum : MysteryGiftAlbum
{
/// <summary>
/// Encryption Seed (only used in Generation 5 to encrypt the stored data)

View File

@@ -3,7 +3,7 @@
namespace PKHeX.Core
{
internal class OPowerFlagSet
internal sealed class OPowerFlagSet
{
public readonly OPower6Type Identifier;
public readonly int Count;

View File

@@ -4,6 +4,9 @@
namespace PKHeX.Core
{
/// <summary>
/// Generation 7 Dex manipulator
/// </summary>
public class Zukan7 : Zukan
{
private const int MAGIC = 0x2F120F17;
@@ -12,12 +15,12 @@ public class Zukan7 : Zukan
private const int SIZE_MISC = 0x80; // Misc Data (1024 bits)
private const int SIZE_CAUGHT = 0x68; // 832 bits
protected override int OFS_CAUGHT => SIZE_MAGIC + SIZE_FLAGS + SIZE_MISC;
protected override int OFS_SEEN => OFS_CAUGHT + SIZE_CAUGHT;
protected sealed override int OFS_CAUGHT => SIZE_MAGIC + SIZE_FLAGS + SIZE_MISC;
protected sealed override int OFS_SEEN => OFS_CAUGHT + SIZE_CAUGHT;
protected override int BitSeenSize => 0x8C; // 1120 bits
protected override int DexLangFlagByteCount => 920; // 0x398 = 817*9, top off the savedata block.
protected override int DexLangIDCount => 9; // CHT, skipping langID 6 (unused)
protected sealed override int BitSeenSize => 0x8C; // 1120 bits
protected sealed override int DexLangFlagByteCount => 920; // 0x398 = 817*9, top off the savedata block.
protected sealed override int DexLangIDCount => 9; // CHT, skipping langID 6 (unused)
private readonly IList<int> FormBaseSpecies;
@@ -34,7 +37,7 @@ private Zukan7(SaveFile sav, int dex, int langflag, Func<int, int, int, int> for
public Func<int, int, int, int> DexFormIndexFetcher { get; }
protected override void SetAllDexSeenFlags(int baseBit, int altform, int gender, bool isShiny, bool value = true)
protected sealed override void SetAllDexSeenFlags(int baseBit, int altform, int gender, bool isShiny, bool value = true)
{
int species = baseBit + 1;
@@ -123,7 +126,7 @@ public static bool SanitizeFormsToIterate(int species, out int formStart, out in
return true;
}
protected override int GetDexLangFlag(int lang)
protected sealed override int GetDexLangFlag(int lang)
{
if (lang > 10 || lang == 6 || lang <= 0)
return -1; // invalid language
@@ -134,7 +137,7 @@ protected override int GetDexLangFlag(int lang)
return lang;
}
protected override void SetSpindaDexData(PKM pkm, bool alreadySeen)
protected sealed override void SetSpindaDexData(PKM pkm, bool alreadySeen)
{
int shift = (pkm.Gender & 1) | (pkm.IsShiny ? 2 : 0);
if (alreadySeen) // update?
@@ -259,7 +262,7 @@ public int GetBaseSpecies(int index)
return FormBaseSpecies[index - SAV.MaxSpeciesID - 1];
}
protected override void SetAllDexFlagsLanguage(int bit, int lang, bool value = true)
protected sealed override void SetAllDexFlagsLanguage(int bit, int lang, bool value = true)
{
lang = GetDexLangFlag(lang);
if (lang < 0)

View File

@@ -5,20 +5,8 @@ namespace PKHeX.Core
/// <summary>
/// Beluga specific Dex manipulator, slightly modified from Gen7.
/// </summary>
public class Zukan7b : Zukan7
public sealed class Zukan7b : Zukan7
{
private const int SIZE_MAGIC = 4; // 0x2F120F17 magic
private const int SIZE_FLAGS = 4;
private const int SIZE_MISC = 0x80; // Misc Data (1024 bits)
private const int SIZE_CAUGHT = 0x68; // 832 bits
protected override int OFS_CAUGHT => SIZE_MAGIC + SIZE_FLAGS + SIZE_MISC;
protected override int OFS_SEEN => OFS_CAUGHT + SIZE_CAUGHT;
protected override int BitSeenSize => 0x8C; // 1120 bits
protected override int DexLangFlagByteCount => 920; // 0x398 = 817*9, top off the savedata block.
protected override int DexLangIDCount => 9; // CHT, skipping langID 6 (unused)
public Zukan7b(SAV7b sav, int dex, int langflag) : base(sav, dex, langflag)
{
}

View File

@@ -4,7 +4,7 @@
namespace PKHeX.Core
{
// I wish I could replace this with raw pointers via Span :)
public class Zukan8 : ZukanBase
public sealed class Zukan8 : ZukanBase
{
private readonly SCBlock Galar;
private readonly SCBlock Rigel1;
@@ -781,7 +781,7 @@ public string GetEntryName(IReadOnlyList<string> speciesNames, int species)
public static bool operator !=(Zukan8Index left, Zukan8Index right) => !(left == right);
}
public class Zukan8EntryInfo
public sealed class Zukan8EntryInfo
{
public readonly int Species;
public readonly Zukan8Index Entry;

View File

@@ -7,7 +7,7 @@ namespace PKHeX.Core
/// <summary>
/// Used for allowing a struct to be mutated in a PropertyGrid.
/// </summary>
public class ValueTypeTypeConverter : ExpandableObjectConverter
public sealed class ValueTypeTypeConverter : ExpandableObjectConverter
{
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) => true;
@@ -23,4 +23,33 @@ public override object CreateInstance(ITypeDescriptorContext context, IDictionar
return boxed;
}
}
public sealed class TypeConverterU64 : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string) && value is ulong)
return $"{value:X16}"; // no 0x prefix
return base.ConvertTo(context, culture, value, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (!(value is string input))
return base.ConvertFrom(context, culture, value);
if (input.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
input = input.Substring(2);
return ulong.TryParse(input, System.Globalization.NumberStyles.HexNumber, culture, out var result) ? result : 0ul;
}
}
}

View File

@@ -172,7 +172,7 @@ private Image LayerOverImageEggAsItem(Image baseImage, int species)
/// <summary>
/// 30 high, 40 wide sprite builder
/// </summary>
public class SpriteBuilder3040 : SpriteBuilder
public sealed class SpriteBuilder3040 : SpriteBuilder
{
public override int Height => 30;
public override int Width => 40;
@@ -196,7 +196,7 @@ public class SpriteBuilder3040 : SpriteBuilder
/// <summary>
/// 56 high, 68 wide sprite builder
/// </summary>
public class SpriteBuilder5668 : SpriteBuilder
public sealed class SpriteBuilder5668 : SpriteBuilder
{
public override int Height => 56;
public override int Width => 68;

View File

@@ -126,7 +126,7 @@ private static PictureBox GetPictureBox(int index)
};
}
private class LabelType : Label
private sealed class LabelType : Label
{
public StorageSlotType Type;
}

View File

@@ -7,7 +7,7 @@ namespace PKHeX.WinForms
/// <summary>
/// Bind-able summary object that can fetch sprite and strings that summarize a <see cref="PKM"/>.
/// </summary>
public class PKMSummaryImage : PKMSummary
public sealed class PKMSummaryImage : PKMSummary
{
public Image Sprite => pkm.Sprite();

View File

@@ -341,7 +341,7 @@ private void B_ClearAll_Click(object sender, EventArgs e)
PrevCountries[i].SelectedValue = 0;
}
private class TextMarkup
private sealed class TextMarkup
{
public string Disabled { get; } = nameof(Disabled);
public string NeverLeft { get; } = "Never left";

View File

@@ -188,7 +188,7 @@ private void ClickSet(object sender, EventArgs e)
return;
}
File.WriteAllBytes(path, pk.Data.Take(pk.SIZE_STORED).ToArray());
File.WriteAllBytes(path, pk.DecryptedBoxData);
pk.Identifier = path;
int pre = RawDB.Count;

View File

@@ -198,7 +198,7 @@ private IEnumerable<IEncounterable> SearchDatabase()
return results;
}
private class ReferenceComparer<T> : IEqualityComparer<T>
private sealed class ReferenceComparer<T> : IEqualityComparer<T>
{
public bool Equals(T x, T y) => RuntimeHelpers.GetHashCode(x).Equals(RuntimeHelpers.GetHashCode(y));
public int GetHashCode(T obj) => RuntimeHelpers.GetHashCode(obj);

View File

@@ -169,7 +169,7 @@ private static IEnumerable<CustomFolderPath> GetSwitchPaths(IEnumerable<string>
return paths.Select(z => new CustomFolderPath(z));
}
private class CustomFolderPath
private sealed class CustomFolderPath
{
public readonly string Path;
public readonly string DisplayText;