Minor clean

Handle remainder of c#9 sugar
Fix some spelling mistakes
This commit is contained in:
Kurt 2020-12-21 23:37:07 -08:00
parent 514b60b447
commit 997e0751f3
80 changed files with 199 additions and 184 deletions

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
public int Offset { get; }
public bool CanWriteTo(SaveFile sav) => false;
public WriteBlockedMessage CanWriteTo(SaveFile sav, PKM pkm) => WriteBlockedMessage.InvalidDestination;
public StorageSlotType Type { get; set; }
public StorageSlotType Type { get; init; }
private readonly byte[] Data; // buffer to r/w

View file

@ -44,7 +44,7 @@ namespace PKHeX.Core
// Some games cannot acquire every Species that exists. Some can only acquire a subset.
return sav switch
{
SAV7b _ => source.SpeciesDataSource // LGPE: Kanto 151, Meltan/Melmetal
SAV7b => source.SpeciesDataSource // LGPE: Kanto 151, Meltan/Melmetal
.Where(s => s.Value <= (int)Core.Species.Mew || s.Value == (int)Core.Species.Meltan || s.Value == (int)Core.Species.Melmetal),
_ => source.SpeciesDataSource.Where(s => s.Value <= sav.MaxSpeciesID)
};
@ -58,7 +58,7 @@ namespace PKHeX.Core
var legal = source.LegalMoveDataSource;
return sav switch
{
SAV7b _ => legal.Where(s => Legal.AllowedMovesGG.Contains((short) s.Value)), // LGPE: Not all moves are available
SAV7b => legal.Where(s => Legal.AllowedMovesGG.Contains((short) s.Value)), // LGPE: Not all moves are available
_ => legal.Where(m => m.Value <= sav.MaxMoveID)
};
}

View file

@ -182,12 +182,12 @@ namespace PKHeX.Core
// E-Reader was only available to Japanese games.
case EncounterStaticShadow {EReader: true}:
// Old Sea Map was only distributed to Japanese games.
case EncounterStatic3 _ when Species == (int)Core.Species.Mew:
case EncounterStatic3 when Species == (int)Core.Species.Mew:
pk.OT_Name = "ゲーフリ";
return (int)LanguageID.Japanese;
// Deoxys for Emerald was not available for Japanese games.
case EncounterStatic3 _ when Species == (int)Core.Species.Deoxys && Version == GameVersion.E && lang == 1:
case EncounterStatic3 when Species == (int)Core.Species.Deoxys && Version == GameVersion.E && lang == 1:
pk.OT_Name = "GF";
return (int)LanguageID.English;

View file

