Bump lang version to 8

some lang upgrades
This commit is contained in:
Kurt 2019-10-04 20:10:50 -07:00
parent 255cdc6ae0
commit 87f43a47d8
21 changed files with 151 additions and 180 deletions

View file

@ -11,7 +11,6 @@ namespace PKHeX.Core
public EventFlag(int index, EventVarType t, IReadOnlyList<string> pieces) : base(index, t, pieces[1])
{
}
}
}

View file

@ -59,13 +59,11 @@ namespace PKHeX.Core
private static SlotReversion GetReversion(ISlotInfo info, SaveFile sav)
{
switch (info)
return info switch
{
case SlotInfoParty p:
return new PartyReversion(p, sav);
default:
return new SingleSlotReversion(info, sav);
}
SlotInfoParty p => (SlotReversion) new PartyReversion(p, sav),
_ => new SingleSlotReversion(info, sav)
};
}
private abstract class SlotReversion

View file

@ -324,15 +324,15 @@ namespace PKHeX.Core
public IReadOnlyList<string> GetItemStrings(int generation, GameVersion game = GameVersion.Any)
{
switch (generation)
return generation switch
{
case 0: return Array.Empty<string>();
case 1: return g1items;
case 2: return g2items;
case 3: return GetItemStrings3(game);
case 4: return g4items; // mail names changed 4->5
default: return itemlist;
}
0 => Array.Empty<string>(),
1 => g1items,
2 => g2items,
3 => GetItemStrings3(game),
4 => g4items, // mail names changed 4->5
_ => itemlist
};
}
private string[] GetItemStrings3(GameVersion game)
@ -434,73 +434,73 @@ namespace PKHeX.Core
private IReadOnlyList<string> GetLocationNames4(int bankID)
{
switch (bankID)
return bankID switch
{
case 0: return metHGSS_00000;
case 2: return metHGSS_02000;
case 3: return metHGSS_03000;
default: return Array.Empty<string>();
}
0 => metHGSS_00000,
2 => metHGSS_02000,
3 => metHGSS_03000,
_ => Array.Empty<string>()
};
}
public IReadOnlyList<string> GetLocationNames5(int bankID)
{
switch (bankID)
return bankID switch
{
case 0: return metBW2_00000;
case 3: return metBW2_30000;
case 4: return metBW2_40000;
case 6: return metBW2_60000;
default: return Array.Empty<string>();
}
0 => metBW2_00000,
3 => metBW2_30000,
4 => metBW2_40000,
6 => metBW2_60000,
_ => Array.Empty<string>()
};
}
public IReadOnlyList<string> GetLocationNames6(int bankID)
{
switch (bankID)
return bankID switch
{
case 0: return metXY_00000;
case 3: return metXY_30000;
case 4: return metXY_40000;
case 6: return metXY_60000;
default: return Array.Empty<string>();
}
0 => metXY_00000,
3 => metXY_30000,
4 => metXY_40000,
6 => metXY_60000,
_ => Array.Empty<string>()
};
}
public IReadOnlyList<string> GetLocationNames7(int bankID)
{
switch (bankID)
return bankID switch
{
case 0: return metSM_00000;
case 3: return metSM_30000;
case 4: return metSM_40000;
case 6: return metSM_60000;
default: return Array.Empty<string>();
}
0 => metSM_00000,
3 => metSM_30000,
4 => metSM_40000,
6 => metSM_60000,
_ => Array.Empty<string>()
};
}
public IReadOnlyList<string> GetLocationNames7GG(int bankID)
{
switch (bankID)
return bankID switch
{
case 0: return metGG_00000;
case 3: return metGG_30000;
case 4: return metGG_40000;
case 6: return metGG_60000;
default: return Array.Empty<string>();
}
0 => metGG_00000,
3 => metGG_30000,
4 => metGG_40000,
6 => metGG_60000,
_ => Array.Empty<string>()
};
}
public IReadOnlyList<string> GetLocationNames8(int bankID)
{
switch (bankID)
return bankID switch
{
case 0: return metSWSH_00000;
case 3: return metSWSH_30000;
case 4: return metSWSH_40000;
case 6: return metSWSH_60000;
default: return Array.Empty<string>();
}
0 => metSWSH_00000,
3 => metSWSH_30000,
4 => metSWSH_40000,
6 => metSWSH_60000,
_ => Array.Empty<string>()
};
}
}
}

View file

@ -66,21 +66,15 @@ namespace PKHeX.Core
public List<ComboItem> GetArgumentStrings(MemoryArgType memIndex)
{
switch (memIndex)
return memIndex switch
{
default:
return None;
case MemoryArgType.Species:
return Species;
case MemoryArgType.GeneralLocation:
return GeneralLocations;
case MemoryArgType.Item:
return Items;
case MemoryArgType.Move:
return Moves;
case MemoryArgType.SpecificLocation:
return SpecificLocations;
}
MemoryArgType.Species => Species,
MemoryArgType.GeneralLocation => GeneralLocations,
MemoryArgType.Item => Items,
MemoryArgType.Move => Moves,
MemoryArgType.SpecificLocation => SpecificLocations,
_ => None
};
}
}
}

View file

@ -101,19 +101,18 @@ namespace PKHeX.Core
/// <returns>Version ID from requested generation. If none, return <see cref="Invalid"/>.</returns>
public static GameVersion GetVersion(int generation)
{
switch (generation)
return generation switch
{
case 1: return RBY;
case 2: return C;
case 3: return E;
case 4: return SS;
case 5: return W2;
case 6: return AS;
case 7: return UM;
case 8: return SH;
default:
return Invalid;
}
1 => RBY,
2 => C,
3 => E,
4 => SS,
5 => W2,
6 => AS,
7 => UM,
8 => SH,
_ => Invalid
};
}
/// <summary>

View file

@ -196,13 +196,9 @@ namespace PKHeX.Core
{
if (form < 30) // specified form
{
switch (pk.Species)
{
case (int)Core.Species.Minior:
return Util.Rand.Next(7, 14);
default:
return form;
}
if (pk.Species == (int) Core.Species.Minior)
return Util.Rand.Next(7, 14);
return form;
}
if (form == 31) // flagged as totally random
return Util.Rand.Next(pk.PersonalInfo.FormeCount);

View file

@ -44,7 +44,7 @@ namespace PKHeX.Core
public CheckMoveResult[] Moves { get; internal set; } = new CheckMoveResult[4];
public ValidEncounterMoves EncounterMoves { get; internal set; }
public IReadOnlyList<EvoCriteria>[] EvoChainsAllGens => _evochains ?? (_evochains = EvolutionChain.GetEvolutionChainsAllGens(pkm, EncounterMatch));
public IReadOnlyList<EvoCriteria>[] EvoChainsAllGens => _evochains ??= EvolutionChain.GetEvolutionChainsAllGens(pkm, EncounterMatch);
private IReadOnlyList<EvoCriteria>[] _evochains;
/// <summary><see cref="RNG"/> related information that generated the <see cref="PKM.PID"/>/<see cref="PKM.IVs"/> value(s).</summary>
@ -75,7 +75,7 @@ namespace PKHeX.Core
internal void Reject(CheckResult c)
{
(InvalidMatches ?? (InvalidMatches = new List<EncounterRejected>())).Add(new EncounterRejected(EncounterMatch, c));
(InvalidMatches ??= new List<EncounterRejected>()).Add(new EncounterRejected(EncounterMatch, c));
}
}
}

View file

@ -44,19 +44,14 @@ namespace PKHeX.Core
if (pkm.Ball == (int)Heavy && Legal.AlolanCaptureNoHeavyBall.Contains(EncounterMatch.Species) && !EncounterMatch.EggEncounter && pkm.SM)
return GetInvalid(LBallHeavy); // Heavy Ball, can inherit if from egg (USUM fixed catch rate calc)
switch (EncounterMatch)
return EncounterMatch switch
{
case EncounterStatic e:
return VerifyBallStatic(data, e);
case EncounterSlot w:
return VerifyBallWild(data, w);
case EncounterEgg _:
return VerifyBallEgg(data);
case EncounterInvalid _:
return VerifyBallEquals(data, pkm.Ball); // ignore me
default:
return VerifyBallEquals(data, (int)Poke); // Pokeball
}
EncounterStatic e => VerifyBallStatic(data, e),
EncounterSlot w => VerifyBallWild(data, w),
EncounterEgg _ => VerifyBallEgg(data),
EncounterInvalid _ => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
_ => VerifyBallEquals(data, (int)Poke)
};
}
private CheckResult VerifyBallMysteryGift(LegalityAnalysis data, MysteryGift g)
@ -96,24 +91,24 @@ namespace PKHeX.Core
if (data.Info.Generation < 6) // No inheriting Balls
return VerifyBallEquals(data, (int)Poke); // Must be Pokéball -- no ball inheritance.
switch ((Ball)pkm.Ball)
return pkm.Ball switch
{
case Poke: return GetValid(LBallEnc); // Poké Ball
case Master: return GetInvalid(LBallEggMaster); // Master Ball
case Cherish: return GetInvalid(LBallEggCherish); // Cherish Ball
default: return VerifyBallInherited(data);
}
(int)Poke => GetValid(LBallEnc), // Poké Ball
(int)Master => GetInvalid(LBallEggMaster), // Master Ball
(int)Cherish => GetInvalid(LBallEggCherish), // Cherish Ball
_ => VerifyBallInherited(data)
};
}
private CheckResult VerifyBallInherited(LegalityAnalysis data)
{
switch (data.Info.Generation)
return data.Info.Generation switch
{
case 6: return VerifyBallEggGen6(data); // Gen6 Inheritance Rules
case 7: return VerifyBallEggGen7(data); // Gen7 Inheritance Rules
case 8: return VerifyBallEggGen8(data);
default: return NONE;
}
6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules
7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules
8 => VerifyBallEggGen8(data),
_ => NONE
};
}
private CheckResult VerifyBallEggGen6(LegalityAnalysis data)