@ -10,15 +10,15 @@ namespace PKHeX.Core
/// <inheritdoc cref="EncounterStatic1"/>
public sealed class EncounterStatic1E : EncounterStatic1, IFixedGBLanguage
{
public EncounterGBLanguage Language { get; set; } = EncounterGBLanguage.Japanese;
public EncounterGBLanguage Language { get; init; } = EncounterGBLanguage.Japanese;
/// <summary> Trainer name for the event. </summary>
public string OT_Name { get; set; } = string.Empty;
public string OT_Name { get; init; } = string.Empty;
public IReadOnlyList<string> OT_Names { get; set; } = Array.Empty<string>();
public IReadOnlyList<string> OT_Names { get; init; } = Array.Empty<string>();
/// <summary> Trainer ID for the event. </summary>
public int TID { get; set; } = -1;
public int TID { get; init; } = -1;
public EncounterStatic1E(int species, int level, GameVersion ver) : base(species, level, ver)
{

View file

@ -10,17 +10,17 @@ namespace PKHeX.Core
/// <inheritdoc cref="EncounterStatic2"/>
public sealed class EncounterStatic2E : EncounterStatic2, IFixedGBLanguage
{
public EncounterGBLanguage Language { get; set; } = EncounterGBLanguage.Japanese;
public EncounterGBLanguage Language { get; init; } = EncounterGBLanguage.Japanese;
/// <summary> Trainer name for the event. </summary>
public string OT_Name { get; set; } = string.Empty;
public string OT_Name { get; init; } = string.Empty;
public IReadOnlyList<string> OT_Names { get; set; } = Array.Empty<string>();
public IReadOnlyList<string> OT_Names { get; init; } = Array.Empty<string>();
/// <summary> Trainer ID for the event. </summary>
public int TID { get; set; } = -1;
public int TID { get; init; } = -1;
public int CurrentLevel { get; set; } = -1;
public int CurrentLevel { get; init; } = -1;
public EncounterStatic2E(int species, int level, GameVersion ver) : base(species, level, ver)
{

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
public sealed class EncounterStatic3 : EncounterStatic
{
public override int Generation => 3;
public bool Roaming { get; set; }
public bool Roaming { get; init; }
public EncounterStatic3(int species, int level, GameVersion game)
{

View file

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

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
{
public override int Generation => 6;
internal IReadOnlyList<int> Contest { set => this.SetContestStats(value); }
internal IReadOnlyList<int> Contest { init => this.SetContestStats(value); }
public int CNT_Cool { get; set; }
public int CNT_Beauty { get; set; }
public int CNT_Cute { get; set; }

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
public sealed class EncounterStatic7 : EncounterStatic, IRelearn
{
public override int Generation => 7;
public IReadOnlyList<int> Relearn { get; set; } = Array.Empty<int>();
public IReadOnlyList<int> Relearn { get; init; } = Array.Empty<int>();
protected override bool IsMatchLocation(PKM pkm)
{

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
public class EncounterStatic8 : EncounterStatic, IDynamaxLevel, IGigantamax, IRelearn
{
public sealed override int Generation => 8;
public bool ScriptedNoMarks { get; set; }
public bool ScriptedNoMarks { get; init; }
public bool CanGigantamax { get; set; }
public byte DynamaxLevel { get; set; }

View file

@ -28,8 +28,8 @@ namespace PKHeX.Core
public Shiny Shiny { get; init; } = Shiny.Never;
public int Ball { get; init; } = 4;
public int TID { get; internal set; }
public int SID { get; internal set; }
public int TID { get; init; }
public int SID { get; init; }
public int OTGender { get; init; } = -1;
public GameVersion Version { get; set; } = GameVersion.Any;
@ -42,7 +42,7 @@ namespace PKHeX.Core
public int TID7
{
set
init
{
TID = (ushort) value;
SID = value >> 16;

View file

@ -11,7 +11,7 @@ namespace PKHeX.Core
/// </summary>
public readonly uint PID;
internal IReadOnlyList<int> Contest { set => this.SetContestStats(value); }
internal IReadOnlyList<int> Contest { init => this.SetContestStats(value); }
public int CNT_Cool { get; set; }
public int CNT_Beauty { get; set; }
public int CNT_Cute { get; set; }

View file

@ -17,7 +17,7 @@ namespace PKHeX.Core
Shiny = Shiny.FixedValue;
}
internal IReadOnlyList<int> Contest { set => this.SetContestStats(value); }
internal IReadOnlyList<int> Contest { init => this.SetContestStats(value); }
public int CNT_Cool { get; set; }
public int CNT_Beauty { get; set; }
public int CNT_Cute { get; set; }

View file

@ -3,23 +3,23 @@
/// <summary>
/// Object that can be fed to a <see cref="IEncounterable"/> converter to ensure that the resulting <see cref="PKM"/> meets rough specifications.
/// </summary>
public sealed class EncounterCriteria
public sealed record EncounterCriteria
{
public static readonly EncounterCriteria Unrestricted = new();
public int Ability { get; set; } = -1;
public int Gender { get; set; } = -1;
public Nature Nature { get; set; } = Nature.Random;
public Shiny Shiny { get; set; } = Shiny.Random;
public int Ability { get; init; } = -1;
public int Gender { get; init; } = -1;
public Nature Nature { get; init; } = Nature.Random;
public Shiny Shiny { get; init; } = Shiny.Random;
public int IV_HP { get; set; } = RandomIV;
public int IV_ATK { get; set; } = RandomIV;
public int IV_DEF { get; set; } = RandomIV;
public int IV_SPA { get; set; } = RandomIV;
public int IV_SPD { get; set; } = RandomIV;
public int IV_SPE { get; set; } = RandomIV;
public int IV_HP { get; init; } = RandomIV;
public int IV_ATK { get; init; } = RandomIV;
public int IV_DEF { get; init; } = RandomIV;
public int IV_SPA { get; init; } = RandomIV;
public int IV_SPD { get; init; } = RandomIV;
public int IV_SPE { get; init; } = RandomIV;
public int HPType { get; set; } = -1;
public int HPType { get; init; } = -1;
private const int RandomIV = -1;

View file

@ -149,10 +149,10 @@ namespace PKHeX.Core
return Encounter switch
{
EncounterTrade1 t1 when t1.IsMatchDeferred(pkm) => GBEncounterPriority.Least,
EncounterTrade1 _ => GBEncounterPriority.TradeEncounterG1,
EncounterTrade2 _ => GBEncounterPriority.TradeEncounterG2,
EncounterStatic _ => GBEncounterPriority.StaticEncounter,
EncounterSlot _ => GBEncounterPriority.WildEncounter,
EncounterTrade1 => GBEncounterPriority.TradeEncounterG1,
EncounterTrade2 => GBEncounterPriority.TradeEncounterG2,
EncounterStatic => GBEncounterPriority.StaticEncounter,
EncounterSlot => GBEncounterPriority.WildEncounter,
_ => GBEncounterPriority.EggEncounter
};
}

View file

@ -45,7 +45,7 @@ namespace PKHeX.Core
return EncounterMatch switch
{
EncounterSlot1 _ => new CheckResult(Severity.Valid, LEncCondition, CheckIdentifier.Encounter),
EncounterSlot1 => new CheckResult(Severity.Valid, LEncCondition, CheckIdentifier.Encounter),
EncounterSlot2 s2 => VerifyWildEncounterGen2(pkm, s2),
EncounterStatic s => VerifyEncounterStatic(pkm, s),
EncounterTrade t => VerifyEncounterTrade(pkm, t),

View file

@ -436,8 +436,8 @@ namespace PKHeX.Core
public static string LTransferMet { get; set; } = "Invalid Met Location, expected Poké Transfer or Crown.";
public static string LTransferMetLocation { get; set; } = "Invalid Transfer Met Location.";
public static string LTransferMove { get; set; } = "Incompatible transfer move.";
public static string LTransferMoveG4HM { get; set; } = "Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5.";
public static string LTransferMoveHM { get; set; } = "Generation {0} HM. Should have been removed before transfered to Generation {1}.";
public static string LTransferMoveG4HM { get; set; } = "Defog and Whirlpool. One of the two moves should have been removed before transferred to Generation 5.";
public static string LTransferMoveHM { get; set; } = "Generation {0} HM. Should have been removed before transferred to Generation {1}.";
public static string LTransferNature { get; set; } = "Invalid Nature for transfer Experience.";
public static string LTransferOriginFInvalid0_1 { get; set; } = "{0} origin cannot exist in the currently loaded ({1}) savegame.";
public static string LTransferPIDECBitFlip { get; set; } = "PID should be equal to EC [with top bit flipped]!";

View file

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

View file

@ -826,7 +826,7 @@ namespace PKHeX.Core
return true;
// forced shiny eggs, when hatched, can lose their detectable correlation.
return g.IsEgg && !pkm.IsEgg && val == PIDType.None && (g.Method == PIDType.BACD_R_S || g.Method == PIDType.BACD_U_S);
case EncounterStaticShadow _:
case EncounterStaticShadow:
return pkm.Version == (int)GameVersion.CXD && (val == PIDType.CXD || val == PIDType.CXDAnti);
case EncounterStatic3 s:
switch (pkm.Version)
@ -886,7 +886,7 @@ namespace PKHeX.Core
var ver = (GameVersion)pkm.Version;
var IsDPPt = ver == GameVersion.D || ver == GameVersion.P || ver == GameVersion.Pt;
return pkm.IsShiny && IsDPPt && sl.TypeEncounter == EncounterType.TallGrass && !Locations.IsSafariZoneLocation4(sl.Location);
case PGT _: // manaphy
case PGT: // manaphy
return IsG4ManaphyPIDValid(val, pkm);
case PCD d when d.Gift.PK.PID != 1:
return true; // already matches PCD's fixed PID requirement

View file

@ -34,7 +34,7 @@ namespace PKHeX.Core
return VerifyBallEquals(data, t.Ball);
case EncounterStatic {Gift: true} s:
return VerifyBallEquals(data, s.Ball);
case EncounterSlot8GO _: // Already a strict match
case EncounterSlot8GO: // Already a strict match
return GetResult(true);
}
@ -56,8 +56,8 @@ namespace PKHeX.Core
{
EncounterStatic e => VerifyBallStatic(data, e),
EncounterSlot w => VerifyBallWild(data, w),
EncounterEgg _ => VerifyBallEgg(data),
EncounterInvalid _ => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
EncounterEgg => VerifyBallEgg(data),
EncounterInvalid => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
_ => VerifyBallEquals(data, (int)Poke)
};
}

View file

@ -177,8 +177,8 @@ namespace PKHeX.Core
return true;
return enc switch
{
EncounterTrade _ => false,
EncounterSlot8GO _ => false,
EncounterTrade => false,
EncounterSlot8GO => false,
WC6 wc6 when wc6.OT_Name.Length > 0 => false,
WC7 wc7 when wc7.OT_Name.Length > 0 && wc7.TID != 18075 => false, // Ash Pikachu QR Gift doesn't set Current Handler
WC8 wc8 when wc8.GetHasOT(pkm.Language) => false,

View file

@ -80,13 +80,13 @@ namespace PKHeX.Core
switch (enc)
{
case WC8 _:
case EncounterEgg _:
case EncounterTrade _:
case EncounterStatic8U _:
case EncounterStatic8N _:
case EncounterStatic8ND _:
case EncounterStatic8NC _:
case WC8:
case EncounterEgg:
case EncounterTrade:
case EncounterStatic8U:
case EncounterStatic8N:
case EncounterStatic8ND:
case EncounterStatic8NC:
case EncounterStatic8 s when s.Gift || s.ScriptedNoMarks:
return false;
}

View file

@ -34,7 +34,7 @@ namespace PKHeX.Core
case PK4 pk4 when pk4.PokéathlonStat != 0:
data.AddLine(GetInvalid(LEggPokeathlon, Egg));
break;
case PK3 _ when pkm.Language != 1: // All Eggs are Japanese and flagged specially for localized string
case PK3 when pkm.Language != 1: // All Eggs are Japanese and flagged specially for localized string
data.AddLine(GetInvalid(string.Format(LOTLanguage, LanguageID.Japanese, (LanguageID)pkm.Language), Egg));
break;
}
@ -188,8 +188,8 @@ namespace PKHeX.Core
VerifyFatefulMysteryGift(data, g);
return;
case EncounterStatic {Fateful: true}: // ingame fateful
case EncounterSlot3PokeSpot _: // ingame pokespot
case EncounterTrade4Ranch _: // ranch varied PID
case EncounterSlot3PokeSpot: // ingame pokespot
case EncounterTrade4Ranch: // ranch varied PID
VerifyFatefulIngameActive(data);
return;
}

View file

@ -21,9 +21,9 @@ namespace PKHeX.Core
var pkm = data.pkm;
switch (data.EncounterMatch)
{
case EncounterTrade _:
case EncounterTrade:
case MysteryGift {IsEgg: false}:
case EncounterStatic5N _:
case EncounterStatic5N:
return; // already verified
}

View file

@ -186,7 +186,6 @@ namespace PKHeX.Core
public virtual int BP { get => 0; set { } }
public virtual bool IsBean { get => false; set { } }
public virtual int Bean { get => 0; set { } }
public virtual int BeanCount { get => 0; set { } }
public virtual string CardHeader => (CardID > 0 ? $"Card #: {CardID:0000}" : "N/A") + $" - {CardTitle.Replace('\u3000',' ').Trim()}";

View file

@ -582,8 +582,8 @@ namespace PKHeX.Core
private int GetTradedEggLocation() => Locations.TradedEggLocation(Generation);
public virtual bool IsUntraded => false;
public virtual bool IsNative => Generation == Format;
public virtual bool IsOriginValid => Species <= Legal.GetMaxSpeciesOrigin(Format);
public bool IsNative => Generation == Format;
public bool IsOriginValid => Species <= Legal.GetMaxSpeciesOrigin(Format);
/// <summary>
/// Checks if the <see cref="PKM"/> could inhabit a set of games.

View file

@ -9,29 +9,29 @@ namespace PKHeX.Core.Searching
/// </summary>
public sealed class SearchSettings
{
public int Format { private get; set; }
public int Generation { private get; set; }
public int Species { get; set; } = -1;
public int Ability { private get; set; } = -1;
public int Nature { private get; set; } = -1;
public int Item { private get; set; } = -1;
public int Version { private get; set; } = -1;
public int HiddenPowerType { private get; set; } = -1;
public int Format { private get; init; }
public int Generation { private get; init; }
public int Species { get; init; } = -1;
public int Ability { private get; init; } = -1;
public int Nature { private get; init; } = -1;
public int Item { private get; init; } = -1;
public int Version { private get; init; } = -1;
public int HiddenPowerType { private get; init; } = -1;
public SearchComparison SearchFormat { private get; set; }
public SearchComparison SearchLevel { private get; set; }
public SearchComparison SearchFormat { private get; init; }
public SearchComparison SearchLevel { private get; init; }
public bool? SearchShiny { private get; set; }
public bool? SearchLegal { private get; set; }
public bool? SearchEgg { get; set; }
public int? ESV { private get; set; }
public int? Level { private get; set; }
public int? Level { private get; init; }
public int IVType { private get; set; }
public int EVType { private get; set; }
public int IVType { private get; init; }
public int EVType { private get; init; }
public CloneDetectionMethod SearchClones { private get; set; }
public IList<string> BatchInstructions { private get; set; } = Array.Empty<string>();
public IList<string> BatchInstructions { private get; init; } = Array.Empty<string>();
public readonly List<int> Moves = new();

View file

@ -352,8 +352,8 @@ LTransferHTFlagRequired = Current handler cannot be past gen OT for transferred
LTransferMet = Invalid Met Location, expected Poké Transfer or Crown.
LTransferMetLocation = Invalid Transfer Met Location.
LTransferMove = Incompatible transfer move.
LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}.
LTransferMoveG4HM = Defog and Whirlpool. One of the two moves should have been removed before transferred to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transferred to Generation {1}.
LTransferNature = Invalid Nature for transfer Experience.
LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame.
LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]!

View file

@ -352,8 +352,8 @@ LTransferHTFlagRequired = Current handler cannot be past gen OT for transferred
LTransferMet = Invalid Met Location, expected Poké Transfer or Crown.
LTransferMetLocation = Invalid Transfer Met Location.
LTransferMove = Incompatible transfer move.
LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}.
LTransferMoveG4HM = Defog and Whirlpool. One of the two moves should have been removed before transferred to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transferred to Generation {1}.
LTransferNature = Invalid Nature for transfer Experience.
LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame.
LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]!

View file

@ -352,8 +352,8 @@ LTransferHTFlagRequired = Current handler cannot be past gen OT for transferred
LTransferMet = Invalid Met Location, expected Poké Transfer or Crown.
LTransferMetLocation = Invalid Transfer Met Location.
LTransferMove = Incompatible transfer move.
LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}.
LTransferMoveG4HM = Defog and Whirlpool. One of the two moves should have been removed before transferred to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transferred to Generation {1}.
LTransferNature = Invalid Nature for transfer Experience.
LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame.
LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]!

View file

@ -352,8 +352,8 @@ LTransferHTFlagRequired = Current handler cannot be past gen OT for transferred
LTransferMet = Invalid Met Location, expected Poké Transfer or Crown.
LTransferMetLocation = Invalid Transfer Met Location.
LTransferMove = Incompatible transfer move.
LTransferMoveG4HM = Defog and whirpool. One of the two moves should have been removed before transfered to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transfered to Generation {1}.
LTransferMoveG4HM = Defog and Whirlpool. One of the two moves should have been removed before transferred to Generation 5.
LTransferMoveHM = Generation {0} HM. Should have been removed before transferred to Generation {1}.
LTransferNature = Invalid Nature for transfer Experience.
LTransferOriginFInvalid0_1 = {0} origin cannot exist in the currently loaded ({1}) savegame.
LTransferPIDECBitFlip = PID should be equal to EC [with top bit flipped]!

View file

@ -6,9 +6,9 @@ namespace PKHeX.Core
public abstract class BlockInfo
{
// General
public uint ID { get; set; }
public int Offset { get; set; }
public int Length { get; set; }
public uint ID { get; init; }
public int Offset { get; protected init; }
public int Length { get; init; }
public string Summary => $"{ID:00}: {Offset:X5}-{Offset + Length - 1:X5}, {Length:X5}";

View file

@ -262,7 +262,7 @@ namespace PKHeX.Core
bool header = newHC == oldHC;
bool body = chk.SequenceEqual(checksum);
static string valid(bool s) => s ? "Valid" : "Invalid";
return $"Header Checksum {valid(header)}, Body Checksum {valid(body)}alid.";
return $"Header Checksum {valid(header)}, Body Checksum {valid(body)}.";
}
}

View file

@ -66,8 +66,8 @@ namespace PKHeX.Core
protected int CGearDataOffset;
protected int EntreeForestOffset;
private int AdventureInfo;
public int GTS { get; protected set; } = int.MinValue;
public int Fused { get; protected set; } = int.MinValue;
public int GTS { get; } = int.MinValue;
public int Fused { get; } = int.MinValue;
// Daycare
public override int DaycareSeedSize => Daycare5.DaycareSeedSize;

View file

@ -4,7 +4,7 @@
namespace PKHeX.Core
{
[StructLayout(LayoutKind.Sequential)]
public struct DecorationInventory3
public readonly struct DecorationInventory3
{
public const int SIZE = 150;

View file

@ -61,8 +61,8 @@ namespace PKHeX.Core
protected abstract void SetAllDexFlagsLanguage(int bit, int lang, bool value = true);
protected abstract void SetAllDexSeenFlags(int baseBit, int form, int gender, bool isShiny, bool value = true);
protected virtual bool GetFlag(int ofs, int bitIndex) => SAV.GetFlag(PokeDex + ofs + (bitIndex >> 3), bitIndex);
protected virtual void SetFlag(int ofs, int bitIndex, bool value = true) => SAV.SetFlag(PokeDex + ofs + (bitIndex >> 3), bitIndex, value);
protected bool GetFlag(int ofs, int bitIndex) => SAV.GetFlag(PokeDex + ofs + (bitIndex >> 3), bitIndex);
protected void SetFlag(int ofs, int bitIndex, bool value = true) => SAV.SetFlag(PokeDex + ofs + (bitIndex >> 3), bitIndex, value);
public override bool GetCaught(int species) => GetFlag(OFS_CAUGHT, species - 1);
public virtual void SetCaught(int species, bool value = true) => SetFlag(OFS_CAUGHT, species - 1, value);

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
protected override int BitSeenSize => 0x60;
protected override int DexLangFlagByteCount => 631; // 721 * 7, rounded up
protected override int DexLangIDCount => 7;
protected int SpindaOffset { get; set; }
protected int SpindaOffset { get; init; }
protected Zukan6(SAV6XY sav, int dex, int langflag) : base(sav, dex, langflag)
{

View file

@ -18,7 +18,7 @@ namespace PKHeX.Drawing
public static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y)
{
Bitmap img = new Bitmap(baseLayer);
Bitmap img = new(baseLayer);
using Graphics gr = Graphics.FromImage(img);
gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height);
return img;

View file

@ -71,7 +71,7 @@ namespace PKHeX.Drawing
/// <summary>
/// Species that show their default Species sprite regardless of current <see cref="PKM.Form"/>
/// </summary>
private static readonly HashSet<int> SpeciesDefaultFormSprite = new HashSet<int>
private static readonly HashSet<int> SpeciesDefaultFormSprite = new()
{
(int)Species.Mothim,
(int)Species.Arceus,
@ -88,7 +88,7 @@ namespace PKHeX.Drawing
/// <summary>
/// Species that show a <see cref="PKM.Gender"/> specific Sprite
/// </summary>
private static readonly HashSet<int> SpeciesGenderedSprite = new HashSet<int>
private static readonly HashSet<int> SpeciesGenderedSprite = new()
{
(int)Species.Pikachu,
(int)Species.Hippopotas,

View file

@ -7,8 +7,8 @@ namespace PKHeX.Drawing
{
public static class SpriteUtil
{
public static readonly SpriteBuilder3040 SB17 = new SpriteBuilder3040();
public static readonly SpriteBuilder5668 SB8 = new SpriteBuilder5668();
public static readonly SpriteBuilder3040 SB17 = new();
public static readonly SpriteBuilder5668 SB8 = new();
public static SpriteBuilder Spriter { get; set; } = SB8;
public static Image GetBallSprite(int ball)

View file

@ -6,7 +6,7 @@ namespace PKHeX.WinForms.Controls
{
public partial class CatchRate : UserControl
{
private PK1 pk1 = new PK1();
private PK1 pk1 = new();
public CatchRate() => InitializeComponent();
public void LoadPK1(PK1 pk) => NUD_CatchRate.Value = (pk1 = pk).Catch_Rate;

View file

@ -95,7 +95,7 @@ namespace PKHeX.WinForms
public Color GetText(bool highlight) => highlight ? TextHighlighted : TextColor;
public Color GetBackground(bool legal, bool highlight) => highlight ? BackHighlighted : (legal ? BackLegal : BackColor);
public readonly BrushSet Brushes = new BrushSet();
public readonly BrushSet Brushes = new();
public void LoadBrushes()
{

View file

@ -129,7 +129,7 @@ namespace PKHeX.WinForms.Controls
/// <summary>
/// List of legal moves for the latest <see cref="Legality"/>.
/// </summary>
private readonly LegalMoveSource LegalMoveSource = new LegalMoveSource();
private readonly LegalMoveSource LegalMoveSource = new();
/// <summary>
/// Gender Symbols for showing Genders
@ -223,12 +223,12 @@ namespace PKHeX.WinForms.Controls
case 7:
switch (pk)
{
case PK7 _:
case PK7:
GetFieldsfromPKM = PopulateFieldsPK7;
GetPKMfromFields = PreparePK7;
break;
case PB7 _:
case PB7:
GetFieldsfromPKM = PopulateFieldsPB7;
GetPKMfromFields = PreparePB7;
break;

View file

@ -20,7 +20,7 @@ namespace PKHeX.WinForms.Controls
private Image? ExtraLayer;
private Image?[]? GlowCache;
public Image? OriginalBackground;
private readonly object Lock = new object();
private readonly object Lock = new();
private PictureBox? pb;
private int GlowInterval;

View file

@ -9,7 +9,7 @@ namespace PKHeX.WinForms.Controls
public sealed class BoxMenuStrip : ContextMenuStrip
{
private readonly SAVEditor SAV;
private readonly List<ItemVisibility> CustomItems = new List<ItemVisibility>();
private readonly List<ItemVisibility> CustomItems = new();
private readonly BoxManipulator Manipulator;
public BoxMenuStrip(SAVEditor sav)
@ -40,7 +40,7 @@ namespace PKHeX.WinForms.Controls
CustomItems.Add(new ItemVisibility(tsi, item));
}
private static readonly Dictionary<BoxManipType, Image> ManipTypeImage = new Dictionary<BoxManipType, Image>
private static readonly Dictionary<BoxManipType, Image> ManipTypeImage = new()
{
[BoxManipType.DeleteAll] = Resources.nocheck,
[BoxManipType.DeleteEggs] = Resources.about,

View file

@ -29,7 +29,7 @@ namespace PKHeX.WinForms.Controls
public SaveFile SAV { get; private set; } = new FakeSaveFile();
public int CurrentBox => Box.CurrentBox;
public SlotChangeManager M { get; set; }
public SlotChangeManager M { get; }
public readonly ContextMenuSAV menu;
public readonly BoxMenuStrip SortMenu;

View file

@ -18,12 +18,12 @@ namespace PKHeX.WinForms.Controls
public sealed class SlotChangeManager : IDisposable
{
public readonly SAVEditor SE;
public readonly SlotTrackerImage LastSlot = new SlotTrackerImage();
public readonly DragManager Drag = new DragManager();
public readonly SlotTrackerImage LastSlot = new();
public readonly DragManager Drag = new();
public SaveDataEditor<PictureBox> Env { get; set; } = null!;
public readonly List<BoxEditor> Boxes = new List<BoxEditor>();
public readonly SlotHoverHandler Hover = new SlotHoverHandler();
public readonly List<BoxEditor> Boxes = new();
public readonly SlotHoverHandler Hover = new();
public SlotChangeManager(SAVEditor se) => SE = se;
@ -35,9 +35,8 @@ namespace PKHeX.WinForms.Controls
public void MouseEnter(object? sender, EventArgs e)
{
if (sender == null)
if (sender is not PictureBox pb)
return;
var pb = (PictureBox)sender;
if (pb.Image == null)
return;
Hover.Start(pb, LastSlot);

View file

@ -8,7 +8,7 @@ namespace PKHeX.WinForms.Controls
{
public sealed class CryPlayer
{
private readonly SoundPlayer Sounds = new SoundPlayer();
private readonly SoundPlayer Sounds = new();
public void PlayCry(PKM pk)
{

View file

@ -5,7 +5,7 @@ namespace PKHeX.WinForms.Controls
{
public sealed class DragManager
{
public SlotChangeInfo<Cursor, PictureBox> Info { get; private set; } = new SlotChangeInfo<Cursor, PictureBox>();
public SlotChangeInfo<Cursor, PictureBox> Info { get; private set; } = new();
public event DragEventHandler? RequestExternalDragDrop;
public void RequestDD(object sender, DragEventArgs e) => RequestExternalDragDrop?.Invoke(sender, e);

View file

@ -13,7 +13,7 @@ namespace PKHeX.WinForms.Controls
InitializeComponent();
}
public readonly List<PictureBox> Entries = new List<PictureBox>();
public readonly List<PictureBox> Entries = new();
public int Slots { get; private set; }
private int sizeW = 40;
@ -73,7 +73,7 @@ namespace PKHeX.WinForms.Controls
public static PictureBox GetControl(int width, int height)
{
return new PictureBox
return new()
{
AutoSize = false,
SizeMode = PictureBoxSizeMode.CenterImage,

View file

@ -12,14 +12,14 @@ namespace PKHeX.WinForms.Controls
/// </summary>
public sealed class SlotHoverHandler : IDisposable
{
public DrawConfig Draw { private get; set; } = new DrawConfig();
public DrawConfig Draw { private get; set; } = new();
public bool GlowHover { private get; set; } = true;
public static readonly CryPlayer CryPlayer = new CryPlayer();
public static readonly SummaryPreviewer Preview = new SummaryPreviewer();
public static readonly CryPlayer CryPlayer = new();
public static readonly SummaryPreviewer Preview = new();
private static Bitmap Hover => SpriteUtil.Spriter.Hover;
private readonly BitmapAnimator HoverWorker = new BitmapAnimator();
private readonly BitmapAnimator HoverWorker = new();
private PictureBox? Slot;
private SlotTrackerImage? LastSlot;

View file

@ -10,8 +10,8 @@ namespace PKHeX.WinForms.Controls
{
private static readonly string[] names = Enum.GetNames(typeof(StorageSlotType));
private readonly LabelType[] Labels = new LabelType[names.Length];
private readonly List<PictureBox> slots = new List<PictureBox>();
private List<SlotInfoMisc> SlotOffsets = new List<SlotInfoMisc>();
private readonly List<PictureBox> slots = new();
private List<SlotInfoMisc> SlotOffsets = new();
public int SlotCount { get; private set; }
public SaveFile SAV { get; set; } = null!;
public bool FlagIllegal { get; set; }
@ -121,7 +121,7 @@ namespace PKHeX.WinForms.Controls
private static PictureBox GetPictureBox(int index, SpriteBuilder s)
{
return new PictureBox
return new()
{
BorderStyle = BorderStyle.FixedSingle,
Width = s.Width + 2,

View file

@ -6,7 +6,7 @@ namespace PKHeX.WinForms.Controls
{
public sealed class SummaryPreviewer
{
private readonly ToolTip ShowSet = new ToolTip { InitialDelay = 200, IsBalloon = false };
private readonly ToolTip ShowSet = new() { InitialDelay = 200, IsBalloon = false };
public void Show(Control pb, PKM pk)
{

View file

@ -86,7 +86,7 @@ namespace PKHeX.WinForms
private readonly string[] main_langlist = Enum.GetNames(typeof(ProgramLanguage));
private static readonly List<IPlugin> Plugins = new List<IPlugin>();
private static readonly List<IPlugin> Plugins = new();
#endregion
#region Path Variables
@ -280,7 +280,7 @@ namespace PKHeX.WinForms
BAKprompt = Settings.BAKPrompt = true;
}
public static DrawConfig Draw { get; private set; } = new DrawConfig();
public static DrawConfig Draw { get; private set; } = new();
private void FormInitializeSecond()
{

View file

@ -89,7 +89,7 @@ namespace PKHeX.WinForms
{
return personalInfo switch
{
PersonalInfoSM _ => s > 721 || Legal.PastGenAlolanNatives.Contains(s),
PersonalInfoSM => s > 721 || Legal.PastGenAlolanNatives.Contains(s),
PersonalInfoSWSH ss => ss.IsInDex,
_ => true,
};

View file

@ -230,7 +230,7 @@ namespace PKHeX.WinForms
}
// Mass Editing
private Core.BatchEditor editor = new Core.BatchEditor();
private Core.BatchEditor editor = new();
private void ProcessSAV(IList<PKM> data, IReadOnlyList<StringInstruction> Filters, IReadOnlyList<StringInstruction> Instructions)
{

View file

@ -49,8 +49,8 @@ namespace PKHeX.WinForms
}
}
private readonly List<RegimenInfo> reglist = new List<RegimenInfo>();
private readonly List<RegimenInfo> distlist = new List<RegimenInfo>();
private readonly List<RegimenInfo> reglist = new();
private readonly List<RegimenInfo> distlist = new();
private readonly ISuperTrain pkm;
private const string PrefixCHK = "CHK_";

View file

@ -46,7 +46,7 @@ namespace PKHeX.WinForms
CenterToParent();
}
private readonly List<NumericUpDown> Bytes = new List<NumericUpDown>();
private readonly List<NumericUpDown> Bytes = new();
public string FinalString;
public byte[] FinalBytes { get; private set; } = Array.Empty<byte>();
private readonly byte[] Raw;
@ -177,9 +177,9 @@ namespace PKHeX.WinForms
private string GetString() => SAV.GetString(Raw, 0, Raw.Length);
// Helpers
private static Label GetLabel(string str) => new Label {Text = str, AutoSize = true};
private static Label GetLabel(string str) => new() {Text = str, AutoSize = true};
private static NumericUpDown GetNUD(int min, int max, bool hex) => new NumericUpDown
private static NumericUpDown GetNUD(int min, int max, bool hex) => new()
{
Maximum = max,
Minimum = min,

View file

@ -42,7 +42,7 @@ namespace PKHeX.WinForms
WinFormsUtil.Alert(MsgReportColumnRestoreSuccess);
};
ContextMenuStrip mnu = new ContextMenuStrip();
ContextMenuStrip mnu = new();
mnu.Items.Add(mnuHide);
mnu.Items.Add(mnuRestore);

View file

@ -102,8 +102,8 @@ namespace PKHeX.WinForms
private readonly PictureBox[] PKXBOXES;
private readonly string DatabasePath = Main.DatabasePath;
private List<PKM> Results = new List<PKM>();
private List<PKM> RawDB = new List<PKM>();
private List<PKM> Results = new();
private List<PKM> RawDB = new();
private int slotSelected = -1; // = null;
private Image? slotColor;
private const int RES_MAX = 66;
@ -112,7 +112,7 @@ namespace PKHeX.WinForms
private readonly string Viewed;
private const int MAXFORMAT = PKX.Generation;
private readonly string EXTERNAL_SAV = new DirectoryInfo(Main.BackupPath).Name + Path.DirectorySeparatorChar;
private readonly SummaryPreviewer ShowSet = new SummaryPreviewer();
private readonly SummaryPreviewer ShowSet = new();
// Important Events
private void ClickView(object sender, EventArgs e)
@ -312,7 +312,7 @@ namespace PKHeX.WinForms
if (this.OpenWindowExists<ReportGrid>())
return;
ReportGrid reportGrid = new ReportGrid();
ReportGrid reportGrid = new();
reportGrid.Show();
reportGrid.PopulateData(Results.ToArray());
}

View file

@ -95,7 +95,7 @@ namespace PKHeX.WinForms
}
private readonly PictureBox[] PKXBOXES;
private List<IEncounterable> Results = new List<IEncounterable>();
private List<IEncounterable> Results = new();
private int slotSelected = -1; // = null;
private Image? slotColor;
private const int RES_MAX = 66;

View file

@ -18,7 +18,7 @@ namespace PKHeX.WinForms
private readonly List<INamedFolderPath> Paths;
private readonly SortableBindingList<SavePreview> Recent;
private readonly SortableBindingList<SavePreview> Backup;
private readonly List<Label> TempTranslationLabels = new List<Label>();
private readonly List<Label> TempTranslationLabels = new();
public SAV_FolderList(Action<SaveFile> openSaveFile)
{
@ -129,7 +129,7 @@ namespace PKHeX.WinForms
private static Button GetCustomButton(string name)
{
return new Button
return new()
{
Size = new Size { Height = ButtonHeight, Width = ButtonWidth },
Text = name,
@ -229,7 +229,7 @@ namespace PKHeX.WinForms
};
mnuBrowseAt.Click += (sender, e) => ClickOpenFolder(dgv);
ContextMenuStrip mnu = new ContextMenuStrip();
ContextMenuStrip mnu = new();
mnu.Items.Add(mnuOpen);
mnu.Items.Add(mnuBrowseAt);
return mnu;

View file

@ -78,8 +78,8 @@ namespace PKHeX.WinForms
private readonly PictureBox[] PKXBOXES;
private readonly string DatabasePath = Main.MGDatabasePath;
private List<MysteryGift> Results = new List<MysteryGift>();
private List<MysteryGift> RawDB = new List<MysteryGift>();
private List<MysteryGift> Results = new();
private List<MysteryGift> RawDB = new();
private int slotSelected = -1; // = null;
private Image? slotColor;
private const int RES_MAX = 66;

View file

@ -33,7 +33,7 @@ namespace PKHeX.WinForms
dgvApricorn.ReadOnly = true;
dgvApricorn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
DataGridViewComboBoxColumn dgvCount = new DataGridViewComboBoxColumn
DataGridViewComboBoxColumn dgvCount = new()
{
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,
DisplayIndex = 0,

View file

@ -18,8 +18,8 @@ namespace PKHeX.WinForms
Table = SAV switch
{
SAV4DP _ => HoneyTree.TableDP,
SAV4Pt _ => HoneyTree.TablePt,
SAV4DP => HoneyTree.TableDP,
SAV4Pt => HoneyTree.TablePt,
_ => throw new Exception()
};

View file

@ -116,12 +116,12 @@ namespace PKHeX.WinForms
IReadOnlyList<ComboItem> metLocationList;
switch (SAV)
{
case SAV4Sinnoh _:
case SAV4Sinnoh:
metLocationList = GameInfo.GetLocationList(GameVersion.Pt, 4, false);
FlyDestD = new[] { 1, 2, 6, 8, 3, 9, 10, 4, 12, 11, 5, 7, 14, 13, 54, 15, 81, 82, 83, 55, };
FlyDestC = new[] { 0, 1, 7, 9, 2, 10, 11, 3, 13, 12, 4, 8, 15, 14, 16, 68, 17, 5, 6, 67, };
break;
case SAV4HGSS _:
case SAV4HGSS:
metLocationList = GameInfo.GetLocationList(GameVersion.HG, 4, false);
FlyDestD = new[] { 126, 127, 128, 129, 131, 133, 132, 130, 134, 135, 136, 227, 229, 137, 221, 147, 138, 139, 140, 141, 143, 142, 144, 148, 145, 146, 225, };
FlyDestC = new[] { 11, 12, 13, 14, 16, 18, 17, 15, 19, 20, 21, 30, 27, 22, 33, 9, 0, 1, 2, 3, 5, 4, 6, 10, 7, 8, 35, };
@ -268,7 +268,7 @@ namespace PKHeX.WinForms
}
}
Bitmap dabmp = new Bitmap(96, 80);
Bitmap dabmp = new(96, 80);
BitmapData dabdata = dabmp.LockBits(new Rectangle(0, 0, dabmp.Width, dabmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
System.Runtime.InteropServices.Marshal.Copy(dupbyte, 0, dabdata.Scan0, dupbyte.Length);
dabmp.UnlockBits(dabdata);

View file

@ -178,7 +178,7 @@ namespace PKHeX.WinForms
private static List<ComboItem> GetStates()
{
return new List<ComboItem>
return new()
{
new ComboItem("Not roamed", 0),
new ComboItem("Roaming", 1),

View file

@ -38,7 +38,7 @@ namespace PKHeX.WinForms
dgvIndex.ReadOnly = true;
dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
DataGridViewComboBoxColumn dgvPuff = new DataGridViewComboBoxColumn
DataGridViewComboBoxColumn dgvPuff = new()
{
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
};

View file

@ -65,7 +65,7 @@ namespace PKHeX.WinForms
dgvIndex.ReadOnly = true;
dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
DataGridViewComboBoxColumn dgvBag = new DataGridViewComboBoxColumn
DataGridViewComboBoxColumn dgvBag = new()
{
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
};

View file

@ -46,7 +46,7 @@ namespace PKHeX.WinForms
private bool MapUpdated;
private static readonly string[] AllStyles = Enum.GetNames(typeof(PlayerBattleStyle7));
private readonly List<string> BattleStyles = new List<string>(AllStyles);
private readonly List<string> BattleStyles = new(AllStyles);
private int[] FlyDestFlagOfs = null!, MapUnmaskFlagOfs = null!;
private int SkipFlag => SAV is SAV7USUM ? 4160 : 3200; // FlagMax - 768

View file

@ -136,8 +136,8 @@ namespace PKHeX.WinForms
}
// Get list
List<int> num = new List<int>();
List<string> desc = new List<string>();
List<int> num = new();
List<string> desc = new();
foreach (string[] split in list.Select(s => s.Split('\t')).Where(split => split.Length == 2))
{
@ -206,9 +206,9 @@ namespace PKHeX.WinForms
}
// Get list
List<int> num = new List<int>();
List<string> desc = new List<string>();
List<string> enums = new List<string>();
List<int> num = new();
List<string> desc = new();
List<string> enums = new();
foreach (string[] split in list.Select(s => s.Split('\t')).Where(split => split.Length == 2 || split.Length == 3))
{

View file

@ -14,7 +14,7 @@ namespace PKHeX.WinForms
private readonly SaveFile SAV;
private readonly IPKMView View;
private readonly IReadOnlyList<SlotGroup> Groups;
private readonly SummaryPreviewer Preview = new SummaryPreviewer();
private readonly SummaryPreviewer Preview = new();
public int CurrentGroup { get; set; } = -1;

View file

@ -44,7 +44,7 @@ namespace PKHeX.WinForms
private int ColumnFreeSpace;
private int ColumnNEW;
private readonly Dictionary<InventoryType, DataGridView> ControlGrids = new Dictionary<InventoryType, DataGridView>();
private readonly Dictionary<InventoryType, DataGridView> ControlGrids = new();
private DataGridView GetGrid(InventoryType type) => ControlGrids[type];
private DataGridView GetGrid(int pouch) => ControlGrids[Pouches[pouch].Type];
@ -100,7 +100,7 @@ namespace PKHeX.WinForms
private static DataGridView GetBaseDataGrid(InventoryPouch pouch)
{
return new DataGridView
return new()
{
Dock = DockStyle.Fill,
Text = pouch.Type.ToString(),
@ -124,7 +124,7 @@ namespace PKHeX.WinForms
private static DataGridViewComboBoxColumn GetItemColumn(int c, string name = "Item")
{
return new DataGridViewComboBoxColumn
return new()
{
HeaderText = name,
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,

View file

@ -520,7 +520,7 @@ namespace PKHeX.WinForms
// UI Generation
private List<PictureBox> PopulateViewGiftsG4()
{
List<PictureBox> pb = new List<PictureBox>();
List<PictureBox> pb = new();
// Row 1
var f1 = GetFlowLayoutPanel();
@ -585,7 +585,7 @@ namespace PKHeX.WinForms
private static FlowLayoutPanel GetFlowLayoutPanel()
{
return new FlowLayoutPanel
return new()
{
Width = 305,
Height = 34,
@ -596,7 +596,7 @@ namespace PKHeX.WinForms
private static Label GetLabel(string text)
{
return new Label
return new()
{
Size = new Size(40, 34),
AutoSize = false,
@ -609,7 +609,7 @@ namespace PKHeX.WinForms
private static PictureBox GetPictureBox()
{
return new PictureBox
return new()
{
Size = new Size(42, 32),
SizeMode = PictureBoxSizeMode.CenterImage,

View file

@ -77,7 +77,7 @@ namespace PKHeX.WinForms
ReflectUtil.SetValue(SettingsObject, s.Name, GetValue(s));
}
private static CheckBox GetCheckBox(string name, bool state) => new CheckBox
private static CheckBox GetCheckBox(string name, bool state) => new()
{
Name = name, Checked = state, Text = name,
AutoSize = true,

View file

@ -10,8 +10,8 @@ namespace PKHeX.WinForms
{
public static class FontUtil
{
private static readonly PrivateFontCollection CustomFonts = new PrivateFontCollection();
private static readonly Dictionary<float, Font> GeneratedFonts = new Dictionary<float, Font>();
private static readonly PrivateFontCollection CustomFonts = new();
private static readonly Dictionary<float, Font> GeneratedFonts = new();
static FontUtil()
{
@ -22,7 +22,8 @@ namespace PKHeX.WinForms
File.WriteAllBytes(g6path, Resources.pgldings_normalregular);
CustomFonts.AddFontFile(g6path);
}
catch (FileNotFoundException ex){
catch (FileNotFoundException ex)
{
Debug.WriteLine($"Unable to read font file: {ex.Message}");
}
#pragma warning disable CA1031 // Do not catch general exception types

View file

@ -10,7 +10,7 @@ namespace PKHeX.WinForms
{
public static class WinFormsTranslator
{
private static readonly Dictionary<string, TranslationContext> Context = new Dictionary<string, TranslationContext>();
private static readonly Dictionary<string, TranslationContext> Context = new();
internal static void TranslateInterface(this Control form, string lang) => TranslateForm(form, GetContext(lang));
private static string GetTranslationFileNameInternal(string lang) => $"lang_{lang}";
@ -216,7 +216,7 @@ namespace PKHeX.WinForms
public bool AddNew { private get; set; }
public bool RemoveUsedKeys { private get; set; }
public const char Separator = '=';
private readonly Dictionary<string, string> Translation = new Dictionary<string, string>();
private readonly Dictionary<string, string> Translation = new();
public TranslationContext(IEnumerable<string> content, char separator = Separator)
{

View file

@ -233,7 +233,7 @@ namespace PKHeX.WinForms
CustomSaveExtensions.AddRange(newExtensions);
}
private static readonly List<string> CustomSaveExtensions = new List<string>
private static readonly List<string> CustomSaveExtensions = new()
{
// THESE ARE SAVE FILE EXTENSION TYPES. SAVE STATE (RAM SNAPSHOT) EXTENSIONS DO NOT GO HERE.
"sav", // standard
@ -385,9 +385,9 @@ namespace PKHeX.WinForms
{
switch (x)
{
case UnauthorizedAccessException _:
case FileNotFoundException _:
case IOException _:
case UnauthorizedAccessException:
case FileNotFoundException:
case IOException:
Error(MsgFileWriteFail + Environment.NewLine + x.Message, MsgFileWriteProtectedAdvice);
break;
default:

View file

@ -107,6 +107,10 @@ namespace PKHeX.Tests.PKM
Met_Year = 12
};
pk.Met_Day.Should().Be(12);
pk.Met_Month.Should().Be(12);
pk.Met_Year.Should().Be(12);
pk.MetDate = null;
pk.Met_Day.Should().Be(0);
@ -124,6 +128,10 @@ namespace PKHeX.Tests.PKM
Met_Year = 12
};
pk.Met_Day.Should().Be(12);
pk.Met_Month.Should().Be(12);
pk.Met_Year.Should().Be(12);
pk.MetDate = new DateTime(2005, 5, 5);
pk.Met_Day.Should().Be(5);
@ -183,6 +191,10 @@ namespace PKHeX.Tests.PKM
Egg_Year = 12
};
pk.Egg_Day.Should().Be(12);
pk.Egg_Month.Should().Be(12);
pk.Egg_Year.Should().Be(12);
pk.EggMetDate = null;
pk.Egg_Day.Should().Be(0);
@ -200,6 +212,10 @@ namespace PKHeX.Tests.PKM
Egg_Year = 12
};
pk.Egg_Day.Should().Be(12);
pk.Egg_Month.Should().Be(12);
pk.Egg_Year.Should().Be(12);
pk.EggMetDate = new DateTime(2005, 5, 5);
pk.Egg_Day.Should().Be(5);

View file

@ -57,7 +57,7 @@ namespace PKHeX.Tests.Simulator
};
for (var nature = Nature.Hardy; nature <= Nature.Quirky; nature++)
{
criteria.Nature = nature;
criteria = criteria with {Nature = nature};
var pkm = ez.ConvertToPKM(tr, criteria);
pkm.Nature.Should().Be((int)nature, "not nature locked");
pkm.IsShiny.Should().BeTrue("encounter is shiny locked");