View file

@ -169,15 +169,12 @@ namespace PKHeX.Core
private uint GetSaneSeed(uint seed)
{
switch (Method)
return Method switch
{
case PIDType.BACD_R:
return seed & 0x0000FFFF;
case PIDType.BACD_R_S:
return seed & 0x000000FF;
default:
return seed; // unmodified
}
PIDType.BACD_R => (seed & 0x0000FFFF),
PIDType.BACD_R_S => (seed & 0x000000FF),
_ => seed
};
}
private static LanguageID GetSafeLanguage(LanguageID hatchLang, LanguageID supplied)

View file

@ -10,7 +10,7 @@
<PackageIconUrl>https://github.com/kwsch/PKHeX/blob/master/PKHeX.WinForms/icon.ico</PackageIconUrl>
<PackageProjectUrl />
<RepositoryUrl>https://github.com/kwsch/PKHeX</RepositoryUrl>
<LangVersion>7.2</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>

View file

@ -397,12 +397,12 @@ namespace PKHeX.Core
private static int AmplifyStat(int nature, int index, int initial)
{
switch (GetNatureAmp(nature, index))
return GetNatureAmp(nature, index) switch
{
case 1: return 110 * initial / 100; // 110%
case -1: return 90 * initial / 100; // 90%
default: return initial; // 100%
}
1 => (110 * initial / 100), // 110%
-1 => (90 * initial / 100), // 90%
_ => initial
};
}
private static sbyte GetNatureAmp(int nature, int index)

View file

@ -34,13 +34,12 @@ namespace PKHeX.Core.Searching
public static IEnumerable<PKM> FilterByGeneration(IEnumerable<PKM> res, int generation)
{
switch (generation)
return generation switch
{
case 1:
case 2: return res.Where(pk => pk.VC || pk.Format < 3);
default:
return res.Where(pk => pk.GenNumber == generation);
}
1 => res.Where(pk => pk.VC || pk.Format < 3),
2 => res.Where(pk => pk.VC || pk.Format < 3),
_ => res.Where(pk => pk.GenNumber == generation)
};
}
public static IEnumerable<PKM> FilterByLVL(IEnumerable<PKM> res, SearchComparison option, int level)
@ -48,18 +47,13 @@ namespace PKHeX.Core.Searching
if (level > 100)
return res;
switch (option)
return option switch
{
case SearchComparison.LessThanEquals:
return res.Where(pk => pk.Stat_Level <= level);
case SearchComparison.Equals:
return res.Where(pk => pk.Stat_Level == level);
case SearchComparison.GreaterThanEquals:
return res.Where(pk => pk.Stat_Level >= level);
default:
return res; // Any (Do nothing)
}
SearchComparison.LessThanEquals => res.Where(pk => pk.Stat_Level <= level),
SearchComparison.Equals => res.Where(pk => pk.Stat_Level == level),
SearchComparison.GreaterThanEquals => res.Where(pk => pk.Stat_Level >= level),
_ => res
};
}
public static IEnumerable<PKM> FilterByEVs(IEnumerable<PKM> res, int option)
@ -133,22 +127,22 @@ namespace PKHeX.Core.Searching
public static string HashByDetails(PKM pk)
{
switch (pk.Format)
return pk.Format switch
{
case 1: return $"{pk.Species:000}{((PK1)pk).DV16:X4}";
case 2: return $"{pk.Species:000}{((PK2)pk).DV16:X4}";
default: return $"{pk.Species:000}{pk.PID:X8}{string.Join(" ", pk.IVs)}{pk.AltForm:00}";
}
1 => $"{pk.Species:000}{((PK1) pk).DV16:X4}",
2 => $"{pk.Species:000}{((PK2) pk).DV16:X4}",
_ => $"{pk.Species:000}{pk.PID:X8}{string.Join(" ", pk.IVs)}{pk.AltForm:00}"
};
}
public static string HashByPID(PKM pk)
{
switch (pk.Format)
return pk.Format switch
{
case 1: return $"{((PK1)pk).DV16:X4}";
case 2: return $"{((PK2)pk).DV16:X4}";
default: return $"{pk.PID:X8}";
}
1 => $"{((PK1) pk).DV16:X4}",
2 => $"{((PK2) pk).DV16:X4}",
_ => $"{pk.PID:X8}"
};
}
public static IEnumerable<PKM> GetClones(IEnumerable<PKM> res, CloneDetectionMethod type = CloneDetectionMethod.HashDetails)

View file

@ -445,13 +445,13 @@ namespace PKHeX.Core
public static int GetGenderFromPIDAndRatio(uint PID, int gr)
{
switch (gr)
return gr switch
{
case 255: return 2;
case 254: return 1;
case 0: return 0;
default: return (PID & 0xFF) < gr ? 1 : 0;
}
255 => 2,
254 => 1,
0 => 0,
_ => ((PID & 0xFF) < gr ? 1 : 0)
};
}
/// <summary>

View file

@ -105,7 +105,7 @@ namespace PKHeX.Core
get
{
if (XD) return false;
return Flag0 | !Flag1;
return Flag0 || !Flag1;
}
set
{

View file

@ -113,13 +113,13 @@ namespace PKHeX.Core
private static EntreeForestArea GetSlotPosition(int index)
{
switch (index)
return index switch
{
case 0: return EntreeForestArea.Center;
case 1: return EntreeForestArea.Left;
case 2: return EntreeForestArea.Right;
default: throw new ArgumentOutOfRangeException();
}
0 => EntreeForestArea.Center,
1 => EntreeForestArea.Left,
2 => EntreeForestArea.Right,
_ => throw new ArgumentOutOfRangeException()
};
}
}
}

View file

@ -57,7 +57,6 @@ namespace PKHeX.Core
}
}
public sealed class BattleBox6 : SaveBlock
{
public BattleBox6(SaveFile SAV, int offset) : base(SAV) => Offset = offset;

View file

@ -118,7 +118,6 @@ namespace PKHeX.Core
set => Data[Offset + 0x58] = (byte)value;
}
public bool MegaUnlocked
{
get => (Data[Offset + 0x78] & 0x01) != 0;

View file

@ -132,14 +132,14 @@ namespace PKHeX.Core
if (slot < 1 || slot > WormholeSlotMax)
return -1;
switch (mapid)
return mapid switch
{
case 256: return WormholeSlotsRed[slot];
case 257: return WormholeSlotsGreen[slot];
case 258: return WormholeSlotsYellow[slot];
case 259: return WormholeSlotsBlue[slot];
default: return -1;
}
256 => WormholeSlotsRed[slot],
257 => WormholeSlotsGreen[slot],
258 => WormholeSlotsYellow[slot],
259 => WormholeSlotsBlue[slot],
_ => -1
};
}
}
}

View file

@ -1058,7 +1058,7 @@ namespace PKHeX.WinForms
private void GetPreview(PictureBox pb, PKM pk = null)
{
pk = pk ?? PreparePKM(false); // don't perform control loss click
pk ??= PreparePKM(false); // don't perform control loss click
dragout.ContextMenuStrip.Enabled = pk.Species != 0 || HaX; // Species

View file

@ -68,7 +68,7 @@ namespace PKHeX.WinForms
private void PB_QR_Click(object sender, EventArgs e)
{
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgQRClipboardImage))
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgQRClipboardImage))
return;
try { Clipboard.SetImage(PB_QR.BackgroundImage); }
catch { WinFormsUtil.Alert(MsgQRClipboardFail); }

View file

@ -13,6 +13,7 @@
<StartupObject>PKHeX.WinForms.Program</StartupObject>
<AssemblyName>PKHeX</AssemblyName>
<Version>19.09.19</Version>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>