Update .NET Runtime to .NET 8.0 (#4082)

With the new version of Visual Studio bringing C# 12, we can revise our logic for better readability as well as use new methods/APIs introduced in the .NET 8.0 BCL.
This commit is contained in:
Kurt 2023-12-03 20:13:20 -08:00 committed by GitHub
parent a71597f3a8
commit d47bb1d297
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
773 changed files with 6267 additions and 7007 deletions

View file

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Version>23.10.11</Version>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<NeutralLanguage>en</NeutralLanguage>
<Product>PKHeX</Product>

View file

@ -96,7 +96,7 @@ public static class BallApplicator
// Gen1/2 don't store color in personal info
var pi = pk.Format >= 3 ? pk.PersonalInfo : PersonalTable.USUM.GetFormEntry(pk.Species, 0);
var color = (PersonalColor)pi.Color;
var balls = BallColors[color];
var balls = BallColors[(int)color];
var currentBall = (Ball)pk.Ball;
return GetCircularOnce(balls, currentBall, result);
}
@ -122,14 +122,15 @@ public static class BallApplicator
static BallApplicator()
{
ReadOnlySpan<Ball> exclude = stackalloc Ball[] {None, Poke};
ReadOnlySpan<Ball> end = stackalloc Ball[] {Poke};
ReadOnlySpan<Ball> exclude = [None, Poke];
ReadOnlySpan<Ball> end = [Poke];
Span<Ball> all = stackalloc Ball[BallList.Length - exclude.Length];
all = all[..FillExcept(all, exclude, BallList)];
var colors = (PersonalColor[])Enum.GetValues(typeof(PersonalColor));
foreach (var c in colors)
foreach (var color in colors)
{
int c = (int)color;
// Replace the array reference with a new array that appends non-matching values, followed by the end values.
var defined = BallColors[c];
Span<Ball> match = (BallColors[c] = new Ball[all.Length + end.Length]);
@ -164,20 +165,20 @@ public static class BallApplicator
/// <summary>
/// Priority Match ball IDs that match the color ID in descending order
/// </summary>
private static readonly Dictionary<PersonalColor, Ball[]> BallColors = new()
{
[PersonalColor.Red] = new[] { Cherish, Repeat, Fast, Heal, Great, Dream, Lure },
[PersonalColor.Blue] = new[] { Dive, Net, Great, Beast, Lure },
[PersonalColor.Yellow] = new[] { Level, Ultra, Repeat, Quick, Moon },
[PersonalColor.Green] = new[] { Safari, Friend, Nest, Dusk },
[PersonalColor.Black] = new[] { Luxury, Heavy, Ultra, Moon, Net, Beast },
private static readonly Ball[][] BallColors =
[
/* Red */ [Cherish, Repeat, Fast, Heal, Great, Dream, Lure],
/* Blue */ [Dive, Net, Great, Beast, Lure],
/* Yellow */ [Level, Ultra, Repeat, Quick, Moon],
/* Green */ [Safari, Friend, Nest, Dusk],
/* Black */ [Luxury, Heavy, Ultra, Moon, Net, Beast],
[PersonalColor.Brown] = new[] { Level, Heavy },
[PersonalColor.Purple] = new[] { Master, Love, Dream, Heal },
[PersonalColor.Gray] = new[] { Heavy, Premier, Luxury },
[PersonalColor.White] = new[] { Premier, Timer, Luxury, Ultra },
[PersonalColor.Pink] = new[] { Love, Dream, Heal },
};
/* Brown */ [Level, Heavy],
/* Purple */ [Master, Love, Dream, Heal],
/* Gray */ [Heavy, Premier, Luxury],
/* White */ [Premier, Timer, Luxury, Ultra],
/* Pink */ [Love, Dream, Heal],
];
/// <summary>
/// Personal Data color IDs

View file

@ -34,17 +34,22 @@ public static class CatchRateApplicator
case EncounterGift1 { Version: GameVersion.Stadium, Species: (int)Species.Psyduck }:
return pk.Japanese ? (byte)167 : (byte)168; // Amnesia Psyduck has different catch rates depending on language
default:
var pt = GetPersonalTable(sav, enc);
var pt = GetPersonalTable(sav, enc.Version);
var pi = pt[enc.Species];
return (byte)pi.CatchRate;
}
}
private static PersonalTable1 GetPersonalTable(SaveFile sav, IEncounterable v)
private static PersonalTable1 GetPersonalTable(SaveFile sav, GameVersion ver)
{
if (sav.Personal is PersonalTable1 pt && (sav.Version.Contains(v.Version) || v.Version.Contains(sav.Version)))
return pt;
if (!GameVersion.RB.Contains(v.Version))
if (sav.Personal is PersonalTable1 pt)
{
var other = sav.Version;
if (other.Contains(ver) || ver.Contains(other))
return pt;
}
if (!GameVersion.RB.Contains(ver))
return PersonalTable.Y;
return PersonalTable.RB;
}

View file

@ -1,4 +1,4 @@
namespace PKHeX.Core;
namespace PKHeX.Core;
/// <summary>
/// Logic for modifying the Memory parameters of a <see cref="PKM"/>.
@ -43,8 +43,9 @@ public static class MemoryApplicator
public static void SetRandomMemory6(this PK6 pk)
{
// for lack of better randomization :)
pk.OT_Memory = 63;
pk.OT_Intensity = 6;
pk.OT_Feeling = MemoryContext6.GetRandomFeeling6(pk.OT_Memory);
const byte memory = 63; // almost got lost when it explored a forest with {Trainer}
pk.OT_Memory = memory;
pk.OT_Feeling = MemoryContext6.GetRandomFeeling6(memory);
pk.OT_Intensity = MemoryContext6.MaxIntensity;
}
}

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core;
public static class MoveApplicator
{
/// <summary>
/// Sets the individual PP Up count values depending if a Move is present in the move's slot or not.
/// Sets the individual PP Up count values depending on if a Move is present in the move's slot or not.
/// </summary>
/// <param name="pk">Pokémon to modify.</param>
/// <param name="moves"><see cref="PKM.Moves"/> to use.</param>
@ -29,7 +29,7 @@ public static class MoveApplicator
}
/// <summary>
/// Sets the individual PP Up count values depending if a Move is present in the move slot or not.
/// Sets the individual PP Up count values depending on if a Move is present in the move slot or not.
/// </summary>
/// <param name="pk">Pokémon to modify.</param>
public static void SetMaximumPPUps(this PKM pk)

View file

@ -129,7 +129,7 @@ public static class MoveShopRecordApplicator
if (!permit.IsRecordPermitted(index))
continue;
// If the Pokémon is caught with any move shop move in its learnset
// If the Pokémon is caught with any move shop move in its learnset,
// and it is high enough level to master it, the game will automatically
// give it the "Mastered" flag but not the "Purchased" flag
// For moves that are not in the learnset, it returns -1 which is true, thus set as mastered.

View file

@ -16,24 +16,24 @@ namespace PKHeX.Core;
public static class BatchEditing
{
public static readonly Type[] Types =
{
[
typeof (PK9),
typeof (PK8), typeof (PA8), typeof (PB8),
typeof (PB7),
typeof (PK7), typeof (PK6), typeof (PK5), typeof (PK4), typeof(BK4), typeof(RK4),
typeof (PK3), typeof (XK3), typeof (CK3),
typeof (PK2), typeof (SK2), typeof (PK1),
};
];
/// <summary>
/// Extra properties to show in the list of selectable properties (GUI)
/// </summary>
public static readonly List<string> CustomProperties = new()
{
public static readonly List<string> CustomProperties =
[
PROP_LEGAL, PROP_TYPENAME, PROP_RIBBONS, PROP_CONTESTSTATS, PROP_MOVEMASTERY,
PROP_TYPE1, PROP_TYPE2, PROP_TYPEEITHER,
IdentifierContains, nameof(ISlotInfo.Slot), nameof(SlotInfoBox.Box),
};
];
/// <summary>
/// Property names, indexed by <see cref="Types"/>.
@ -122,7 +122,7 @@ public static class BatchEditing
/// <param name="pk">Pokémon to check</param>
/// <param name="name">Property Name to check</param>
/// <param name="pi">Property Info retrieved (if any).</param>
/// <returns>True if has property, false if does not.</returns>
/// <returns>True if it has property, false if it does not.</returns>
public static bool TryGetHasProperty(PKM pk, string name, [NotNullWhen(true)] out PropertyInfo? pi)
{
var type = pk.GetType();
@ -135,7 +135,7 @@ public static class BatchEditing
/// <param name="type">Type to check</param>
/// <param name="name">Property Name to check</param>
/// <param name="pi">Property Info retrieved (if any).</param>
/// <returns>True if has property, false if does not.</returns>
/// <returns>True if it has property, false if it does not.</returns>
public static bool TryGetHasProperty(Type type, string name, [NotNullWhen(true)] out PropertyInfo? pi)
{
var index = Array.IndexOf(Types, type);
@ -167,7 +167,7 @@ public static class BatchEditing
/// Gets the type of the <see cref="PKM"/> property using the saved cache of properties.
/// </summary>
/// <param name="propertyName">Property Name to fetch the type for</param>
/// <param name="typeIndex">Type index (within <see cref="Types"/>. Leave empty (0) for a nonspecific format.</param>
/// <param name="typeIndex">Type index (within <see cref="Types"/>). Leave empty (0) for a nonspecific format.</param>
/// <returns>Short name of the property's type.</returns>
public static string? GetPropertyType(string propertyName, int typeIndex = 0)
{
@ -385,13 +385,13 @@ public static class BatchEditing
}
/// <summary>
/// Sets the if the <see cref="BatchInfo"/> should be filtered due to the <see cref="StringInstruction"/> provided.
/// Sets the property if the <see cref="BatchInfo"/> should be filtered due to the <see cref="StringInstruction"/> provided.
/// </summary>
/// <param name="cmd">Command Filter</param>
/// <param name="info">Pokémon to check.</param>
/// <param name="props">PropertyInfo cache (optional)</param>
/// <returns>True if filtered, else false.</returns>
private static ModifyResult SetPKMProperty(StringInstruction cmd, BatchInfo info, IReadOnlyDictionary<string, PropertyInfo> props)
private static ModifyResult SetPKMProperty(StringInstruction cmd, BatchInfo info, Dictionary<string, PropertyInfo> props)
{
var pk = info.Entity;
if (cmd.PropertyValue.StartsWith(CONST_BYTES, StringComparison.Ordinal))

View file

@ -69,7 +69,7 @@ public sealed class BatchEditor
/// </summary>
/// <param name="lines">Batch instruction line(s)</param>
/// <param name="data">Entities to modify</param>
/// <returns>Editor object if follow up modifications are desired.</returns>
/// <returns>Editor object if follow-up modifications are desired.</returns>
public static BatchEditor Execute(ReadOnlySpan<string> lines, IEnumerable<PKM> data)
{
var editor = new BatchEditor();

View file

@ -11,8 +11,8 @@ public static class BatchFilters
/// <summary>
/// Filters to use for <see cref="BatchEditing"/> that are derived from the <see cref="PKM"/> data.
/// </summary>
public static readonly List<IComplexFilter> FilterMods = new()
{
public static readonly List<IComplexFilter> FilterMods =
[
new ComplexFilter(PROP_LEGAL,
(pk, cmd) => bool.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == new LegalityAnalysis(pk).Valid),
(info, cmd) => bool.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == info.Legality.Valid)),
@ -32,13 +32,13 @@ public static class BatchFilters
new ComplexFilter(PROP_TYPEEITHER,
(pk, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(pk.PersonalInfo.IsType(b)),
(info, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(info.Entity.PersonalInfo.IsType(b))),
};
];
/// <summary>
/// Filters to use for <see cref="BatchEditing"/> that are derived from the <see cref="PKM"/> source.
/// </summary>
public static readonly List<IComplexFilterMeta> FilterMeta = new()
{
public static readonly List<IComplexFilterMeta> FilterMeta =
[
new MetaFilter(IdentifierContains,
(obj, cmd) => obj is SlotCache s && cmd.Comparer.IsCompareEquivalence(s.Identify().Contains(cmd.PropertyValue))),
@ -47,5 +47,5 @@ public static class BatchFilters
new MetaFilter(nameof(ISlotInfo.Slot),
(obj, cmd) => obj is SlotCache s && int.TryParse(cmd.PropertyValue, out var slot) && cmd.Comparer.IsCompareOperator((s.Source.Slot + 1).CompareTo(slot))),
};
];
}

View file

@ -10,8 +10,8 @@ namespace PKHeX.Core;
/// </summary>
public static class BatchMods
{
public static readonly List<ISuggestModification> SuggestionMods = new()
{
public static readonly List<ISuggestModification> SuggestionMods =
[
// Interface Specific
new TypeSuggestion<ICombatPower>(nameof(ICombatPower.Stat_CP), p => p.ResetCP()),
new TypeSuggestion<IScaledSizeValue>(nameof(IScaledSizeValue.HeightAbsolute), p => p.ResetHeight()),
@ -49,13 +49,12 @@ public static class BatchMods
new ComplexSuggestion(nameof(PKM.CurrentLevel), (_, _, info) => BatchModifications.SetMinimumCurrentLevel(info)),
new ComplexSuggestion(PROP_CONTESTSTATS, p => p is IContestStats, (_, value, info) => BatchModifications.SetContestStats(info.Entity, info.Legality, value)),
new ComplexSuggestion(PROP_MOVEMASTERY, (_, value, info) => BatchModifications.SetSuggestedMasteryData(info, value)),
};
];
private static DateOnly ParseDate(ReadOnlySpan<char> val) => DateOnly.ParseExact(val, "yyyyMMdd", CultureInfo.InvariantCulture);
public static readonly List<IComplexSet> ComplexMods = new()
{
// Date
public static readonly List<IComplexSet> ComplexMods =
[
new ComplexSet(nameof(PKM.MetDate), (pk, cmd) => pk.MetDate = ParseDate(cmd.PropertyValue)),
new ComplexSet(nameof(PKM.EggMetDate), (pk, cmd) => pk.EggMetDate = ParseDate(cmd.PropertyValue)),
@ -84,7 +83,7 @@ public static class BatchMods
// Complicated
new ComplexSet(nameof(PKM.EncryptionConstant), value => value.StartsWith(CONST_RAND), (pk, cmd) => pk.EncryptionConstant = CommonEdits.GetComplicatedEC(pk, option: cmd.PropertyValue[^1])),
};
];
private static void SetRandomTeraType(PKM pk)
{

View file

@ -1,24 +1,14 @@
using System;
using System;
namespace PKHeX.Core;
/// <inheritdoc cref="IComplexFilter"/>
public sealed class ComplexFilter : IComplexFilter
public sealed class ComplexFilter(
string Property,
Func<PKM, StringInstruction, bool> FilterPKM,
Func<BatchInfo, StringInstruction, bool> FilterBulk)
: IComplexFilter
{
private readonly string Property;
private readonly Func<PKM, StringInstruction, bool> FilterPKM;
private readonly Func<BatchInfo, StringInstruction, bool> FilterBulk;
public ComplexFilter(
string property,
Func<PKM, StringInstruction, bool> filterPkm,
Func<BatchInfo, StringInstruction, bool> filterBulk)
{
Property = property;
FilterPKM = filterPkm;
FilterBulk = filterBulk;
}
public bool IsMatch(string prop) => prop == Property;
public bool IsFiltered(PKM pk, StringInstruction value) => FilterPKM(pk, value);
public bool IsFiltered(BatchInfo info, StringInstruction value) => FilterBulk(info, value);

View file

@ -1,21 +1,14 @@
using System;
using System;
namespace PKHeX.Core;
/// <inheritdoc cref="IComplexSet"/>
public sealed class ComplexSet : IComplexSet
public sealed class ComplexSet(string PropertyName, Action<PKM, StringInstruction> Action) : IComplexSet
{
public readonly string PropertyName;
public readonly string PropertyName = PropertyName;
public readonly Func<string, bool> IsValueCompatible = _ => true;
private readonly Action<PKM, StringInstruction> Action;
public ComplexSet(string propertyName, Action<PKM, StringInstruction> modify)
{
PropertyName = propertyName;
Action = modify;
}
public ComplexSet(string propertyName, Func<string, bool> criteria, Action<PKM, StringInstruction> modify) : this(propertyName, modify) => IsValueCompatible = criteria;
public ComplexSet(string PropertyName, Func<string, bool> criteria, Action<PKM, StringInstruction> Action) : this(PropertyName, Action) => IsValueCompatible = criteria;
public bool IsMatch(string name, string value) => name == PropertyName && IsValueCompatible(value);

View file

@ -1,21 +1,13 @@
using System;
using System;
namespace PKHeX.Core;
/// <inheritdoc cref="IComplexFilter"/>
public sealed class MetaFilter : IComplexFilterMeta
public sealed class MetaFilter(
string Property,
Func<object, StringInstruction, bool> FilterPKM)
: IComplexFilterMeta
{
private readonly string Property;
private readonly Func<object, StringInstruction, bool> FilterPKM;
public MetaFilter(
string property,
Func<object, StringInstruction, bool> filterPkm)
{
Property = property;
FilterPKM = filterPkm;
}
public bool IsMatch(string prop) => prop == Property;
public bool IsFiltered(object pk, StringInstruction value) => FilterPKM(pk, value);
}

View file

@ -16,21 +16,17 @@ namespace PKHeX.Core;
/// <see cref="FilterNotEqual"/>
/// <see cref="FilterEqual"/>
/// <see cref="Apply"/>
public sealed class StringInstruction
public sealed class StringInstruction(string PropertyName, string PropertyValue)
{
/// <summary> Property to modify. </summary>
public string PropertyName { get; }
public string PropertyName { get; } = PropertyName;
/// <summary> Value to set to the property. </summary>
public string PropertyValue { get; private set; }
public string PropertyValue { get; private set; } = PropertyValue;
/// <summary> Filter Comparison Type </summary>
public InstructionComparer Comparer { get; private init; }
public StringInstruction(string name, string value)
{
PropertyName = name;
PropertyValue = value;
}
public void SetScreenedValue(ReadOnlySpan<string> arr)
{
int index = arr.IndexOf(PropertyValue);
@ -41,7 +37,12 @@ public sealed class StringInstruction
/// <summary>
/// Valid prefixes that are recognized for <see cref="InstructionComparer"/> value comparison types.
/// </summary>
public static ReadOnlySpan<char> Prefixes => new[] { Apply, FilterEqual, FilterNotEqual, FilterGreaterThan, FilterGreaterThanOrEqual, FilterLessThan, FilterLessThanOrEqual };
public static ReadOnlySpan<char> Prefixes =>
[
Apply,
FilterEqual, FilterNotEqual, FilterGreaterThan, FilterGreaterThanOrEqual, FilterLessThan, FilterLessThanOrEqual,
];
private const char Apply = '.';
private const char SplitRange = ',';
@ -292,8 +293,6 @@ public sealed class StringInstruction
/// <summary>
/// Gets the <see cref="InstructionComparer"/> from the input <see cref="opCode"/>.
/// </summary>
/// <param name="opCode"></param>
/// <returns></returns>
public static InstructionComparer GetComparer(char opCode) => opCode switch
{
FilterEqual => IsEqual,

View file

@ -1,30 +1,25 @@
using System;
using System;
namespace PKHeX.Core;
/// <inheritdoc cref="ISuggestModification"/>
public sealed class ComplexSuggestion : ISuggestModification
public sealed class ComplexSuggestion(
string Keyword,
Func<string, string, BatchInfo, ModifyResult> Action)
: ISuggestModification
{
public readonly string Keyword;
public readonly string Keyword = Keyword;
public readonly Func<PKM, bool> Criteria = _ => true;
public readonly Func<string, string, BatchInfo, ModifyResult> Action;
public readonly Func<string, string, BatchInfo, ModifyResult> Action = Action;
public ComplexSuggestion(
string keyword,
string Keyword,
Func<PKM, bool> criteria,
Func<string, string, BatchInfo, ModifyResult> action) : this(keyword, action)
Func<string, string, BatchInfo, ModifyResult> action) : this(Keyword, action)
{
Criteria = criteria;
}
public ComplexSuggestion(
string keyword,
Func<string, string, BatchInfo, ModifyResult> action)
{
Keyword = keyword;
Action = action;
}
public bool IsMatch(string name, string value, BatchInfo info)
{
return name == Keyword && Criteria(info.Entity);

View file

@ -1,22 +1,16 @@
using System;
using System;
namespace PKHeX.Core;
/// <inheritdoc cref="ISuggestModification"/>
/// <typeparam name="T">Specific (or not) type</typeparam>
public sealed class TypeSuggestion<T> : ISuggestModification
public sealed class TypeSuggestion<T>(string Keyword, Action<T> Action) : ISuggestModification
{
public readonly string Keyword;
public readonly Action<T, string> Action;
public readonly string Keyword = Keyword;
public readonly Action<T, string> Action = (pk, _) => Action(pk);
public readonly Func<T, bool> Criteria = _ => true;
public TypeSuggestion(string keyword, Action<T> action)
{
Keyword = keyword;
Action = (pk, _) => action(pk);
}
public TypeSuggestion(string keyword, Func<T, bool> criteria, Action<T> action) : this(keyword, action)
public TypeSuggestion(string Keyword, Func<T, bool> criteria, Action<T> action) : this(Keyword, action)
{
Criteria = criteria;
}

View file

@ -172,18 +172,18 @@ public static class CommonEdits
{
// In Generation 1/2 Format sets, when IVs are not specified with a Hidden Power set, we might not have the hidden power type.
// Under this scenario, just force the Hidden Power type.
if (Array.IndexOf(Set.Moves, (ushort)Move.HiddenPower) != -1 && pk.HPType != Set.HiddenPowerType)
if (Array.IndexOf(Set.Moves, (ushort)Move.HiddenPower) != -1 && gb.HPType != Set.HiddenPowerType)
{
if (Set.IVs.AsSpan().IndexOfAny(30, 31) >= 0)
pk.SetHiddenPower(Set.HiddenPowerType);
if (Set.IVs.AsSpan().ContainsAny(30, 31))
gb.SetHiddenPower(Set.HiddenPowerType);
}
// In Generation 1/2 Format sets, when EVs are not specified at all, it implies maximum EVs instead!
// Under this scenario, just apply maximum EVs (65535).
if (Set.EVs.AsSpan().IndexOfAnyExcept(0) == -1)
if (!Set.EVs.AsSpan().ContainsAnyExcept(0))
gb.MaxEVs();
else
pk.SetEVs(Set.EVs);
gb.SetEVs(Set.EVs);
}
else
{
@ -191,7 +191,7 @@ public static class CommonEdits
}
// IVs have no side effects such as hidden power type in gen 8
// therefore all specified IVs are deliberate and should not be Hyper Trained for pokemon met in gen 8
// therefore all specified IVs are deliberate and should not be Hyper Trained for Pokémon met in gen 8
if (pk.Generation < 8)
pk.SetSuggestedHyperTrainingData(Set.IVs);

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core;
/// </summary>
public sealed class TrainerDatabase
{
private readonly Dictionary<GameVersion, List<ITrainerInfo>> Database = new();
private readonly Dictionary<GameVersion, List<ITrainerInfo>> Database = [];
/// <summary>
/// Fetches an appropriate trainer based on the requested <see cref="version"/>.
@ -104,7 +104,7 @@ public sealed class TrainerDatabase
ver = s.Version;
if (!Database.TryGetValue(ver, out var list))
{
Database.Add(ver, new List<ITrainerInfo> { trainer });
Database.Add(ver, [trainer]);
return;
}
@ -127,7 +127,7 @@ public sealed class TrainerDatabase
/// <remarks>A copy of the object will be made to prevent modifications, just in case.</remarks>
public void RegisterCopy(ITrainerInfo info) => Register(new SimpleTrainerInfo(info));
private static ITrainerInfo GetTrainerReference(PKM pk)
private static SimpleTrainerInfo GetTrainerReference(PKM pk)
{
var result = new SimpleTrainerInfo((GameVersion)pk.Version)
{

View file

@ -33,8 +33,8 @@ public static class HiddenPower
return SixBitType[hp];
}
private static ReadOnlySpan<byte> SixBitType => new byte[]
{
private static ReadOnlySpan<byte> SixBitType =>
[
// (low-bit mash) * 15 / 63
00, 00, 00, 00, 00, 01, 01, 01,
01, 02, 02, 02, 02, 03, 03, 03,
@ -44,7 +44,7 @@ public static class HiddenPower
09, 09, 10, 10, 10, 10, 10, 11,
11, 11, 11, 12, 12, 12, 12, 13,
13, 13, 13, 14, 14, 14, 14, 15,
};
];
/// <summary>
/// Gets the current Hidden Power Type of the input <see cref="IVs"/> for Generations 1 &amp; 2
@ -58,6 +58,9 @@ public static class HiddenPower
return ((atk & 3) << 2) | (def & 3);
}
/// <inheritdoc cref="GetTypeGB(ReadOnlySpan{int})"/>
public static int GetTypeGB(ushort u16) => ((u16 >> 12) & 0b1100) | ((u16 >> 8) & 0b11);
/// <summary>
/// Modifies the provided <see cref="IVs"/> to have the requested <see cref="hiddenPowerType"/> for Generations 1 &amp; 2
/// </summary>
@ -71,6 +74,14 @@ public static class HiddenPower
return true;
}
/// <inheritdoc cref="SetTypeGB(int, Span{int})"/>
public static ushort SetTypeGB(int hiddenPowerType, ushort current)
{
// Extract bits from ATK and DEF.
var u16 = ((hiddenPowerType & 0b1100) << 12) | ((hiddenPowerType & 0b11) << 8);
return (ushort)((current & 0b1100_1100_1111_1111) | u16);
}
/// <summary>
/// Modifies the provided <see cref="IVs"/> to have the requested <see cref="hiddenPowerType"/>.
/// </summary>
@ -190,8 +201,8 @@ public static class HiddenPower
/// These are just precomputed for fast modification.
/// Individual Values (H/A/B/S/C/D)
/// </remarks>
public static ReadOnlySpan<byte> DefaultLowBits => new byte[]
{
public static ReadOnlySpan<byte> DefaultLowBits =>
[
0b000011, // Fighting
0b001000, // Flying
0b001011, // Poison
@ -208,5 +219,5 @@ public static class HiddenPower
0b111001, // Ice
0b111101, // Dragon
0b111111, // Dark
};
];
}

View file

@ -17,7 +17,7 @@ public static class NatureAmp
/// <returns>New nature value</returns>
public static int GetNewNature(this NatureAmpRequest type, int statIndex, int currentNature)
{
if (currentNature > (int)Nature.Quirky)
if (currentNature >= NatureCount)
return -1;
var (up, dn) = GetNatureModification(currentNature);
@ -105,6 +105,64 @@ public static class NatureAmp
upStat = (ushort)((upStat * 11) / 10);
dnStat = (ushort)((dnStat * 9) / 10);
}
/// <summary>
/// Nature Amplification Table
/// </summary>
/// <remarks>-1 is 90%, 0 is 100%, 1 is 110%.</remarks>
public static ReadOnlySpan<sbyte> Table =>
[
0, 0, 0, 0, 0, // Hardy
1,-1, 0, 0, 0, // Lonely
1, 0, 0, 0,-1, // Brave
1, 0,-1, 0, 0, // Adamant
1, 0, 0,-1, 0, // Naughty
-1, 1, 0, 0, 0, // Bold
0, 0, 0, 0, 0, // Docile
0, 1, 0, 0,-1, // Relaxed
0, 1,-1, 0, 0, // Impish
0, 1, 0,-1, 0, // Lax
-1, 0, 0, 0, 1, // Timid
0,-1, 0, 0, 1, // Hasty
0, 0, 0, 0, 0, // Serious
0, 0,-1, 0, 1, // Jolly
0, 0, 0,-1, 1, // Naive
-1, 0, 1, 0, 0, // Modest
0,-1, 1, 0, 0, // Mild
0, 0, 1, 0,-1, // Quiet
0, 0, 0, 0, 0, // Bashful
0, 0, 1,-1, 0, // Rash
-1, 0, 0, 1, 0, // Calm
0,-1, 0, 1, 0, // Gentle
0, 0, 0, 1,-1, // Sassy
0, 0,-1, 1, 0, // Careful
0, 0, 0, 0, 0, // Quirky
];
private const int NatureCount = 25;
private const int AmpWidth = 5;
public static int AmplifyStat(int nature, int index, int initial) => GetNatureAmp(nature, index) switch
{
1 => 110 * initial / 100, // 110%
-1 => 90 * initial / 100, // 90%
_ => initial,
};
private static sbyte GetNatureAmp(int nature, int index)
{
if ((uint)nature >= NatureCount)
return -1;
var amps = GetAmps(nature);
return amps[index];
}
public static ReadOnlySpan<sbyte> GetAmps(int nature)
{
if ((uint)nature >= NatureCount)
nature = 0;
return Table.Slice(AmpWidth * nature, AmpWidth);
}
}
public enum NatureAmpRequest

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core;
@ -10,16 +9,16 @@ namespace PKHeX.Core;
public sealed class LegalMoveComboSource : ILegalMoveDisplaySource<ComboItem>
{
private readonly bool[] IsMoveBoxOrdered = new bool[4];
private ComboItem[] MoveDataAllowed = Array.Empty<ComboItem>();
private ComboItem[] MoveDataAllowed = [];
public IReadOnlyList<ComboItem> DataSource => (ComboItem[])MoveDataAllowed.Clone();
public IReadOnlyList<ComboItem> DataSource => [.. MoveDataAllowed]; // copy
/// <summary>
/// Resets the <see cref="MoveDataAllowed"/> data source with an updated collection.
/// </summary>
public void ReloadMoves(IReadOnlyList<ComboItem> moves)
{
MoveDataAllowed = moves.ToArray();
MoveDataAllowed = [.. moves]; // copy
ClearUpdateCheck();
}
@ -35,7 +34,7 @@ public sealed class LegalMoveComboSource : ILegalMoveDisplaySource<ComboItem>
private void SortMoves(LegalMoveInfo info) => Array.Sort(MoveDataAllowed, (i1, i2) => Compare(i1, i2, info.CanLearn));
// defer re-population until dropdown is opened; handled by dropdown event
private void ClearUpdateCheck() => Array.Clear(IsMoveBoxOrdered, 0, IsMoveBoxOrdered.Length);
private void ClearUpdateCheck() => IsMoveBoxOrdered.AsSpan().Clear();
private static int Compare(ComboItem i1, ComboItem i2, Func<ushort, bool> check)
{

View file

@ -15,8 +15,8 @@ public sealed class LegalMoveInfo
/// <summary>
/// Checks if the requested <see cref="move"/> is legally able to be learned.
/// </summary>
/// <param name="move">Move to check if can be learned</param>
/// <returns>True if can learn the move</returns>
/// <param name="move">Move to check if it can be learned</param>
/// <returns>True if it can learn the move</returns>
public bool CanLearn(ushort move) => AllowedMoves[move];
/// <summary>

View file

@ -5,12 +5,10 @@ namespace PKHeX.Core;
/// <summary>
/// Legal Move information for a single <see cref="PKM"/>, for indicating if a move is legal or not.
/// </summary>
public sealed class LegalMoveSource<T>
public sealed class LegalMoveSource<T>(ILegalMoveDisplaySource<T> Display)
{
public LegalMoveInfo Info { get; } = new();
public readonly ILegalMoveDisplaySource<T> Display;
public LegalMoveSource(ILegalMoveDisplaySource<T> display) => Display = display;
public readonly ILegalMoveDisplaySource<T> Display = Display;
public void ReloadMoves(LegalityAnalysis source)
{

View file

@ -6,8 +6,10 @@ namespace PKHeX.Core;
/// <summary>
/// Generation 7 PGL QR Code encoded <see cref="PKM"/> entities.
/// </summary>
public sealed class QRPK7 : IEncounterInfo
public sealed class QRPK7(byte[] Data) : IEncounterInfo
{
private readonly byte[] Data = (byte[])Data.Clone();
public GameVersion Version => (GameVersion)CassetteVersion;
public bool EggEncounter => false;
public byte LevelMin => Level;
@ -16,9 +18,7 @@ public sealed class QRPK7 : IEncounterInfo
public EntityContext Context => EntityContext.Gen7;
public bool IsShiny => false;
private readonly byte[] Data;
public const int SIZE = 0x30;
public QRPK7(byte[] d) => Data = (byte[])d.Clone();
public uint EncryptionConstant => ReadUInt32LittleEndian(Data.AsSpan(0));
public byte HT_Flags => Data[4];

View file

@ -33,12 +33,12 @@ public static class QRPKM
string IVs = $"IVs: {pk.IV_HP:00}/{pk.IV_ATK:00}/{pk.IV_DEF:00}/{pk.IV_SPA:00}/{pk.IV_SPD:00}/{pk.IV_SPE:00}";
string EVs = $"EVs: {pk.EV_HP:00}/{pk.EV_ATK:00}/{pk.EV_DEF:00}/{pk.EV_SPA:00}/{pk.EV_SPD:00}/{pk.EV_SPE:00}";
return new[]
{
return
[
string.Join(" ", header),
sb.ToString(),
IVs + " " + EVs,
};
];
}
private static IEnumerable<string> GetHeader(PKM pk, GameStrings s)

View file

@ -63,7 +63,7 @@ public static class Pokerus
/// <inheritdoc cref="IsStrainValid(PKM,int,int)"/>
/// <remarks>
/// Gen3 R/S have a 30/255 chance of giving strain 0, and a 1/255 chance of giving strain 8.
/// Transfers will retain strain 0/8 and they're still able to infect others.
/// Transfers will retain strain 0/8, and they're still able to infect others.
/// </remarks>
public static bool IsStrainValid(int strain) => strain <= 0xF;
@ -102,11 +102,11 @@ public static class Pokerus
/// </summary>
/// <param name="strain">Strain number</param>
/// <param name="days">Duration remaining</param>
/// <returns>True if can be infected by another infectious individual.</returns>
/// <returns>True if it can be infected by another infectious individual.</returns>
public static bool IsSusceptible(int strain, int days) => strain == 0 && days == 0;
/// <summary>
/// Vaccinates the Pokémon so it will never be infectious in the format it exists in.
/// Vaccinates the Pokémon, so it will never be infectious in the format it exists in.
/// </summary>
/// <param name="pk">Entity to modify.</param>
/// <remarks>Overwrites all Pokérus values even if already legal.</remarks>

View file

@ -1,4 +1,4 @@
namespace PKHeX.Core;
namespace PKHeX.Core;
/// <summary>
/// Option to load a save file automatically to an editing environment.
@ -6,7 +6,7 @@
public enum AutoLoadSetting
{
/// <summary>
/// Doesn't auto load a save file, and instead uses a fake save file data.
/// Doesn't autoload a save file, and instead uses a fake save file data.
/// </summary>
Disabled,

View file

@ -16,7 +16,7 @@ public sealed class StartupArguments
// ReSharper disable once UnassignedGetOnlyAutoProperty
public Exception? Error { get; }
// ReSharper disable once CollectionNeverQueried.Global
public readonly List<object> Extra = new();
public readonly List<object> Extra = [];
/// <summary>
/// Step 1: Reads in command line arguments.

View file

@ -1,15 +1,13 @@
using System;
using System;
namespace PKHeX.Core;
/// <summary>
/// Clears contents of boxes by deleting all that satisfy a <see cref="Criteria"/>.
/// Clears contents of boxes by deleting all that satisfy a criteria.
/// </summary>
public sealed class BoxManipClear : BoxManipBase
public sealed class BoxManipClear(BoxManipType Type, Func<PKM, bool> criteria, Func<SaveFile, bool> Usable) : BoxManipBase(Type, Usable)
{
private readonly Func<PKM, bool> Criteria;
public BoxManipClear(BoxManipType type, Func<PKM, bool> criteria) : this(type, criteria, _ => true) { }
public BoxManipClear(BoxManipType type, Func<PKM, bool> criteria, Func<SaveFile, bool> usable) : base(type, usable) => Criteria = criteria;
public BoxManipClear(BoxManipType Type, Func<PKM, bool> Criteria) : this(Type, Criteria, _ => true) { }
public override string GetPrompt(bool all) => all ? MessageStrings.MsgSaveBoxClearAll : MessageStrings.MsgSaveBoxClearCurrent;
public override string GetFail(bool all) => all ? MessageStrings.MsgSaveBoxClearAllFailBattle : MessageStrings.MsgSaveBoxClearCurrentFailBattle;
@ -18,7 +16,8 @@ public sealed class BoxManipClear : BoxManipBase
public override int Execute(SaveFile sav, BoxManipParam param)
{
var (start, stop, reverse) = param;
bool Method(PKM p) => reverse ^ Criteria(p);
return sav.ClearBoxes(start, stop, Method);
bool Method(PKM p) => reverse ^ criteria(p);
}
}

View file

@ -1,15 +1,13 @@
using System;
using System;
namespace PKHeX.Core;
/// <summary>
/// Clears contents of boxes by deleting all that satisfy a <see cref="Criteria"/> based on a <see cref="SaveFile"/>.
/// Clears contents of boxes by deleting all that satisfy a criteria based on a <see cref="SaveFile"/>.
/// </summary>
public sealed class BoxManipClearComplex : BoxManipBase
public sealed class BoxManipClearComplex(BoxManipType Type, Func<PKM, SaveFile, bool> criteria, Func<SaveFile, bool> Usable) : BoxManipBase(Type, Usable)
{
private readonly Func<PKM, SaveFile, bool> Criteria;
public BoxManipClearComplex(BoxManipType type, Func<PKM, SaveFile, bool> criteria) : this(type, criteria, _ => true) { }
public BoxManipClearComplex(BoxManipType type, Func<PKM, SaveFile, bool> criteria, Func<SaveFile, bool> usable) : base(type, usable) => Criteria = criteria;
public BoxManipClearComplex(BoxManipType Type, Func<PKM, SaveFile, bool> Criteria) : this(Type, Criteria, _ => true) { }
public override string GetPrompt(bool all) => all ? MessageStrings.MsgSaveBoxClearAll : MessageStrings.MsgSaveBoxClearCurrent;
public override string GetFail(bool all) => all ? MessageStrings.MsgSaveBoxClearAllFailBattle : MessageStrings.MsgSaveBoxClearCurrentFailBattle;
@ -18,7 +16,8 @@ public sealed class BoxManipClearComplex : BoxManipBase
public override int Execute(SaveFile sav, BoxManipParam param)
{
var (start, stop, reverse) = param;
bool Method(PKM p) => reverse ^ Criteria(p, sav);
return sav.ClearBoxes(start, stop, Method);
bool Method(PKM p) => reverse ^ criteria(p, sav);
}
}

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
namespace PKHeX.Core;
@ -9,7 +9,7 @@ namespace PKHeX.Core;
/// <typeparam name="T">Base type of the "is duplicate" hash for the duplicate detection.</typeparam>
public sealed class BoxManipClearDuplicate<T> : BoxManipBase
{
private readonly HashSet<T> HashSet = new();
private readonly HashSet<T> HashSet = [];
private readonly Func<PKM, bool> Criteria;
public BoxManipClearDuplicate(BoxManipType type, Func<PKM, T> criteria) : this(type, criteria, _ => true) { }
@ -18,10 +18,7 @@ public sealed class BoxManipClearDuplicate<T> : BoxManipBase
Criteria = pk =>
{
var result = criteria(pk);
if (HashSet.Contains(result))
return true;
HashSet.Add(result);
return false;
return !HashSet.Add(result);
};
}
@ -33,7 +30,8 @@ public sealed class BoxManipClearDuplicate<T> : BoxManipBase
{
HashSet.Clear();
var (start, stop, reverse) = param;
bool Method(PKM p) => reverse ^ Criteria(p);
return sav.ClearBoxes(start, stop, Method);
bool Method(PKM p) => reverse ^ Criteria(p);
}
}

View file

@ -1,15 +1,14 @@
using System;
using System;
namespace PKHeX.Core;
/// <summary>
/// Modifies contents of boxes by using an <see cref="Action"/> to change data.
/// </summary>
public sealed class BoxManipModify : BoxManipBase
public sealed class BoxManipModify(BoxManipType type, Action<PKM> Action, Func<SaveFile, bool> Usable)
: BoxManipBase(type, Usable)
{
private readonly Action<PKM> Action;
public BoxManipModify(BoxManipType type, Action<PKM> action) : this(type, action, _ => true) { }
public BoxManipModify(BoxManipType type, Action<PKM> action, Func<SaveFile, bool> usable) : base(type, usable) => Action = action;
public BoxManipModify(BoxManipType type, Action<PKM> Action) : this(type, Action, _ => true) { }
public override string GetPrompt(bool all) => string.Empty;
public override string GetFail(bool all) => string.Empty;

View file

@ -1,15 +1,14 @@
using System;
using System;
namespace PKHeX.Core;
/// <summary>
/// Modifies contents of boxes by using an <see cref="Action"/> (referencing a Save File) to change data.
/// </summary>
public sealed class BoxManipModifyComplex : BoxManipBase
public sealed class BoxManipModifyComplex(BoxManipType Type, Action<PKM, SaveFile> Action, Func<SaveFile, bool> Usable)
: BoxManipBase(Type, Usable)
{
private readonly Action<PKM, SaveFile> Action;
public BoxManipModifyComplex(BoxManipType type, Action<PKM, SaveFile> action) : this(type, action, _ => true) { }
public BoxManipModifyComplex(BoxManipType type, Action<PKM, SaveFile> action, Func<SaveFile, bool> usable) : base(type, usable) => Action = action;
public BoxManipModifyComplex(BoxManipType Type, Action<PKM, SaveFile> Action) : this(Type, Action, _ => true) { }
public override string GetPrompt(bool all) => string.Empty;
public override string GetFail(bool all) => string.Empty;

View file

@ -1,16 +1,14 @@
using System;
using System;
using System.Collections.Generic;
namespace PKHeX.Core;
/// <summary>
/// Sorts contents of boxes by using a <see cref="Sorter"/> to determine the order.
/// Sorts contents of boxes by using a Sorter to determine the order.
/// </summary>
public sealed class BoxManipSort : BoxManipBase
public sealed class BoxManipSort(BoxManipType Type, Func<IEnumerable<PKM>, IEnumerable<PKM>> Sorter, Func<SaveFile, bool> Usable) : BoxManipBase(Type, Usable)
{
private readonly Func<IEnumerable<PKM>, IEnumerable<PKM>> Sorter;
public BoxManipSort(BoxManipType type, Func<IEnumerable<PKM>, IEnumerable<PKM>> sorter) : this(type, sorter, _ => true) { }
public BoxManipSort(BoxManipType type, Func<IEnumerable<PKM>, IEnumerable<PKM>> sorter, Func<SaveFile, bool> usable) : base(type, usable) => Sorter = sorter;
public BoxManipSort(BoxManipType Type, Func<IEnumerable<PKM>, IEnumerable<PKM>> Sorter) : this(Type, Sorter, _ => true) { }
public override string GetPrompt(bool all) => all ? MessageStrings.MsgSaveBoxSortAll : MessageStrings.MsgSaveBoxSortCurrent;
public override string GetFail(bool all) => all ? MessageStrings.MsgSaveBoxSortAllFailBattle: MessageStrings.MsgSaveBoxSortCurrentFailBattle;
@ -18,8 +16,9 @@ public sealed class BoxManipSort : BoxManipBase
public override int Execute(SaveFile sav, BoxManipParam param)
{
IEnumerable<PKM> Method(IEnumerable<PKM> p, int index) => Sorter(p);
var (start, stop, reverse) = param;
return sav.SortBoxes(start, stop, Method, reverse);
IEnumerable<PKM> Method(IEnumerable<PKM> p, int index) => Sorter(p);
}
}

View file

@ -12,12 +12,12 @@ public static class BoxManipUtil
/// Grouped categories of different <see cref="IBoxManip"/>.
/// </summary>
public static readonly IReadOnlyList<IBoxManip>[] ManipCategories =
{
[
BoxManipDefaults.ClearCommon,
BoxManipDefaults.SortCommon,
BoxManipDefaults.SortAdvanced,
BoxManipDefaults.ModifyCommon,
};
];
/// <summary>
/// Manipulation Group Names to be used for uniquely naming groups of GUI controls.
@ -26,12 +26,12 @@ public static class BoxManipUtil
/// Order should match that of <see cref="ManipCategories"/>.
/// </remarks>
public static readonly string[] ManipCategoryNames =
{
[
"Delete",
"Sort",
"SortAdvanced",
"Modify",
};
];
/// <summary>
/// Gets a <see cref="IBoxManip"/> reference that carries out the action of the requested <see cref="type"/>.

View file

@ -13,7 +13,7 @@ public static class EventLabelParsing
private const char Split = '\t';
private static readonly NamedEventConst Custom = new("Custom", NamedEventConst.CustomMagicValue);
private static readonly NamedEventConst[] Empty = { Custom };
private static readonly NamedEventConst[] Empty = [Custom];
public static List<NamedEventValue> GetFlags(ReadOnlySpan<string> strings, int maxValue = int.MaxValue)
{
@ -45,14 +45,13 @@ public static class EventLabelParsing
return result;
}
private static void SanityCheck(NamedEventValue item, ISet<int> processed, int maxValue)
private static void SanityCheck(NamedEventValue item, ISet<int> processed, int maxValue) => SanityCheck(processed, maxValue, item.Index);
private static void SanityCheck(ISet<int> processed, int maxValue, int index)
{
var index = item.Index;
if (index >= maxValue)
throw new ArgumentOutOfRangeException(nameof(index), index, "Value too high.");
if (processed.Contains(index))
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, maxValue);
if (!processed.Add(index))
throw new ArgumentOutOfRangeException(nameof(index), index, "Already have an entry for this!");
processed.Add(index);
}
public static bool TryParseValue(ReadOnlySpan<char> value, [NotNullWhen(true)] out NamedEventValue? result)
@ -115,9 +114,9 @@ public static class EventLabelParsing
return (desc, predefined);
}
private static IReadOnlyList<NamedEventConst> GetPredefinedArray(ReadOnlySpan<char> combined)
private static List<NamedEventConst> GetPredefinedArray(ReadOnlySpan<char> combined)
{
var result = new List<NamedEventConst>(Empty);
List<NamedEventConst> result = [..Empty];
// x:y tuples separated by ,
while (true)

View file

@ -1,9 +1,7 @@
namespace PKHeX.Core;
public sealed class EventUnlocker8b : EventUnlocker<SAV8BS>
public sealed class EventUnlocker8b(SAV8BS sav) : EventUnlocker<SAV8BS>(sav)
{
public EventUnlocker8b(SAV8BS sav) : base(sav) { }
public bool UnlockReadySpiritomb => SAV.UgSaveData.TalkedNPC < 32;
public bool UnlockReadyBoxLegend => SAV.FlagWork.GetFlag(308) && SAV.FlagWork.GetWork(84) != 5; // FE_D05R0114_SPPOKE_GET, WK_SCENE_D05R0114 (1-3 story related, 4 = captured, 5 = can retry)
public bool UnlockReadyShaymin => SAV.FlagWork.GetFlag(545) || !(SAV.FlagWork.GetWork(276) == 1 && SAV.Zukan.HasNationalDex && SAV.Items.GetItemQuantity(452) == 1 && SAV.FlagWork.GetSystemFlag(5)); // HAIHUEVENT_ID_D30, Oak's Letter

View file

@ -11,10 +11,10 @@ namespace PKHeX.Core;
/// </summary>
public sealed class EventBlockDiff<T, T2> : IEventWorkDiff where T : class, IEventFlagArray, IEventWorkArray<T2> where T2 : unmanaged, IEquatable<T2>
{
public List<int> SetFlags { get; } = new();
public List<int> ClearedFlags { get; } = new();
public List<int> WorkChanged { get; } = new();
public List<string> WorkDiff { get; } = new();
public List<int> SetFlags { get; } = [];
public List<int> ClearedFlags { get; } = [];
public List<int> WorkChanged { get; } = [];
public List<string> WorkDiff { get; } = [];
public EventWorkDiffCompatibility Message { get; private set; }
private const int MAX_SAVEFILE_SIZE = 0x10_0000; // 1 MB

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static PKHeX.Core.EventWorkUtil;
@ -10,10 +9,10 @@ namespace PKHeX.Core;
public sealed class EventWorkDiff7b : IEventWorkDiff
{
private SAV7b? S1;
public List<int> SetFlags { get; } = new();
public List<int> ClearedFlags { get; } = new();
public List<int> WorkChanged { get; } = new();
public List<string> WorkDiff { get; } = new();
public List<int> SetFlags { get; } = [];
public List<int> ClearedFlags { get; } = [];
public List<int> WorkChanged { get; } = [];
public List<string> WorkDiff { get; } = [];
public EventWorkDiffCompatibility Message { get; private set; }
private const int MAX_SAVEFILE_SIZE = 0x10_0000; // 1 MB
@ -53,7 +52,7 @@ public sealed class EventWorkDiff7b : IEventWorkDiff
public IReadOnlyList<string> Summarize()
{
if (S1 == null)
return Array.Empty<string>();
return [];
var ew = S1.Blocks.EventWork;
var fOn = SetFlags.Select(z => FlagSummary.Get(z, ew).ToString());

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static PKHeX.Core.EventWorkUtil;
@ -10,12 +9,12 @@ namespace PKHeX.Core;
public sealed class EventWorkDiff8b : IEventWorkDiff
{
private SAV8BS? S1;
public List<int> SetSystem { get; } = new();
public List<int> SetFlags { get; } = new();
public List<int> ClearedSystem { get; } = new();
public List<int> ClearedFlags { get; } = new();
public List<int> WorkChanged { get; } = new();
public List<string> WorkDiff { get; } = new();
public List<int> SetSystem { get; } = [];
public List<int> SetFlags { get; } = [];
public List<int> ClearedSystem { get; } = [];
public List<int> ClearedFlags { get; } = [];
public List<int> WorkChanged { get; } = [];
public List<string> WorkDiff { get; } = [];
public EventWorkDiffCompatibility Message { get; private set; }
private const int MAX_SAVEFILE_SIZE = 0x10_0000; // 1 MB
@ -55,7 +54,7 @@ public sealed class EventWorkDiff8b : IEventWorkDiff
public IReadOnlyList<string> Summarize()
{
if (S1 == null)
return Array.Empty<string>();
return [];
var fOn = SetFlags.Select(z => new FlagSummary(z).ToString());
var fOff = ClearedFlags.Select(z => new FlagSummary(z).ToString());

View file

@ -1,15 +1,11 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace PKHeX.Core;
/// <summary>
/// Event Flag that toggles certain features / entities on and off.
/// </summary>
public sealed class EventFlag : EventVar
public sealed class EventFlag(int index, EventVarType t, IReadOnlyList<string> pieces) : EventVar(index, t, pieces[1])
{
public bool Flag;
public EventFlag(int index, EventVarType t, IReadOnlyList<string> pieces) : base(index, t, pieces[1])
{
}
}

View file

@ -1,11 +1,9 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace PKHeX.Core;
public sealed class EventVarGroup
public sealed class EventVarGroup(EventVarType type)
{
public readonly EventVarType Type;
public readonly List<EventVar> Vars = new();
public EventVarGroup(EventVarType type) => Type = type;
public readonly EventVarType Type = type;
public readonly List<EventVar> Vars = [];
}

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core;
@ -42,7 +42,7 @@ public sealed class SplitEventEditor<T> where T : struct
}
/// <summary>
/// Writes all of the updated event values back to the block.
/// Writes all the updated event values back to the block.
/// </summary>
public void Save()
{

View file

@ -1,13 +1,11 @@
namespace PKHeX.Core;
namespace PKHeX.Core;
/// <summary>
/// Fakes the <see cref="IPKMView"/> interface interactions.
/// </summary>
public sealed class FakePKMEditor : IPKMView
public sealed class FakePKMEditor(PKM template) : IPKMView
{
public FakePKMEditor(PKM template) => Data = template;
public PKM Data { get; private set; }
public PKM Data { get; private set; } = template;
public bool Unicode => true;
public bool HaX => false;
public bool ChangingFields { get; set; }

View file

@ -1,20 +1,13 @@
using System;
using System;
namespace PKHeX.Core;
/// <summary>
/// Represents a Box Editor that loads the contents for easy manipulation.
/// </summary>
public sealed class BoxEdit
public sealed class BoxEdit(SaveFile SAV)
{
private readonly SaveFile SAV;
private readonly PKM[] CurrentContents;
public BoxEdit(SaveFile sav)
{
SAV = sav;
CurrentContents = new PKM[sav.BoxSlotCount];
}
private readonly PKM[] CurrentContents = new PKM[SAV.BoxSlotCount];
public void Reload() => LoadBox(CurrentBox);

View file

@ -29,7 +29,7 @@ public static partial class Extensions
return arr;
}
private static readonly List<SlotInfoMisc> None = new();
private static readonly List<SlotInfoMisc> None = [];
public static List<SlotInfoMisc> GetExtraSlots(this SaveFile sav, bool all = false) => sav switch
{
@ -50,20 +50,20 @@ public static partial class Extensions
private static List<SlotInfoMisc> GetExtraSlots2(SAV2 sav)
{
return new List<SlotInfoMisc>
{
return
[
new(sav.Data.AsMemory(sav.GetDaycareSlotOffset(0, 2)), 0) {Type = StorageSlotType.Daycare }, // egg
};
];
}
private static List<SlotInfoMisc> GetExtraSlots3(SAV3 sav)
{
if (sav is not SAV3FRLG)
return None;
return new List<SlotInfoMisc>
{
return
[
new(sav.Large.AsMemory(0x3C98), 0) {Type = StorageSlotType.Daycare},
};
];
}
private static List<SlotInfoMisc> GetExtraSlots4(SAV4 sav)
@ -99,8 +99,8 @@ public static partial class Extensions
private static List<SlotInfoMisc> GetExtraSlots6XY(SAV6XY sav)
{
return new List<SlotInfoMisc>
{
return
[
new(sav.Data, 0, sav.GTS) {Type = StorageSlotType.GTS},
new(sav.Data, 0, sav.Fused) {Type = StorageSlotType.Fused},
new(sav.Data, 0, sav.SUBE.Give) {Type = StorageSlotType.Misc}, // Old Man
@ -111,13 +111,13 @@ public static partial class Extensions
new(sav.Data, 3, sav.GetBattleBoxSlot(3)) {Type = StorageSlotType.BattleBox},
new(sav.Data, 4, sav.GetBattleBoxSlot(4)) {Type = StorageSlotType.BattleBox},
new(sav.Data, 5, sav.GetBattleBoxSlot(5)) {Type = StorageSlotType.BattleBox},
};
];
}
private static List<SlotInfoMisc> GetExtraSlots6AO(SAV6AO sav)
{
return new List<SlotInfoMisc>
{
return
[
new(sav.Data, 0, SAV6AO.GTS) {Type = StorageSlotType.GTS},
new(sav.Data, 0, SAV6AO.Fused) {Type = StorageSlotType.Fused},
new(sav.Data, 0, sav.SUBE.Give) {Type = StorageSlotType.Misc},
@ -128,7 +128,7 @@ public static partial class Extensions
new(sav.Data, 3, sav.GetBattleBoxSlot(3)) {Type = StorageSlotType.BattleBox},
new(sav.Data, 4, sav.GetBattleBoxSlot(4)) {Type = StorageSlotType.BattleBox},
new(sav.Data, 5, sav.GetBattleBoxSlot(5)) {Type = StorageSlotType.BattleBox},
};
];
}
private static List<SlotInfoMisc> GetExtraSlots7(SAV7 sav, bool all)
@ -164,10 +164,10 @@ public static partial class Extensions
private static List<SlotInfoMisc> GetExtraSlots7b(SAV7b sav)
{
return new List<SlotInfoMisc>
{
return
[
new(sav.Data, 0, sav.Blocks.GetBlockOffset(BelugaBlockIndex.Daycare) + 8, true) {Type = StorageSlotType.Daycare},
};
];
}
private static List<SlotInfoMisc> GetExtraSlots8(ISaveBlock8Main sav)
@ -198,8 +198,8 @@ public static partial class Extensions
private static List<SlotInfoMisc> GetExtraSlots8b(SAV8BS sav)
{
return new List<SlotInfoMisc>
{
return
[
new(sav.Data, 0, sav.UgSaveData.GetSlotOffset(0), true) { Type = StorageSlotType.Misc },
new(sav.Data, 1, sav.UgSaveData.GetSlotOffset(1), true) { Type = StorageSlotType.Misc },
new(sav.Data, 2, sav.UgSaveData.GetSlotOffset(2), true) { Type = StorageSlotType.Misc },
@ -209,12 +209,12 @@ public static partial class Extensions
new(sav.Data, 6, sav.UgSaveData.GetSlotOffset(6), true) { Type = StorageSlotType.Misc },
new(sav.Data, 7, sav.UgSaveData.GetSlotOffset(7), true) { Type = StorageSlotType.Misc },
new(sav.Data, 8, sav.UgSaveData.GetSlotOffset(8), true) { Type = StorageSlotType.Misc },
};
];
}
private static List<SlotInfoMisc> GetExtraSlots8a(SAV8LA _)
{
return new List<SlotInfoMisc>();
return [];
}
private static List<SlotInfoMisc> GetExtraSlots9(SAV9SV sav)

View file

@ -19,7 +19,7 @@ public interface ISlotInfo
/// Indicates if this slot can write to the requested <see cref="sav"/>.
/// </summary>
/// <param name="sav">Save file to try writing to.</param>
/// <returns>True if can write to</returns>
/// <returns>True if the slot can be written to</returns>
bool CanWriteTo(SaveFile sav);
/// <summary>
@ -27,7 +27,7 @@ public interface ISlotInfo
/// </summary>
/// <param name="sav">Save file to try writing to.</param>
/// <param name="pk">Entity data to try writing.</param>
/// <returns>True if can write to</returns>
/// <returns>True if the slot can be written to</returns>
WriteBlockedMessage CanWriteTo(SaveFile sav, PKM pk);
/// <summary>

View file

@ -1,7 +1,7 @@
namespace PKHeX.Core;
/// <summary>
/// Records data for an <see cref="ISlotInfo"/> that originates from an external file.
/// Records data for <see cref="ISlotInfo"/> that originates from an external file.
/// </summary>
/// <param name="Path"></param>
public sealed record SlotInfoFile(string Path) : ISlotInfo

View file

@ -8,7 +8,7 @@ public enum SlotOrigin : byte
/// <summary>
/// Slot data originated from the Party, or follows "party format" data rules.
/// </summary>
/// <remarks>Some games do not permit forms to exist outside of the party.</remarks>
/// <remarks>Some games do not permit forms to exist outside the party.</remarks>
Party = 0,
/// <summary>

View file

@ -1,18 +1,15 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace PKHeX.Core;
/// <summary>
/// Tracks <see cref="PKM"/> slot changes and provides the ability to revert a change.
/// </summary>
public sealed class SlotChangelog
public sealed class SlotChangelog(SaveFile SAV)
{
private readonly SaveFile SAV;
private readonly Stack<SlotReversion> UndoStack = new();
private readonly Stack<SlotReversion> RedoStack = new();
public SlotChangelog(SaveFile sav) => SAV = sav;
public bool CanUndo => UndoStack.Count != 0;
public bool CanRedo => RedoStack.Count != 0;
@ -57,26 +54,22 @@ public sealed class SlotChangelog
_ => new SingleSlotReversion(info, sav),
};
private abstract class SlotReversion
private abstract class SlotReversion(ISlotInfo Info)
{
internal readonly ISlotInfo Info;
protected SlotReversion(ISlotInfo info) => Info = info;
internal readonly ISlotInfo Info = Info;
public abstract void Revert(SaveFile sav);
}
private sealed class PartyReversion : SlotReversion
private sealed class PartyReversion(ISlotInfo info, IList<PKM> Party) : SlotReversion(info)
{
private readonly IList<PKM> Party;
public PartyReversion(ISlotInfo info, SaveFile s) : base(info) => Party = s.PartyData;
public PartyReversion(ISlotInfo info, SaveFile s) : this(info, s.PartyData) { }
public override void Revert(SaveFile sav) => sav.PartyData = Party;
}
private sealed class SingleSlotReversion : SlotReversion
private sealed class SingleSlotReversion(ISlotInfo info, PKM Entity) : SlotReversion(info)
{
private readonly PKM Entity;
public SingleSlotReversion(ISlotInfo info, SaveFile sav) : base(info) => Entity = info.Read(sav);
public SingleSlotReversion(ISlotInfo info, SaveFile sav) : this(info, info.Read(sav)) { }
public override void Revert(SaveFile sav) => Info.WriteTo(sav, Entity, PKMImportSetting.Skip);
}

View file

@ -3,18 +3,10 @@ namespace PKHeX.Core;
/// <summary>
/// Facilitates interaction with a <see cref="SaveFile"/> or other data location's slot data.
/// </summary>
public sealed class SlotEditor<T>
public sealed class SlotEditor<T>(SaveFile SAV)
{
private readonly SaveFile SAV;
public readonly SlotChangelog Changelog;
public readonly SlotPublisher<T> Publisher;
public SlotEditor(SaveFile sav)
{
SAV = sav;
Changelog = new SlotChangelog(sav);
Publisher = new SlotPublisher<T>();
}
public readonly SlotChangelog Changelog = new(SAV);
public readonly SlotPublisher<T> Publisher = new();
private void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk) => Publisher.NotifySlotChanged(slot, type, pk);

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace PKHeX.Core;
@ -10,7 +10,7 @@ public sealed class SlotPublisher<T>
/// <summary>
/// All <see cref="ISlotViewer{T}"/> instances that provide a view on individual <see cref="ISlotInfo"/> content.
/// </summary>
public List<ISlotViewer<T>> Subscribers { get; } = new();
public List<ISlotViewer<T>> Subscribers { get; } = [];
public ISlotInfo? Previous { get; private set; }
public SlotTouchType PreviousType { get; private set; } = SlotTouchType.None;

View file

@ -6,22 +6,17 @@ namespace PKHeX.Core;
/// Tuple containing data for a <see cref="Slot"/> and the originating <see cref="View"/>
/// </summary>
/// <typeparam name="T"></typeparam>
public sealed class SlotViewInfo<T> : IEquatable<T> where T : class
public sealed class SlotViewInfo<T>(ISlotInfo Slot, ISlotViewer<T> View) : IEquatable<T>
where T : class
{
public readonly ISlotInfo Slot;
public readonly ISlotViewer<T> View;
public readonly ISlotInfo Slot = Slot;
public readonly ISlotViewer<T> View = View;
public PKM ReadCurrent() => Slot.Read(View.SAV);
public bool CanWriteTo() => Slot.CanWriteTo(View.SAV);
public bool IsEmpty() => Slot.IsEmpty(View.SAV);
public WriteBlockedMessage CanWriteTo(PKM pk) => Slot.CanWriteTo(View.SAV, pk);
public SlotViewInfo(ISlotInfo slot, ISlotViewer<T> view)
{
Slot = slot;
View = view;
}
private bool Equals(SlotViewInfo<T> other)
{
if (other.View.SAV != View.SAV)

View file

@ -9,7 +9,7 @@ namespace PKHeX.Core;
/// </summary>
public static class ShowdownParsing
{
private static readonly string[] genderForms = { "", "F", "" };
private static readonly string[] genderForms = ["", "F", ""];
/// <summary>
/// Gets the Form ID from the input <see cref="name"/>.
@ -193,7 +193,7 @@ public static class ShowdownParsing
{
// Find the end of the Showdown Set lines.
// The end is implied when:
// - we see a completely whitespace or empty line, or
// - we see a complete whitespace or empty line, or
// - we witness four 'move' definition lines.
int length = 0;
int moveCount = 4;

View file

@ -10,20 +10,20 @@ namespace PKHeX.Core;
/// </summary>
public sealed class ShowdownSet : IBattleTemplate
{
private static readonly string[] StatNames = { "HP", "Atk", "Def", "Spe", "SpA", "SpD" };
private static readonly string[] StatNames = ["HP", "Atk", "Def", "Spe", "SpA", "SpD"];
private const string LineSplit = ": ";
private const string ItemSplit = " @ ";
private const int MAX_SPECIES = (int)MAX_COUNT - 1;
internal const string DefaultLanguage = GameLanguage.DefaultLanguage;
private static readonly GameStrings DefaultStrings = GameInfo.GetStrings(DefaultLanguage);
private static ReadOnlySpan<ushort> DashedSpecies => new ushort[]
{
private static ReadOnlySpan<ushort> DashedSpecies =>
[
(int)NidoranF, (int)NidoranM,
(int)HoOh,
(int)Jangmoo, (int)Hakamoo, (int)Kommoo,
(int)TingLu, (int)ChienPao, (int)WoChien, (int)ChiYu,
};
];
/// <inheritdoc/>
public ushort Species { get; private set; }
@ -62,10 +62,10 @@ public sealed class ShowdownSet : IBattleTemplate
public byte Form { get; private set; }
/// <inheritdoc/>
public int[] EVs { get; } = {00, 00, 00, 00, 00, 00};
public int[] EVs { get; } = [00, 00, 00, 00, 00, 00];
/// <inheritdoc/>
public int[] IVs { get; } = {31, 31, 31, 31, 31, 31};
public int[] IVs { get; } = [31, 31, 31, 31, 31, 31];
/// <inheritdoc/>
public int HiddenPowerType { get; private set; } = -1;
@ -73,7 +73,7 @@ public sealed class ShowdownSet : IBattleTemplate
public MoveType TeraType { get; private set; } = MoveType.Any;
/// <inheritdoc/>
public ushort[] Moves { get; } = {0, 0, 0, 0};
public ushort[] Moves { get; } = [0, 0, 0, 0];
/// <inheritdoc/>
public bool CanGigantamax { get; private set; }
@ -429,7 +429,7 @@ public sealed class ShowdownSet : IBattleTemplate
{
var count = stats.Length - stats.Count(ignoreValue);
if (count == 0)
return Array.Empty<string>();
return [];
var result = new string[count];
int ctr = 0;
@ -676,7 +676,7 @@ public sealed class ShowdownSet : IBattleTemplate
else // (Species), or garbage
{
species = tmp;
nickname = ReadOnlySpan<char>.Empty;
nickname = [];
}
}

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
@ -23,7 +22,7 @@ public sealed class FilteredGameDataSource
}
else
{
Items = Array.Empty<ComboItem>();
Items = [];
}
var gamelist = GameUtil.GetVersionsWithinRange(sav, sav.Generation).ToList();
@ -123,5 +122,5 @@ public sealed class FilteredGameDataSource
return list;
}
private static readonly string[] AbilityIndexSuffixes = { " (1)", " (2)", " (H)" };
private static readonly string[] AbilityIndexSuffixes = [" (1)", " (2)", " (H)"];
}

View file

@ -24,8 +24,8 @@ public sealed class GameDataSource
/// <summary>
/// List of <see cref="LanguageID"/> values to display.
/// </summary>
private static readonly List<ComboItem> LanguageList = new()
{
private static readonly List<ComboItem> LanguageList =
[
new ComboItem("JPN (日本語)", (int)LanguageID.Japanese),
new ComboItem("ENG (English)", (int)LanguageID.English),
new ComboItem("FRE (Français)", (int)LanguageID.French),
@ -35,7 +35,7 @@ public sealed class GameDataSource
new ComboItem("KOR (한국어)", (int)LanguageID.Korean),
new ComboItem("CHS (简体中文)", (int)LanguageID.ChineseS),
new ComboItem("CHT (繁體中文)", (int)LanguageID.ChineseT),
};
];
public GameDataSource(GameStrings s)
{
@ -87,37 +87,37 @@ public sealed class GameDataSource
/// Preferentially ordered list of <see cref="GameVersion"/> values to display in a list.
/// </summary>
/// <remarks>Most recent games are at the top, loosely following Generation groups.</remarks>
private static ReadOnlySpan<byte> OrderedVersionArray => new byte[]
{
50, 51, // 9 sv
47, // 8 legends arceus
48, 49, // 8 bdsp
44, 45, // 8 swsh
42, 43, // 7 gg
30, 31, // 7 sm
32, 33, // 7 usum
24, 25, // 6 xy
27, 26, // 6 oras
21, 20, // 5 bw
23, 22, // 5 b2w2
10, 11, 12, // 4 dppt
07, 08, // 4 hgss
02, 01, 03, // 3 rse
04, 05, // 3 frlg
15, // 3 cxd
private static ReadOnlySpan<byte> OrderedVersionArray =>
[
50, 51, // 9 S/V
47, // 8 PLA
48, 49, // 8 BD/SP
44, 45, // 8 SW/SH
42, 43, // 7 LGP/E
30, 31, // 7 S/M
32, 33, // 7 US/UM
24, 25, // 6 X/Y
27, 26, // 6 OR/AS
21, 20, // 5 B/W
23, 22, // 5 B2/W2
10, 11, 12, // 4 D/P/Pt
07, 08, // 4 HG/SS
02, 01, 03, // 3 R/S/E
04, 05, // 3 FR/LG
15, // 3 Colosseum & XD
39, 40, 41, // 7vc2
35, 36, 37, 38, // 7vc1
39, 40, 41, // 7vc2 (Gen2 VC)
35, 36, 37, 38, // 7vc1 (Gen1 VC)
34, // 7go
00,
};
];
private static IReadOnlyList<ComboItem> GetBalls(ReadOnlySpan<string> itemList) => Util.GetVariedCBListBall(itemList, BallStoredIndexes, BallItemIDs);
private static ComboItem[] GetBalls(ReadOnlySpan<string> itemList) => Util.GetVariedCBListBall(itemList, BallStoredIndexes, BallItemIDs);
// Since Poké Ball (and Great Ball / Ultra Ball) are most common, any list should have them at the top. The rest can be sorted alphabetically.
private static ReadOnlySpan<byte> BallStoredIndexes => new byte[] { 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037 };
private static ReadOnlySpan<ushort> BallItemIDs => new ushort[] { 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 576, 851, 1785, 1710, 1711, 1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771 };
private static ReadOnlySpan<byte> BallStoredIndexes => [ 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037 ];
private static ReadOnlySpan<ushort> BallItemIDs => [ 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 576, 851, 1785, 1710, 1711, 1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771 ];
private static ComboItem[] GetVersionList(GameStrings s)
{

View file

@ -28,12 +28,12 @@ public static class GameLanguage
/// Language codes supported for loading string resources
/// </summary>
/// <see cref="ProgramLanguage"/>
private static readonly string[] LanguageCodes = { "ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2" };
private static readonly string[] LanguageCodes = ["ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2"];
/// <summary>
/// Pokétransporter location names, ordered per index of <see cref="LanguageCodes"/>
/// </summary>
private static readonly string[] ptransp = { "ポケシフター", "Poké Transfer", "Poké Fret", "Pokétrasporto", "Poképorter", "Pokétransfer", "포케시프터", "宝可传送", "寶可傳送" };
private static readonly string[] ptransp = ["ポケシフター", "Poké Transfer", "Poké Fret", "Pokétrasporto", "Poképorter", "Pokétransfer", "포케시프터", "宝可传送", "寶可傳送"];
/// <summary>
/// Gets the Met Location display name for the Pokétransporter.

View file

@ -42,14 +42,14 @@ public sealed class GameStrings : IBasicStrings
/// <summary>
/// Item IDs that correspond to the <see cref="Ball"/> value.
/// </summary>
private static ReadOnlySpan<ushort> Items_Ball => new ushort[]
{
private static ReadOnlySpan<ushort> Items_Ball =>
[
0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009,
0010, 0011, 0012, 0013, 0014, 0015, 0016, 0492, 0493, 0494,
0495, 0496, 0497, 0498, 0499, 0576, 0851,
1785, 1710, 1711,
1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771,
};
];
internal GameStrings(string l)
{
@ -398,11 +398,11 @@ public sealed class GameStrings : IBasicStrings
private void SanitizeMetGen4(LocationSet4 set)
{
set.Met0[054] += " (DP/Pt)"; // Victory Road
set.Met0[054] += " (D/P/Pt)"; // Victory Road
set.Met0[221] += " (HG/SS)"; // Victory Road
// German language duplicate; handle for all since it can be confused.
set.Met0[104] += " (DP/Pt)"; // Vista Lighthouse
set.Met0[104] += " (D/P/Pt)"; // Vista Lighthouse
set.Met0[212] += " (HG/SS)"; // Lighthouse
set.Met2[1] += $" ({NPC})"; // Anything from an NPC
@ -411,10 +411,10 @@ public sealed class GameStrings : IBasicStrings
private void SanitizeMetGen5(LocationSet6 set)
{
set.Met0[36] = $"{set.Met0[84]}/{set.Met0[36]}"; // Cold Storage in BW = PWT in BW2
set.Met0[40] += " (B/W)"; // Victory Road in BW
set.Met0[134] += " (B2/W2)"; // Victory Road in B2W2
// BW2 Entries from 76 to 105 are for Entralink in BW
set.Met0[36] = $"{set.Met0[84]}/{set.Met0[36]}"; // Cold Storage in B/W = PWT in B2/W2
set.Met0[40] += " (B/W)"; // Victory Road in B/W
set.Met0[134] += " (B2/W2)"; // Victory Road in B2/W2
// B2/W2 Entries from 76 to 105 are for Entralink in B/W
for (int i = 76; i < 106; i++)
set.Met0[i] += "●";
@ -513,7 +513,7 @@ public sealed class GameStrings : IBasicStrings
for (int i = 55; i < 61; i++) // distinguish Event year duplicates
set.Met4[i] += " (-)";
set.Met4[30] += " (-)"; // a Video game Event (in spanish etc) -- duplicate with line 39
set.Met4[30] += " (-)"; // a Video game Event (in spanish etc.) -- duplicate with line 39
set.Met4[53] += " (-)"; // a Pokémon event -- duplicate with line 37
set.Met4[81] += " (-)"; // Pokémon GO -- duplicate with 30000's entry
@ -542,7 +542,7 @@ public sealed class GameStrings : IBasicStrings
set.Met3[i] += " (-)";
set.Met3[19] += " (?)"; // Kanto for the third time
set.Met4[30] += " (-)"; // a Video game Event (in spanish etc) -- duplicate with line 39
set.Met4[30] += " (-)"; // a Video game Event (in spanish etc.) -- duplicate with line 39
set.Met4[53] += " (-)"; // a Pokémon event -- duplicate with line 37
set.Met4[81] += " (-)"; // Pokémon GO -- duplicate with 30000's entry
@ -622,7 +622,7 @@ public sealed class GameStrings : IBasicStrings
for (int i = 49; i <= 54; i++) // distinguish Event year duplicates
set.Met4[i] += " (-)";
set.Met4[27] += " (-)"; // a Video game Event (in spanish etc) -- duplicate with line 36
set.Met4[27] += " (-)"; // a Video game Event (in spanish etc.) -- duplicate with line 36
set.Met4[48] += " (-)"; // a Pokémon event -- duplicate with line 34
set.Met4[73] += " (-)"; // Pokémon GO -- duplicate with 30000's entry
@ -736,7 +736,7 @@ public sealed class GameStrings : IBasicStrings
/// <param name="format">Current <see cref="PKM.Format"/></param>
/// <param name="generation"><see cref="PKM.Generation"/> of origin</param>
/// <param name="version">Current GameVersion (only applicable for <see cref="GameVersion.Gen7b"/> differentiation)</param>
/// <returns>Location name. May be an empty string if no location name is known for that location value.</returns>
/// <returns>Location name. Potentially an empty string if no location name is known for that location value.</returns>
public string GetLocationName(bool isEggLocation, int location, int format, int generation, GameVersion version)
{
if (format == 1)
@ -803,7 +803,7 @@ public sealed class GameStrings : IBasicStrings
{
var set = GetLocations(gen, version);
if (set is null)
return Array.Empty<string>();
return [];
return set.GetLocationNames(bankID);
}
}

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core;
public static class GeoLocation
{
private static readonly string[]?[] CountryList = GetCountryList();
private static readonly string[] lang_geo = { "ja", "en", "fr", "de", "it", "es", "zh", "ko", "zh2" };
private static readonly string[] lang_geo = ["ja", "en", "fr", "de", "it", "es", "zh", "ko", "zh2"];
private static readonly string[]?[]?[] RegionList = new string[CountryList.Length][][];
/// <summary>

View file

@ -8,7 +8,7 @@ public sealed record LocationSet0(string[] Met0) : ILocationSet
public ReadOnlySpan<string> GetLocationNames(int bankID) => bankID switch
{
0 => Met0,
_ => Array.Empty<string>(),
_ => [],
};
public string GetLocationName(int locationID)

View file

@ -10,7 +10,7 @@ public sealed record LocationSet4(string[] Met0, string[] Met2, string[] Met3) :
0 => Met0,
2 => Met2,
3 => Met3,
_ => Array.Empty<string>(),
_ => [],
};
public string GetLocationName(int locationID) => locationID switch

View file

@ -11,7 +11,7 @@ public sealed record LocationSet6(string[] Met0, string[] Met3, string[] Met4, s
3 => Met3,
4 => Met4,
6 => Met6,
_ => Array.Empty<string>(),
_ => [],
};
public string GetLocationName(int locationID) => locationID switch

View file

@ -9,40 +9,24 @@ namespace PKHeX.Core;
/// <summary>
/// Cached copies of Met Location lists
/// </summary>
public sealed class MetDataSource
public sealed class MetDataSource(GameStrings s)
{
private readonly List<ComboItem> MetGen2;
private readonly List<ComboItem> MetGen3;
private readonly List<ComboItem> MetGen3CXD;
private readonly List<ComboItem> MetGen4;
private readonly List<ComboItem> MetGen5;
private readonly List<ComboItem> MetGen6;
private readonly List<ComboItem> MetGen7;
private readonly List<ComboItem> MetGen7GG;
private readonly List<ComboItem> MetGen8;
private readonly List<ComboItem> MetGen8a;
private readonly List<ComboItem> MetGen8b;
private readonly List<ComboItem> MetGen9;
private readonly List<ComboItem> MetGen2 = CreateGen2(s);
private readonly List<ComboItem> MetGen3 = CreateGen3(s);
private readonly List<ComboItem> MetGen3CXD = CreateGen3CXD(s);
private readonly List<ComboItem> MetGen4 = CreateGen4(s);
private readonly List<ComboItem> MetGen5 = CreateGen5(s);
private readonly List<ComboItem> MetGen6 = CreateGen6(s);
private readonly List<ComboItem> MetGen7 = CreateGen7(s);
private readonly List<ComboItem> MetGen7GG = CreateGen7GG(s);
private readonly List<ComboItem> MetGen8 = CreateGen8(s);
private readonly List<ComboItem> MetGen8a = CreateGen8a(s);
private readonly List<ComboItem> MetGen8b = CreateGen8b(s);
private readonly List<ComboItem> MetGen9 = CreateGen9(s);
private IReadOnlyList<ComboItem>? MetGen4Transfer;
private IReadOnlyList<ComboItem>? MetGen5Transfer;
public MetDataSource(GameStrings s)
{
MetGen2 = CreateGen2(s);
MetGen3 = CreateGen3(s);
MetGen3CXD = CreateGen3CXD(s);
MetGen4 = CreateGen4(s);
MetGen5 = CreateGen5(s);
MetGen6 = CreateGen6(s);
MetGen7 = CreateGen7(s);
MetGen7GG = CreateGen7GG(s);
MetGen8 = CreateGen8(s);
MetGen8a = CreateGen8a(s);
MetGen8b = CreateGen8b(s);
MetGen9 = CreateGen9(s);
}
private static List<ComboItem> CreateGen2(GameStrings s)
{
var locations = Util.GetCBList(s.Gen2.Met0.AsSpan(0, 0x5F));
@ -76,7 +60,7 @@ public sealed class MetDataSource
return locations;
}
private IReadOnlyList<ComboItem> CreateGen4Transfer()
private ComboItem[] CreateGen4Transfer()
{
// Pal Park to front
var met = MetGen4.ToArray();
@ -99,7 +83,7 @@ public sealed class MetDataSource
return locations;
}
private IReadOnlyList<ComboItem> CreateGen5Transfer()
private ComboItem[] CreateGen5Transfer()
{
// PokéTransfer to front
var index = MetGen5.FindIndex(static z => z.Value == Locations.Transfer4);
@ -231,7 +215,7 @@ public sealed class MetDataSource
else
result = GetLocationListInternal(version, context);
// Insert the BDSP none location if the format requires it.
// Insert the BD/SP none location if the format requires it.
if (context is EntityContext.Gen8b && !BDSP.Contains(version))
{
var bdsp = new ComboItem[result.Count + 1];
@ -323,6 +307,6 @@ public sealed class MetDataSource
{
<= CXD when context == EntityContext.Gen4 => MetGen4Transfer ??= CreateGen4Transfer(),
< X when context.Generation() >= 5 => MetGen5Transfer ??= CreateGen5Transfer(),
_ => Array.Empty<ComboItem>(),
_ => [],
};
}

View file

@ -224,7 +224,7 @@ public static class GameUtil
public static GameVersion[] GetVersionsInGeneration(int generation, int pkVersion)
{
if (Gen7b.Contains(pkVersion))
return new[] {GO, GP, GE};
return [GO, GP, GE];
return Array.FindAll(GameVersions, z => z.GetGeneration() == generation);
}
@ -232,7 +232,7 @@ public static class GameUtil
/// List of possible <see cref="GameVersion"/> values within the provided <see cref="IGameValueLimit"/> criteria.
/// </summary>
/// <param name="obj">Criteria for retrieving versions</param>
/// <param name="generation">Generation format minimum (necessary for the CXD/Gen4 swap etc)</param>
/// <param name="generation">Generation format minimum (necessary for the CXD/Gen4 swap etc.)</param>
public static IEnumerable<GameVersion> GetVersionsWithinRange(IGameValueLimit obj, int generation = -1)
{
var max = obj.MaxGameID;

View file

@ -4,8 +4,8 @@ namespace PKHeX.Core;
internal static class Locations4
{
public static ReadOnlySpan<byte> Met0 => new byte[]
{
public static ReadOnlySpan<byte> Met0 =>
[
000, 001, 002, 003, 004, 005, 006, 007, 008, 009,
010, 011, 012, 013, 014, 015, 016, 017, 018, 019,
020, 021, 022, 023, 024, 025, 026, 027, 028, 029,
@ -30,17 +30,17 @@ internal static class Locations4
210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234,
};
];
// Ignore the --- met location at index 7.
public static ReadOnlySpan<ushort> Met2 => new ushort[]
{
public static ReadOnlySpan<ushort> Met2 =>
[
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009,
2010, 2011, 2012, 2013, 2014,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009,
3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019,
3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029,
@ -49,5 +49,5 @@ internal static class Locations4
3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059,
3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069,
3070, 3071, 3072, 3073, 3074, 3075, 3076,
};
];
}

View file

@ -4,8 +4,8 @@ namespace PKHeX.Core;
internal static class Locations5
{
public static ReadOnlySpan<byte> Met0 => new byte[]
{
public static ReadOnlySpan<byte> Met0 =>
[
001, 002, 004, 005, 006, 007, 008, 009,
010, 011, 012, 013, 014, 015, 016, 017, 018, 019,
020, 021, 022, 023, 024, 025, 026, 027, 028, 029,
@ -22,17 +22,17 @@ internal static class Locations5
130, 131, 132, 133, 134, 135, 136, 137, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30002, 30004, 30005, 30006, 30007, 30008,
30010, 30011, 30012, 30013, 30014, 30015,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009,
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029,
40030, 40031, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039,
@ -43,7 +43,7 @@ internal static class Locations5
40080, 40081, 40082, 40083, 40084, 40085, 40086, 40087, 40088, 40089,
40090, 40091, 40092, 40093, 40094, 40095, 40096, 40097, 40098, 40099,
40100, 40101, 40102, 40103, 40104, 40105, 40106, 40107, 40108, 40109,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] { 60001, 60003 };
public static ReadOnlySpan<ushort> Met6 => [60001, 60003];
}

View file

@ -4,9 +4,9 @@ namespace PKHeX.Core;
internal static class Locations6
{
public static ReadOnlySpan<ushort> Met0 => new ushort[]
{
/* XY */
public static ReadOnlySpan<ushort> Met0 =>
[
/* X/Y */
002, 006, 008,
010, 012, 014, 016, 018,
020, 022, 024, 026, 028,
@ -25,7 +25,7 @@ internal static class Locations6
150, 152, 154, 156, 158,
160, 162, 164, 166, 168,
/* ORAS */
/* OR/AS */
170, 172, 174, 176, 178,
180, 182, 184, 186, 188,
190, 192, 194, 196, 198,
@ -45,16 +45,16 @@ internal static class Locations6
330, 332, 334, 336, 338,
340, 342, 344, 346, 348,
350, 352, 354,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009,
30010, 30011,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029,
@ -63,7 +63,7 @@ internal static class Locations6
40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 };
public static ReadOnlySpan<ushort> Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004];
}

View file

@ -4,8 +4,8 @@ namespace PKHeX.Core;
internal static class Locations7
{
public static ReadOnlySpan<byte> Met0 => new byte[]
{
public static ReadOnlySpan<byte> Met0 =>
[
002, 004, 006, 008,
010, 012, 014, 016, 018,
020, 022, 024, 026, 028,
@ -30,16 +30,16 @@ internal static class Locations7
210, 212, 214, 216, 218,
220, 222, 224, 226, 228,
230, 232,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009,
30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029,
@ -49,7 +49,7 @@ internal static class Locations7
40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079,
40080, 40081, 40082, 40083, 40084, 40085, 40086, 40087, 40088,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 };
public static ReadOnlySpan<ushort> Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004];
}

View file

@ -4,24 +4,24 @@ namespace PKHeX.Core;
internal static class Locations7b
{
public static ReadOnlySpan<byte> Met0 => new byte[]
{
public static ReadOnlySpan<byte> Met0 =>
[
002, 003, 004, 005, 006, 007, 008, 009,
010, 011, 012, 013, 014, 015, 016, 017, 018, 019,
020, 021, 022, 023, 024, 025, 026, 027, 028, 029,
030, 031, 032, 033, 034, 035, 036, 037, 038, 039,
040, 041, 042, 043, 044, 045, 046, 047, 048, 049,
050, 051, 052, 053,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009,
30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029,
@ -30,7 +30,7 @@ internal static class Locations7b
40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 };
public static ReadOnlySpan<ushort> Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004];
}

View file

@ -4,8 +4,8 @@ namespace PKHeX.Core;
internal static class Locations8
{
public static ReadOnlySpan<byte> Met0 => new byte[]
{
public static ReadOnlySpan<byte> Met0 =>
[
002, 004, 006, 008,
012, 014, 016, 018,
020, 022, 024, 028,
@ -31,26 +31,26 @@ internal static class Locations8
220, 222, 224, 226, 228,
230, 232, 234, 236, 238,
240, 242, 244, 246,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009,
30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029,
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029,
40030, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039,
40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049,
40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079,
40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049,
40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079,
40080, 40081, 40082, 40083, 40084, 40085, 40086,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 };
public static ReadOnlySpan<ushort> Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004];
}

View file

@ -4,8 +4,8 @@ namespace PKHeX.Core;
internal static class Locations8a
{
public static ReadOnlySpan<byte> Met0 => new byte[]
{
public static ReadOnlySpan<byte> Met0 =>
[
000, 002, 004, 006, 007, 008, 009,
010, 011, 012, 013, 014, 015, 016, 017, 018, 019,
020, 021, 022, 023, 024, 025, 026, 027, 028, 029,
@ -22,27 +22,27 @@ internal static class Locations8a
130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153, 154, 155,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30002, 30003, 30004, 30005, 30006, 30007, 30008, 30009,
30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019,
30020, 30021, 30022,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029,
40030, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039,
40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049,
40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079,
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029,
40030, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039,
40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049,
40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079,
40080, 40081, 40082, 40083, 40084, 40085, 40086,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 };
public static ReadOnlySpan<ushort> Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004];
}

View file

@ -7,8 +7,8 @@ internal static class Locations8b
public static bool IsUnderground(ushort location) => location is (>= 508 and <= 617);
public static bool IsMarsh(ushort location) => location is (>= 219 and <= 224);
public static ReadOnlySpan<ushort> Met0 => new ushort[]
{
public static ReadOnlySpan<ushort> Met0 =>
[
000, 001, 002, 003, 004, 005, 006, 007, 008, 009,
010, 011, 012, 013, 014, 015, 016, 017, 018, 019,
020, 021, 022, 023, 024, 025, 026, 027, 028, 029,
@ -77,17 +77,17 @@ internal static class Locations8b
// Ramanas Park rooms with lights out
648, 649, 650, 651, 652, 653, 654, 655, 656, 657,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30003, 30004, 30005, 30006, 30007, 30009,
30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019,
30020, 30022,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029,
@ -96,7 +96,7 @@ internal static class Locations8b
40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40074, 40075, 40076, 40077,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004, /* BDSP */ 60005, 60006, 60007, 60010 };
public static ReadOnlySpan<ushort> Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004, /* BD/SP */ 60005, 60006, 60007, 60010];
}

View file

@ -14,8 +14,8 @@ internal static class Locations9
/// </summary>
public static bool IsKitakami(ushort location) => location is (>= 132 and <= 170);
public static ReadOnlySpan<byte> Met0 => new byte[]
{
public static ReadOnlySpan<byte> Met0 =>
[
002, 004, 006, 008,
010, 012, 014, 016, 018,
020, 022, 024, 026, 028,
@ -37,17 +37,17 @@ internal static class Locations9
140, 142, 144, 146, 148, 150,
152, 154, 156, 158, 160, 162,
164, 166, 168, 170,
};
];
public static ReadOnlySpan<ushort> Met3 => new ushort[]
{
public static ReadOnlySpan<ushort> Met3 =>
[
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009,
30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019,
30020, 30021, 30022, 30023, 30024,
};
];
public static ReadOnlySpan<ushort> Met4 => new ushort[]
{
public static ReadOnlySpan<ushort> Met4 =>
[
40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009,
40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019,
40020, 40021, 40022, 40024, 40024, 40025, 40026, 40027, 40028, 40029,
@ -56,7 +56,7 @@ internal static class Locations9
40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059,
40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069,
40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078,
};
];
public static ReadOnlySpan<ushort> Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004, /* SV */ 60005 };
public static ReadOnlySpan<ushort> Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004, /* S/V */ 60005];
}

View file

@ -18,7 +18,7 @@ public static class LocationsHOME
public const ushort SWSHEgg = 65534; // -2 = 8bNone-1..
/// <summary>
/// Gets the external entity version needs to be remapped into a SW/SH location.
/// Gets the external entity version needs to be remapped into a location for SW/SH.
/// </summary>
/// <param name="version"></param>
/// <returns>True if a known remap exists.</returns>
@ -100,7 +100,7 @@ public static class LocationsHOME
/// <summary>
/// Checks if the met location is a valid location for the input <see cref="ver"/>.
/// </summary>
/// <remarks>Relevant when a BD/SP entity is transferred to SW/SH.</remarks>
/// <remarks>Relevant when an entity from BD/SP is transferred to SW/SH.</remarks>
public static bool IsValidMetBDSP(ushort loc, int ver) => loc switch
{
SHSP when ver == (int)GameVersion.SH => true,
@ -111,7 +111,7 @@ public static class LocationsHOME
/// <summary>
/// Checks if the met location is a valid location for the input <see cref="ver"/>.
/// </summary>
/// <remarks>Relevant when a S/V entity is transferred to SW/SH.</remarks>
/// <remarks>Relevant when an entity from S/V is transferred to SW/SH.</remarks>
public static bool IsValidMetSV(ushort loc, int ver) => loc switch
{
SHVL when ver == (int)GameVersion.SH => true,

View file

@ -22,7 +22,7 @@ public enum HeldItemLumpImage
}
/// <summary>
/// Logic to check if a held item should how a lumped image sprite.
/// Logic to check if a held item should show a lumped image sprite.
/// </summary>
public static class HeldItemLumpUtil
{
@ -41,8 +41,8 @@ public static class HeldItemLumpUtil
/// <returns>Evaluation result.</returns>
public static HeldItemLumpImage GetIsLump(int item, EntityContext context) => context.Generation() switch
{
<= 4 when item is (>= 0328 and <= 0419) => HeldItemLumpImage.TechnicalMachine, // gen2/3/4 TM
8 when item is (>= 0328 and <= 0427) => HeldItemLumpImage.TechnicalMachine, // BDSP TMs
<= 4 when item is (>= 0328 and <= 0419) => HeldItemLumpImage.TechnicalMachine, // Gen2/3/4 TM
8 when item is (>= 0328 and <= 0427) => HeldItemLumpImage.TechnicalMachine, // BD/SP TMs
8 when item is (>= 1130 and <= 1229) => HeldItemLumpImage.TechnicalRecord, // Gen8 TR
9 when item is (>= 0328 and <= 0419) // TM01-TM92
or (>= 0618 and <= 0620) // TM093-TM095

View file

@ -7,8 +7,8 @@ public sealed class ItemStorage1 : IItemStorage
public static readonly ItemStorage1 Instance = new();
private ItemStorage1() { }
private static ReadOnlySpan<ushort> Pouch_Items_RBY => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Items_RBY =>
[
000,001,002,003,004,005,006, 010,011,012,013,014,015,
016,017,018,019,020, 029,030,031,
032,033,034,035,036,037,038,039,040,041,042,043, 045,046,047,
@ -22,7 +22,7 @@ public sealed class ItemStorage1 : IItemStorage
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,248,249,250,
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -10,8 +10,8 @@ public sealed class ItemStorage2 : IItemStorage
private readonly bool Crystal;
private ItemStorage2(bool crystal) => Crystal = crystal;
private static ReadOnlySpan<ushort> Pouch_Items_GSC => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Items_GSC =>
[
003, 008, 009,
010, 011, 012, 013, 014, 015, 016, 017, 018, 019,
020, 021, 022, 023, 024, 026, 027, 028, 029,
@ -31,39 +31,39 @@ public sealed class ItemStorage2 : IItemStorage
163, 167, 168, 169,
170, 172, 173, 174,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
};
];
private static ReadOnlySpan<ushort> Pouch_Ball_GSC => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Ball_GSC =>
[
1, 2, 4, 5, 157, 159, 160, 161, 164, 165, 166,
};
];
private static ReadOnlySpan<ushort> Pouch_Key_GS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_GS =>
[
007, 054, 055, 058, 059, 061, 066, 067, 068, 069, 071, 127, 128, 130, 133, 134, 175, 178,
};
];
private const int ExtraKeyCrystal = 4;
private static ReadOnlySpan<ushort> Pouch_Key_C => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_C =>
[
007, 054, 055, 058, 059, 061, 066, 067, 068, 069, 071, 127, 128, 130, 133, 134, 175, 178,
070, 115, 116, 129,
};
];
private static ReadOnlySpan<ushort> Pouch_TMHM_GSC => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_TMHM_GSC =>
[
191, 192, 193, 194, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
};
];
public static ushort[] GetAllHeld() => ArrayUtil.ConcatAll(Pouch_Items_GSC, Pouch_Ball_GSC, Pouch_TMHM_GSC);
public static ushort[] GetAllHeld() => [..Pouch_Items_GSC, ..Pouch_Ball_GSC, ..Pouch_TMHM_GSC];
private static readonly ushort[] PCItemsC = ArrayUtil.ConcatAll(Pouch_Items_GSC, Pouch_Ball_GSC, Pouch_TMHM_GSC, Pouch_Key_C);
private static readonly ushort[] PCItemsC = [..Pouch_Items_GSC, ..Pouch_Ball_GSC, ..Pouch_TMHM_GSC, ..Pouch_Key_C];
private static ReadOnlySpan<ushort> PCItemsGS => PCItemsC.AsSpan(..^ExtraKeyCrystal);

View file

@ -6,23 +6,23 @@ public sealed class ItemStorage3Colo : IItemStorage
{
public static readonly ItemStorage3Colo Instance = new();
private static ReadOnlySpan<ushort> Pouch_Cologne_COLO => new ushort[] { 543, 544, 545 };
private static ReadOnlySpan<ushort> Pouch_Cologne_COLO => [543, 544, 545];
private static ReadOnlySpan<ushort> Pouch_Items_COLO => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Items_COLO =>
[
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258,
537, // Time Flute
};
];
private static ReadOnlySpan<ushort> Pouch_Key_COLO => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_COLO =>
[
500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
510, 511, 512, 513, 514, 515, 516, 517, 518, 519,
520, 521, 522, 523, 524, 525, 526, 527, 528, 529,
530, 531, 532, 533, 534, 535, 536, 538, 539,
540, 541, 542, 546, 547,
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -1,4 +1,5 @@
using System;
using static PKHeX.Core.ItemStorage3RS;
namespace PKHeX.Core;
@ -6,28 +7,27 @@ public sealed class ItemStorage3E : IItemStorage
{
public static readonly ItemStorage3E Instance = new();
private static ReadOnlySpan<ushort> Pouch_Key_E => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_E =>
[
// R/S
259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
// FR/LG
349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
// E
375, 376,
};
];
private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(ItemStorage3RS.Pouch_Items_RS, Pouch_Key_E,
ItemStorage3RS.Pouch_Ball_RS, ItemStorage3RS.Pouch_TMHM_RS, ItemStorage3RS.Pouch_Berries_RS);
private static readonly ushort[] PCItems = [..Pouch_Items_RS, ..Pouch_Key_E, ..Pouch_Ball_RS, ..Pouch_TMHM_RS, ..Pouch_Berries_RS];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;
public ReadOnlySpan<ushort> GetItems(InventoryType type) => type switch
{
InventoryType.Items => ItemStorage3RS.Pouch_Items_RS,
InventoryType.Items => Pouch_Items_RS,
InventoryType.KeyItems => Pouch_Key_E,
InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS,
InventoryType.TMHMs => ItemStorage3RS.Pouch_TMHM_RS,
InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS,
InventoryType.Balls => Pouch_Ball_RS,
InventoryType.TMHMs => Pouch_TMHM_RS,
InventoryType.Berries => Pouch_Berries_RS,
InventoryType.PCItems => PCItems,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
};

View file

@ -1,4 +1,5 @@
using System;
using static PKHeX.Core.ItemStorage3RS;
namespace PKHeX.Core;
@ -6,26 +7,25 @@ public sealed class ItemStorage3FRLG : IItemStorage
{
public static readonly ItemStorage3FRLG Instance = new();
private static ReadOnlySpan<ushort> Pouch_Key_FRLG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_FRLG =>
[
// R/S
259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
// FR/LG
349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
};
];
private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(ItemStorage3RS.Pouch_Items_RS, Pouch_Key_FRLG,
ItemStorage3RS.Pouch_Ball_RS, ItemStorage3RS.Pouch_TMHM_RS, ItemStorage3RS.Pouch_Berries_RS);
private static readonly ushort[] PCItems = [..Pouch_Items_RS, ..Pouch_Key_FRLG, ..Pouch_Ball_RS, ..Pouch_TMHM_RS, ..Pouch_Berries_RS];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;
public ReadOnlySpan<ushort> GetItems(InventoryType type) => type switch
{
InventoryType.Items => ItemStorage3RS.Pouch_Items_RS,
InventoryType.Items => Pouch_Items_RS,
InventoryType.KeyItems => Pouch_Key_FRLG,
InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS,
InventoryType.TMHMs => ItemStorage3RS.Pouch_TMHM_RS,
InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS,
InventoryType.Balls => Pouch_Ball_RS,
InventoryType.TMHMs => Pouch_TMHM_RS,
InventoryType.Berries => Pouch_Berries_RS,
InventoryType.PCItems => PCItems,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
};

View file

@ -6,21 +6,21 @@ public sealed class ItemStorage3RS : IItemStorage
{
public static readonly ItemStorage3RS Instance = new();
internal static ReadOnlySpan<ushort> Pouch_Items_RS => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_Items_RS =>
[
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258,
};
];
private static ReadOnlySpan<ushort> Pouch_Key_RS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_RS =>
[
259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
};
];
private const int COUNT_TM = 50;
private const int COUNT_HM = 8;
internal static ReadOnlySpan<ushort> Pouch_TMHM_RS => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_TMHM_RS =>
[
289, 290, 291, 292, 293, 294, 295, 296, 297, 298,
299, 300, 301, 302, 303, 304, 305, 306, 307, 308,
309, 310, 311, 312, 313, 314, 315, 316, 317, 318,
@ -29,7 +29,7 @@ public sealed class ItemStorage3RS : IItemStorage
// HMs
339, 340, 341, 342, 343, 344, 345, 346,
};
];
internal static ReadOnlySpan<ushort> Pouch_TM_RS => Pouch_TMHM_RS[..COUNT_TM];
@ -37,24 +37,25 @@ public sealed class ItemStorage3RS : IItemStorage
public static bool IsTM(ushort itemID) => itemID - 289u < COUNT_TM;
public static bool IsHM(ushort itemID) => itemID - 339u < COUNT_HM;
internal static ReadOnlySpan<ushort> Pouch_Berries_RS => new ushort[]
{
133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
};
internal static ReadOnlySpan<ushort> Pouch_Berries_RS =>
[
133, 134, 135, 136, 137, 138, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
170, 171, 172, 173, 174, 175,
];
internal static ReadOnlySpan<ushort> Pouch_Ball_RS => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_Ball_RS =>
[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
};
];
internal static ReadOnlySpan<ushort> Unreleased => new ushort[] { 005 }; // Safari Ball
internal static ReadOnlySpan<ushort> Unreleased => [005]; // Safari Ball
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Items_RS, Pouch_Ball_RS, Pouch_Berries_RS, Pouch_TMHM_RS[..^COUNT_HM]);
}
public static ushort[] GetAllHeld() => [..Pouch_Items_RS, ..Pouch_Ball_RS, ..Pouch_Berries_RS, ..Pouch_TMHM_RS[..^COUNT_HM]];
private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(Pouch_Items_RS, Pouch_Key_RS, Pouch_Ball_RS, Pouch_TMHM_RS, Pouch_Berries_RS);
private static readonly ushort[] PCItems = [..Pouch_Items_RS, ..Pouch_Key_RS, .. Pouch_Berries_RS, ..Pouch_Ball_RS, ..Pouch_TMHM_RS];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -6,39 +6,58 @@ public sealed class ItemStorage3XD : IItemStorage
{
public static readonly ItemStorage3XD Instance = new();
private static ReadOnlySpan<ushort> Pouch_Cologne_XD => new ushort[] { 513, 514, 515 };
private static ReadOnlySpan<ushort> Pouch_Items_XD => new ushort[]
{
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258,
private static ReadOnlySpan<ushort> Pouch_Cologne_XD => [513, 514, 515];
private static ReadOnlySpan<ushort> Pouch_Items_XD =>
[
13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51,
63, 64, 65, 66, 67, 68, 69,
70, 71, 73, 74, 75, 76, 77, 78, 79,
80, 81, 83, 84, 85, 86,
93, 94, 95, 96, 97, 98,
103, 104, 106, 107, 108, 109,
110, 111,
121, 122, 123, 124, 125, 126, 127, 128, 129,
130, 131, 132,
179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225,
254, 255, 256, 257, 258,
// XD Additions
511, // Poké Snack
};
];
private static ReadOnlySpan<ushort> Pouch_Key_XD => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_XD =>
[
500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
510, 512, 516, 517, 518, 519,
523, 524, 525, 526, 527, 528, 529,
530, 531, 532, 533,
};
];
private static ReadOnlySpan<ushort> Pouch_Disc_XD => new ushort[]
{
534, 535, 536, 537, 538, 539,
private static ReadOnlySpan<ushort> Pouch_Disc_XD =>
[
534, 535, 536, 537, 538, 539,
540, 541, 542, 543, 544, 545, 546, 547, 548, 549,
550, 551, 552, 553, 554, 555, 556, 557, 558, 559,
560, 561, 562, 563, 564, 565, 566, 567, 568, 569,
570, 571, 572, 573, 574, 575, 576, 577, 578, 579,
580, 581, 582, 583, 584, 585, 586, 587, 588, 589,
590, 591, 592, 593,
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;
public ReadOnlySpan<ushort> GetItems(InventoryType type) => type switch
{
InventoryType.Items => Pouch_Items_XD,
InventoryType.KeyItems => Pouch_Key_XD,
InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS,

View file

@ -4,24 +4,65 @@ namespace PKHeX.Core;
public abstract class ItemStorage4
{
private protected static ReadOnlySpan<ushort> Pouch_Items_DP => new ushort[]
{
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327,
};
private protected static ReadOnlySpan<ushort> Pouch_Items_DP =>
[
68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
private protected static ReadOnlySpan<ushort> Pouch_Items_Pt => new ushort[]
{
// Adds Griseous Orb
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327,
};
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111,
135, 136,
213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 256, 257, 258, 259,
260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
300, 301, 302, 303, 304, 305, 306, 307, 308, 309,
310, 311, 312, 313, 314, 315, 316, 317, 318, 319,
320, 321, 322, 323, 324, 325, 326, 327,
];
private protected static ReadOnlySpan<ushort> Pouch_Key_DP => new ushort[]
{
428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
};
private protected static ReadOnlySpan<ushort> Pouch_Items_Pt =>
[
68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
private protected static ReadOnlySpan<ushort> Pouch_TMHM_DP => new ushort[]
{
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, // Griseous Orb Added
135, 136,
213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 256, 257, 258, 259,
260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
300, 301, 302, 303, 304, 305, 306, 307, 308, 309,
310, 311, 312, 313, 314, 315, 316, 317, 318, 319,
320, 321, 322, 323, 324, 325, 326, 327,
];
private protected static ReadOnlySpan<ushort> Pouch_Key_DP =>
[
428, 429,
430, 431, 432, 433, 434, 435, 436, 437, 438, 439,
440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
450, 451, 452, 453, 454, 455, 456, 457, 458, 459,
460, 461, 462, 463, 464,
];
private protected static ReadOnlySpan<ushort> Pouch_TMHM_DP =>
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
@ -35,43 +76,54 @@ public abstract class ItemStorage4
// HMs
420, 421, 422, 423, 424, 425, 426, 427,
};
];
private protected static ReadOnlySpan<ushort> Pouch_Mail_DP => new ushort[]
{
private protected static ReadOnlySpan<ushort> Pouch_Mail_DP =>
[
137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
};
];
private protected static ReadOnlySpan<ushort> Pouch_Medicine_DP => new ushort[]
{
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
};
private protected static ReadOnlySpan<ushort> Pouch_Medicine_DP =>
[
17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54,
];
private protected static ReadOnlySpan<ushort> Pouch_Berries_DP => new ushort[]
{
149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
};
private protected static ReadOnlySpan<ushort> Pouch_Berries_DP =>
[
149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212,
];
private protected static ReadOnlySpan<ushort> Pouch_Ball_DP => new ushort[]
{
private protected static ReadOnlySpan<ushort> Pouch_Ball_DP =>
[
1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
};
];
private protected static ReadOnlySpan<ushort> Pouch_Battle_DP => new ushort[]
{
private protected static ReadOnlySpan<ushort> Pouch_Battle_DP =>
[
// Stat Ups
55, 56, 57, 58, 59, 60, 61, 62,
// In-Battle Use
63, 64, 65, 66, 67,
};
];
internal static ReadOnlySpan<ushort> Unreleased => new ushort[]
{
internal static ReadOnlySpan<ushort> Unreleased =>
[
005, // Safari Ball
016, // Cherish Ball
147, // Mosaic Mail
499, // Sport Ball
500, // Park Ball
};
];
}

View file

@ -6,10 +6,7 @@ public sealed class ItemStorage4DP : ItemStorage4, IItemStorage
{
public static readonly ItemStorage4DP Instance = new();
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Items_DP, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP[..^8]);
}
public static ushort[] GetAllHeld() => [..Pouch_Items_DP, ..Pouch_Mail_DP, ..Pouch_Medicine_DP, ..Pouch_Berries_DP, ..Pouch_Ball_DP, ..Pouch_TMHM_DP[..^8]];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -6,15 +6,23 @@ public sealed class ItemStorage4HGSS : ItemStorage4, IItemStorage
{
public static readonly ItemStorage4HGSS Instance = new();
private static ReadOnlySpan<ushort> Pouch_Key_HGSS => new ushort[]
{
434, 435, 437, 444, 445, 446, 447, 450, 456, 464, 465, 466, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 501, 502, 503, 504, 532, 533, 534, 535, 536,
};
private static ReadOnlySpan<ushort> Pouch_Key_HGSS =>
[
434, 435, 437,
444, 445, 446, 447,
450, 456,
464, 465, 466, 468, 469,
470, 471, 472, 473, 474, 475, 476, 477, 478, 479,
480, 481, 482, 483, 484,
501, 502, 503, 504,
532, 533, 534, 535, 536,
];
private static ReadOnlySpan<ushort> Pouch_Ball_HGSS => new ushort[]
{
1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 492, 493, 494, 495, 496, 497, 498, 499, 500,
};
private static ReadOnlySpan<ushort> Pouch_Ball_HGSS =>
[
1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
492, 493, 494, 495, 496, 497, 498, 499, 500, // Apricorn Balls
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -6,15 +6,16 @@ public sealed class ItemStorage4Pt : ItemStorage4, IItemStorage
{
public static readonly ItemStorage4Pt Instance = new();
private static ReadOnlySpan<ushort> Pouch_Key_Pt => new ushort[]
{
428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467,
};
private static ReadOnlySpan<ushort> Pouch_Key_Pt =>
[
428, 429,
430, 431, 432, 433, 434, 435, 436, 437, 438, 439,
440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
450, 451, 452, 453, 454, 455, 456, 457, 458, 459,
460, 461, 462, 463, 464, 465, 466, 467,
];
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Items_Pt, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP[..^8]);
}
public static ushort[] GetAllHeld() => [..Pouch_Items_Pt, ..Pouch_Mail_DP, ..Pouch_Medicine_DP, ..Pouch_Berries_DP, ..Pouch_Ball_DP, ..Pouch_TMHM_DP[..^8]];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -4,9 +4,9 @@ namespace PKHeX.Core;
public abstract class ItemStorage5
{
private protected static ReadOnlySpan<ushort> Pouch_Items_BW => new ushort[]
{
01, 02, 03, 04, 05, 06, 07, 08, 09,
private protected static ReadOnlySpan<ushort> Pouch_Items_BW =>
[
01, 02, 03, 04, 05, 06, 07, 08, 09,
10, 11, 12, 13, 14, 15, 16,
55, 56, 57, 58, 59,
@ -14,11 +14,35 @@ public abstract class ItemStorage5
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, 572, 573, 575, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590,
};
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 116, 117, 118, 119,
135, 136, 137, 138, 139,
140, 141, 142, 143, 144, 145, 146, 147, 148,
private protected static ReadOnlySpan<ushort> Pouch_TMHM_BW => new ushort[]
{
213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 256, 257, 258, 259,
260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
300, 301, 302, 303, 304, 305, 306, 307, 308, 309,
310, 311, 312, 313, 314, 315, 316, 317, 318, 319,
320, 321, 322, 323, 324, 325, 326, 327,
492, 493, 494, 495, 496, 497, 498, 499,
500, 537, 538, 539,
540, 541, 542, 543, 544, 545, 546, 547, 548, 549,
550, 551, 552, 553, 554, 555, 556, 557, 558, 559,
560, 561, 562, 563, 564,
571, 572, 573, 575, 576, 577,
580, 581, 582, 583, 584, 585, 586, 587, 588, 589,
590,
];
private protected static ReadOnlySpan<ushort> Pouch_TMHM_BW =>
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
@ -33,20 +57,35 @@ public abstract class ItemStorage5
618, 619, 620, // 93-95
420, 421, 422, 423, 424, 425,
};
];
private protected static ReadOnlySpan<ushort> Pouch_Medicine_BW => new ushort[]
{
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 134, 504, 565, 566, 567, 568, 569, 570, 591,
};
private protected static ReadOnlySpan<ushort> Pouch_Medicine_BW =>
[
17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54,
private protected static ReadOnlySpan<ushort> Pouch_Berries_BW => new ushort[]
{
149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
};
134,
504, 565, 566, 567, 568, 569,
570, 591,
];
internal static ReadOnlySpan<ushort> Unreleased => new ushort[]
{
private protected static ReadOnlySpan<ushort> Pouch_Berries_BW =>
[
149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212,
];
internal static ReadOnlySpan<ushort> Unreleased =>
[
005, // Safari Ball
016, // Cherish Ball
260, // Red Scarf
@ -64,10 +103,7 @@ public abstract class ItemStorage5
499, // Sport Ball
500, // Park Ball
576, // Dream Ball
};
];
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Items_BW, Pouch_Medicine_BW, Pouch_Berries_BW);
}
public static ushort[] GetAllHeld() => [..Pouch_Items_BW, ..Pouch_Medicine_BW, ..Pouch_Berries_BW];
}

View file

@ -5,12 +5,12 @@ namespace PKHeX.Core;
public sealed class ItemStorage5B2W2 : ItemStorage5, IItemStorage
{
public static readonly ItemStorage5B2W2 Instance = new();
private static ReadOnlySpan<ushort> Pouch_Key_B2W2 => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_B2W2 =>
[
437, 442, 447, 450, 453, 458, 465, 466, 471,
504, 578,
616, 617, 621, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638,
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -6,12 +6,12 @@ public sealed class ItemStorage5BW : ItemStorage5, IItemStorage
{
public static readonly ItemStorage5BW Instance = new();
private static ReadOnlySpan<ushort> Pouch_Key_BW => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_BW =>
[
437, 442, 447, 450, 465, 466, 471,
504, 533, 574, 578, 579,
616, 617, 621, 623, 624, 625, 626,
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -1,4 +1,5 @@
using System;
using static PKHeX.Core.ItemStorage6XY;
namespace PKHeX.Core;
@ -6,8 +7,8 @@ public sealed class ItemStorage6AO : IItemStorage
{
public static readonly ItemStorage6AO Instance = new();
internal static ReadOnlySpan<ushort> Pouch_TMHM_AO => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_TMHM_AO =>
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
@ -26,10 +27,10 @@ public sealed class ItemStorage6AO : IItemStorage
// OR/AS
425, 737,
};
];
private static ReadOnlySpan<ushort> Pouch_Items_AO => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Items_AO =>
[
// Flutes moved to the Medicine pouch.
001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056,
057, 058, 059, 060, 061, 062, 063, 064, 068, 069, 070, 071, 072, 073, 074, 075,
@ -51,17 +52,17 @@ public sealed class ItemStorage6AO : IItemStorage
// OR/AS Additions
534, 535,
752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770,
};
];
private static ReadOnlySpan<ushort> Pouch_Key_AO => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_AO =>
[
216, 445, 446, 447, 465, 466, 471, 628,
629, 631, 632, 638, 697,
// Illegal
// 716, 717, 723, 745, 746, 747, 748, 749, 750, 766,
// ORAS
// OR/AS
457, 474, 503,
718, 719,
@ -70,28 +71,25 @@ public sealed class ItemStorage6AO : IItemStorage
740, 741, 742, 743, 744,
751,
765, 771, 772, 774, 775,
};
];
private static ReadOnlySpan<ushort> Pouch_Medicine_AO => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Medicine_AO =>
[
017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033,
034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051,
052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709,
// OR/AS -- Moved from Items pouch.
065, 066, 067,
};
];
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Items_AO, Pouch_Medicine_AO, ItemStorage6XY.Pouch_Berry_XY);
}
public static ushort[] GetAllHeld() => [..Pouch_Items_AO, ..Pouch_Medicine_AO, ..Pouch_Berry_XY];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount)
{
if (type is InventoryType.KeyItems)
return true;
return ItemStorage6XY.Unreleased.BinarySearch((ushort)itemIndex) < 0;
return Unreleased.BinarySearch((ushort)itemIndex) < 0;
}
public ReadOnlySpan<ushort> GetItems(InventoryType type) => type switch
@ -100,7 +98,7 @@ public sealed class ItemStorage6AO : IItemStorage
InventoryType.KeyItems => Pouch_Key_AO,
InventoryType.TMHMs => Pouch_TMHM_AO,
InventoryType.Medicine => Pouch_Medicine_AO,
InventoryType.Berries => ItemStorage6XY.Pouch_Berry_XY,
InventoryType.Berries => Pouch_Berry_XY,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
};
}

View file

@ -6,8 +6,8 @@ public sealed class ItemStorage6XY : IItemStorage
{
public static readonly ItemStorage6XY Instance = new();
private static ReadOnlySpan<ushort> Pouch_Items_XY => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Items_XY =>
[
001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056,
057, 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075,
076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094,
@ -24,20 +24,20 @@ public sealed class ItemStorage6XY : IItemStorage
647, 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666,
667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685,
699, 704, 710, 711, 715,
};
];
private static ReadOnlySpan<ushort> Pouch_Key_XY => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_XY =>
[
216, 431, 442, 445, 446, 447, 450, 465, 466, 471, 628,
629, 631, 632, 638, 641, 642, 643, 651, 689, 695, 696, 697, 698,
700, 701, 702, 703, 705, 712, 713, 714,
// Illegal
// 716, 717, 706, 707,
};
];
private static ReadOnlySpan<ushort> Pouch_TMHM_XY => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_TMHM_XY =>
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
@ -53,10 +53,10 @@ public sealed class ItemStorage6XY : IItemStorage
690, 691, 692, 693, 694, // 96-100
420, 421, 422, 423, 424,
};
];
private static ReadOnlySpan<ushort> Pouch_Medicine_XY => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Medicine_XY =>
[
017, 018, 019,
020, 021, 022, 023, 024, 025, 026, 027, 028, 029,
030, 031, 032, 033, 034, 035, 036, 037, 038, 039,
@ -70,10 +70,10 @@ public sealed class ItemStorage6XY : IItemStorage
591,
645,
708, 709,
};
];
public static ReadOnlySpan<ushort> Pouch_Berry_XY => new ushort[]
{
public static ReadOnlySpan<ushort> Pouch_Berry_XY =>
[
149, // Cheri Berry
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
@ -86,15 +86,12 @@ public sealed class ItemStorage6XY : IItemStorage
686, // Roseli Berry
687, // Kee Berry
688, // Maranga Berry
};
];
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Items_XY, Pouch_Medicine_XY, Pouch_Berry_XY);
}
public static ushort[] GetAllHeld() => [..Pouch_Items_XY, ..Pouch_Medicine_XY, ..Pouch_Berry_XY];
internal static ReadOnlySpan<ushort> Unreleased => new ushort[]
{
internal static ReadOnlySpan<ushort> Unreleased =>
[
005, // Safari Ball
016, // Cherish Ball
492, // Fast Ball
@ -130,7 +127,7 @@ public sealed class ItemStorage6XY : IItemStorage
589, // Relic Statue
590, // Relic Crown
715, // Fairy Gem
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount)
{

View file

@ -6,8 +6,8 @@ public sealed class ItemStorage7GG : IItemStorage
{
public static readonly ItemStorage7GG Instance = new();
private static ReadOnlySpan<ushort> Pouch_Candy_GG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Candy_GG =>
[
050, // Rare Candy
960, 961, 962, 963, 964, 965, // S
966, 967, 968, 969, 970, 971, // L
@ -24,44 +24,44 @@ public sealed class ItemStorage7GG : IItemStorage
1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049,
1050, 1051, 1052, 1053, 1054, 1055, 1056,
1057,
};
];
private static ReadOnlySpan<ushort> Pouch_Medicine_GG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Medicine_GG =>
[
017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 038, 039, 040, 041, 709, 903,
};
];
private static ReadOnlySpan<ushort> Pouch_TM_GG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_TM_GG =>
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
358, 359, 360, 361, 362, 363, 364, 365, 366, 367,
368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
378, 379, 380, 381, 382, 383, 384, 385, 386, 387,
};
];
private static ReadOnlySpan<ushort> Pouch_PowerUp_GG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_PowerUp_GG =>
[
051, 053, 081, 082, 083, 084, 085,
849,
};
];
private static ReadOnlySpan<ushort> Pouch_Catching_GG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Catching_GG =>
[
001, 002, 003, 004, 012, 164, 166, 168,
861, 862, 863, 864, 865, 866,
};
];
private static ReadOnlySpan<ushort> Pouch_Battle_GG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Battle_GG =>
[
055, 056, 057, 058, 059, 060, 061, 062,
656, 659, 660, 661, 662, 663, 671, 672, 675, 676, 678, 679,
760, 762, 770, 773,
};
];
private static ReadOnlySpan<ushort> Pouch_Regular_GG => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Regular_GG =>
[
076, 077, 078, 079, 086, 087, 088, 089,
090, 091, 092, 093, 101, 102, 103, 113, 115,
121, 122, 123, 124, 125, 126, 127, 128,
@ -70,10 +70,10 @@ public sealed class ItemStorage7GG : IItemStorage
632, 651,
795, 796,
872, 873, 874, 875, 876, 877, 878, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 900, 901, 902,
};
];
internal static ReadOnlySpan<ushort> Pouch_Regular_GG_Key => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_Regular_GG_Key =>
[
113, // Tea
115, // Autograph
121, // Pokémon Box
@ -107,7 +107,7 @@ public sealed class ItemStorage7GG : IItemStorage
894, // Leaf Letter (P)
895, // Leaf Letter (E)
896, // Small Bouquet
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true;

View file

@ -6,8 +6,8 @@ public sealed class ItemStorage7SM : IItemStorage
{
public static readonly ItemStorage7SM Instance = new();
internal static ReadOnlySpan<ushort> Pouch_Regular_SM => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_Regular_SM =>
[
001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016,
055, 056, 057, 058, 059, 060, 061, 062, 063, 064,
068, 069,
@ -54,18 +54,18 @@ public sealed class ItemStorage7SM : IItemStorage
851, 853, 854, 855, 856, 879,
880, 881, 882,
883, 884, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920,
};
];
private static ReadOnlySpan<ushort> Pouch_Key_SM => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_SM =>
[
216,
465, 466, 628, 629, 631, 632, 638,
705, 706, 765, 773, 797,
841, 842, 843, 845, 847, 850, 857, 858, 860,
};
];
internal static ReadOnlySpan<ushort> Pouch_TMHM_SM => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_TMHM_SM =>
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
@ -79,34 +79,34 @@ public sealed class ItemStorage7SM : IItemStorage
618, 619, 620, // 93-95
690, 691, 692, 693, 694, // 96-100
};
];
internal static ReadOnlySpan<ushort> Pouch_Medicine_SM => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_Medicine_SM =>
[
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 65, 66, 67, 134,
504, 565, 566, 567, 568, 569, 570, 591, 645, 708, 709,
852,
};
];
internal static ReadOnlySpan<ushort> Pouch_Berries_SM => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_Berries_SM =>
[
149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
686, 687, 688,
};
];
private static ReadOnlySpan<ushort> Pouch_ZCrystal_SM => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_ZCrystal_SM =>
[
807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835,
};
];
private static ReadOnlySpan<ushort> Pouch_ZCrystalHeld_SM => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_ZCrystalHeld_SM =>
[
// SM
776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836,
};
];
internal static ReadOnlySpan<ushort> Unreleased => new ushort[]
{
internal static ReadOnlySpan<ushort> Unreleased =>
[
005, // Safari Ball
016, // Cherish Ball
064, // Fluffy Tail
@ -168,12 +168,9 @@ public sealed class ItemStorage7SM : IItemStorage
590, // Relic Crown
699, // Discount Coupon
715, // Fairy Gem
};
];
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Regular_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_SM);
}
public static ushort[] GetAllHeld() => [..Pouch_Regular_SM, ..Pouch_Berries_SM, ..Pouch_Medicine_SM, ..Pouch_ZCrystalHeld_SM];
public static bool GetCrystalHeld(ushort itemKey, out ushort itemHeld)
{

View file

@ -1,4 +1,5 @@
using System;
using static PKHeX.Core.ItemStorage7SM;
namespace PKHeX.Core;
@ -6,8 +7,8 @@ public sealed class ItemStorage7USUM : IItemStorage
{
public static readonly ItemStorage7USUM Instance = new();
private static ReadOnlySpan<ushort> Pouch_Key_USUM => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_USUM =>
[
216,
440, // US/UM
465, 466, 628, 629, 631, 632, 638,
@ -15,30 +16,30 @@ public sealed class ItemStorage7USUM : IItemStorage
841, 842, 843, 845, 847, 850, 857, 858, 860,
// US/UM
933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948,
};
];
private static ReadOnlySpan<ushort> Pouch_Roto_USUM => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Roto_USUM =>
[
949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959,
};
];
internal static ReadOnlySpan<ushort> Pouch_ZCrystal_USUM => new ushort[]
{
internal static ReadOnlySpan<ushort> Pouch_ZCrystal_USUM =>
[
// SM
807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835,
// US/UM
927, 928, 929, 930, 931, 932,
};
];
private static ReadOnlySpan<ushort> Pouch_ZCrystalHeld_USUM => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_ZCrystalHeld_USUM =>
[
// SM
776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836,
// US/UM Additions
921, 922, 923, 924, 925, 926,
};
];
public static ushort[] GetAllHeld() => ArrayUtil.ConcatAll(ItemStorage7SM.Pouch_Regular_SM, ItemStorage7SM.Pouch_Berries_SM, ItemStorage7SM.Pouch_Medicine_SM, Pouch_ZCrystalHeld_USUM, Pouch_Roto_USUM);
public static ushort[] GetAllHeld() => [..Pouch_Regular_SM, ..Pouch_Berries_SM, ..Pouch_Medicine_SM, ..Pouch_ZCrystalHeld_USUM, ..Pouch_Roto_USUM];
public static bool GetCrystalHeld(ushort itemKey, out ushort itemHeld)
{
@ -72,15 +73,15 @@ public sealed class ItemStorage7USUM : IItemStorage
if (items.BinarySearch((ushort)itemIndex) < 0)
return false;
return ItemStorage7SM.Unreleased.BinarySearch((ushort)itemIndex) < 0;
return Unreleased.BinarySearch((ushort)itemIndex) < 0;
}
public ReadOnlySpan<ushort> GetItems(InventoryType type) => type switch
{
InventoryType.Medicine => ItemStorage7SM.Pouch_Medicine_SM,
InventoryType.Items => ItemStorage7SM.Pouch_Regular_SM,
InventoryType.TMHMs => ItemStorage7SM.Pouch_TMHM_SM,
InventoryType.Berries => ItemStorage7SM.Pouch_Berries_SM,
InventoryType.Medicine => Pouch_Medicine_SM,
InventoryType.Items => Pouch_Regular_SM,
InventoryType.TMHMs => Pouch_TMHM_SM,
InventoryType.Berries => Pouch_Berries_SM,
InventoryType.KeyItems => Pouch_Key_USUM,
InventoryType.ZCrystals => Pouch_ZCrystal_USUM,
InventoryType.BattleItems => Pouch_Roto_USUM,

View file

@ -6,8 +6,8 @@ public sealed class ItemStorage8BDSP : IItemStorage
{
public static readonly ItemStorage8BDSP Instance = new();
private static ReadOnlySpan<ushort> Pouch_Regular_BS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Regular_BS =>
[
045, 046, 047, 048, 049, 050, 051, 052, 053, 072, 073, 074, 075, 076, 077, 078,
079, 080, 081, 082, 083, 084, 085, 093, 094, 107, 108, 109, 110, 111, 112, 135,
136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
@ -21,23 +21,23 @@ public sealed class ItemStorage8BDSP : IItemStorage
1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244,
1245, 1246, 1247, 1248, 1249, 1250, 1251, 1606,
};
];
private static ReadOnlySpan<ushort> Pouch_Ball_BS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Ball_BS =>
[
001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016,
492, 493, 494, 495, 496, 497, 498, 499, 500,
576,
851,
};
];
private static ReadOnlySpan<ushort> Pouch_Battle_BS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Battle_BS =>
[
055, 056, 057, 058, 059, 060, 061, 062, 063,
};
];
internal static ReadOnlySpan<ushort> Unreleased => new ushort[]
{
internal static ReadOnlySpan<ushort> Unreleased =>
[
005, // Safari Ball
016, // Cherish Ball
044, // Sacred Ash
@ -53,11 +53,11 @@ public sealed class ItemStorage8BDSP : IItemStorage
576, // Dream Ball
849, // Ice Stone
851, // Beast Ball
};
];
internal static ReadOnlySpan<ushort> DisallowHeldTreasure => new ushort[]
{
// new BDSP items, but they can't be held
internal static ReadOnlySpan<ushort> DisallowHeldTreasure =>
[
// new BD/SP items, but they can't be held
1808, // Mysterious Shard S
1809, // Mysterious Shard L
1810, // Digger Drill
@ -72,26 +72,24 @@ public sealed class ItemStorage8BDSP : IItemStorage
1819, // Genome Slate
1820, // Discovery Slate
1821, // Distortion Slate
};
];
private static ReadOnlySpan<ushort> Pouch_Key_BS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_BS =>
[
428, 431, 432, 433, 438, 439, 440, 443, 445, 446, 447, 448, 449, 450, 451, 452,
453, 454, 455, 459, 460, 461, 462, 463, 464, 466, 467, 631, 632,
1267, 1278, 1822,
};
];
private static ReadOnlySpan<ushort> Pouch_Medicine_BS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Medicine_BS =>
[
017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037,
038, 039, 040, 041, 042, 043, 044, 054,
];
// 134 Sweet Heart (future event item?)
};
private static ReadOnlySpan<ushort> Pouch_Berries_BS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Berries_BS =>
[
149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
@ -99,17 +97,17 @@ public sealed class ItemStorage8BDSP : IItemStorage
189, 190, 191, 192, 193, 194, 195, 196, 197, 198,
199, 200, 201, 202, 203, 204, 205, 206, 207, 208,
209, 210, 211, 212, 686,
};
];
private static ReadOnlySpan<ushort> Pouch_Treasure_BS => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Treasure_BS =>
[
086, 087, 088, 089, 090, 091, 092, 099, 100, 101, 102, 103, 104, 105, 106, 795, 796,
1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821,
};
];
private static ReadOnlySpan<ushort> Pouch_TMHM_BS => new ushort[] // TM01-TM100
{
private static ReadOnlySpan<ushort> Pouch_TMHM_BS => // TM01-TM100
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
@ -120,8 +118,8 @@ public sealed class ItemStorage8BDSP : IItemStorage
398, 399, 400, 401, 402, 403, 404, 405, 406, 407,
408, 409, 410, 411, 412, 413, 414, 415, 416, 417,
418, 419,
420, 421, 422, 423, 424, 425, 426, 427, // Previously called HM0X, in BDSP they're now called TM93-TM100
};
420, 421, 422, 423, 424, 425, 426, 427, // Previously called HM0X, in BD/SP they're now called TM93-TM100
];
public int GetMax(InventoryType type) => type switch
{
@ -151,16 +149,13 @@ public sealed class ItemStorage8BDSP : IItemStorage
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
internal static ReadOnlySpan<InventoryType> ValidTypes => new[]
{
internal static ReadOnlySpan<InventoryType> ValidTypes =>
[
InventoryType.Items, InventoryType.KeyItems, InventoryType.TMHMs, InventoryType.Medicine,
InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, InventoryType.Treasure,
};
];
public static ushort[] GetAll()
{
return ArrayUtil.ConcatAll(Pouch_Regular_BS, Pouch_Ball_BS, Pouch_Battle_BS, Pouch_Berries_BS, Pouch_TMHM_BS, Pouch_Medicine_BS, Pouch_Treasure_BS);
}
public static ushort[] GetAll() => [..Pouch_Regular_BS, ..Pouch_Ball_BS, ..Pouch_Battle_BS, ..Pouch_Berries_BS, ..Pouch_TMHM_BS, ..Pouch_Medicine_BS, ..Pouch_Treasure_BS];
public static InventoryType GetInventoryPouch(ushort itemIndex)
{

View file

@ -6,8 +6,8 @@ public sealed class ItemStorage8LA : IItemStorage
{
public static readonly ItemStorage8LA Instance = new();
private static ReadOnlySpan<ushort> Pouch_Items_LA => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Items_LA =>
[
017, 023, 024, 025, 026, 027, 028, 029, 039, 041,
050, 054, 072, 073, 075, 080, 081, 082, 083, 084,
085, 090, 091, 092, 107, 108, 109, 110, 149, 150,
@ -28,10 +28,10 @@ public sealed class ItemStorage8LA : IItemStorage
1733, 1734, 1735, 1736, 1738, 1739, 1740, 1741, 1742, 1746,
1747, 1748, 1749, 1750, 1754, 1755, 1756, 1757, 1758, 1759,
1760, 1761, 1762, 1764, 1785,
};
];
private static ReadOnlySpan<ushort> Pouch_Recipe_LA => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Recipe_LA =>
[
1640, 1641, 1642, 1643, 1644, 1646, 1647, 1648, 1649,
1650, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659,
1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669,
@ -43,10 +43,10 @@ public sealed class ItemStorage8LA : IItemStorage
1751, 1752, 1753,
1783, 1784,
};
];
private static ReadOnlySpan<ushort> Pouch_Key_LA => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_LA =>
[
111,
298, 299,
300, 301, 302, 303, 304, 305, 306, 307, 308, 309,
@ -60,7 +60,7 @@ public sealed class ItemStorage8LA : IItemStorage
1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804,
1805, 1806, 1807,
1828,
};
];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => GetItems(type).BinarySearch((ushort)itemIndex) >= 0;

View file

@ -6,8 +6,8 @@ public sealed class ItemStorage8SWSH : IItemStorage
{
public static readonly ItemStorage8SWSH Instance = new();
private static ReadOnlySpan<ushort> Pouch_Regular_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Regular_SWSH =>
[
045, 046, 047, 048, 049, 050, 051, 052, 053, 076, 077, 079, 080, 081, 082, 083, 084, 085, 107, 108, 109,
110, 112, 116, 117, 118, 119, 135, 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 228,
229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
@ -42,23 +42,23 @@ public sealed class ItemStorage8SWSH : IItemStorage
// DLC 2
1592, 1604, 1606,
};
];
private static ReadOnlySpan<ushort> Pouch_Ball_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Ball_SWSH =>
[
001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016,
492, 493, 494, 495, 496, 497, 498, 499, 500,
576,
851,
};
];
private static ReadOnlySpan<ushort> Pouch_Battle_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Battle_SWSH =>
[
055, 056, 057, 058, 059, 060, 061, 062, 063, 1580,
};
];
private static ReadOnlySpan<ushort> Pouch_Key_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Key_SWSH =>
[
078,
628, 629, 631, 632, 638,
703,
@ -69,10 +69,10 @@ public sealed class ItemStorage8SWSH : IItemStorage
// DLC 2
1590, 1591, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1605, 1607,
};
];
private static ReadOnlySpan<ushort> Pouch_TMTR_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_TMTR_SWSH =>
[
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
@ -100,14 +100,14 @@ public sealed class ItemStorage8SWSH : IItemStorage
1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229,
1230, // TM00
};
];
private const int COUNT_TR = 100;
private static ReadOnlySpan<ushort> Pouch_TR_SWSH => Pouch_TMTR_SWSH.Slice(99, COUNT_TR);
public static bool IsTechRecord(ushort itemID) => itemID - 1130u < COUNT_TR;
private static ReadOnlySpan<ushort> Pouch_Medicine_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Medicine_SWSH =>
[
017, 018, 019, 020, 021, 022, 023, 024, 025, 026,
027, 028, 029, 030, 031, 032, 033, 034, 035, 036,
037, 038, 039, 040, 041, 042, 043, 054,
@ -116,35 +116,38 @@ public sealed class ItemStorage8SWSH : IItemStorage
708, 709,
852, 903,
1579,
};
];
private static ReadOnlySpan<ushort> Pouch_Berries_SWSH => new ushort[]
{
149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 169, 170, 171, 172, 173,
174, 184, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, 198, 199, 200, 201, 202,
203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
private static ReadOnlySpan<ushort> Pouch_Berries_SWSH =>
[
149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 169,
170, 171, 172, 173, 174,
184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212,
686, 687, 688,
};
];
private static ReadOnlySpan<ushort> Pouch_Ingredients_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Ingredients_SWSH =>
[
1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093,
1094, 1095, 1096, 1097, 1098, 1099, 1256, 1257, 1258, 1259,
1260, 1261, 1262, 1263, 1264,
};
];
private static ReadOnlySpan<ushort> Pouch_Treasure_SWSH => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Treasure_SWSH =>
[
086, 087, 088, 089, 090, 091, 092, 094, 106,
571, 580, 581, 582, 583,
795, 796,
1105, 1106, 1107, 1108,
};
];
internal static ReadOnlySpan<ushort> Unreleased => new ushort[]
{
internal static ReadOnlySpan<ushort> Unreleased =>
[
016, // Cherish Ball
298, // Flame Plate
299, // Splash Plate
@ -165,7 +168,7 @@ public sealed class ItemStorage8SWSH : IItemStorage
500, // Park Ball
// 644, // Pixie Plate
};
];
internal static Range DynamaxCrystalBCAT => new(DMAX_START, DMAX_END + 1);
@ -194,10 +197,7 @@ public sealed class ItemStorage8SWSH : IItemStorage
return Unreleased.BinarySearch(item) < 0;
}
public static ushort[] GetAllHeld()
{
return ArrayUtil.ConcatAll(Pouch_Regular_SWSH, Pouch_Ball_SWSH, Pouch_Battle_SWSH, Pouch_Berries_SWSH, Pouch_Medicine_SWSH, Pouch_TR_SWSH, Pouch_Treasure_SWSH, Pouch_Ingredients_SWSH);
}
public static ushort[] GetAllHeld() => [..Pouch_Regular_SWSH, ..Pouch_Ball_SWSH, ..Pouch_Battle_SWSH, ..Pouch_Berries_SWSH, ..Pouch_Medicine_SWSH, ..Pouch_TR_SWSH, ..Pouch_Treasure_SWSH, ..Pouch_Ingredients_SWSH];
public bool IsLegal(InventoryType type, int itemIndex, int itemCount)
{

View file

@ -6,37 +6,37 @@ public sealed class ItemStorage9SV : IItemStorage
{
public static readonly ItemStorage9SV Instance = new();
private static ReadOnlySpan<ushort> Pouch_Medicine_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Medicine_SV =>
[
0017, 0018, 0019, 0020, 0021, 0022, 0023, 0024, 0025, 0026,
0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036,
0037, 0038, 0039, 0040, 0041, 0708, 0709,
};
];
private static ReadOnlySpan<ushort> Pouch_Ball_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Ball_SV =>
[
0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 0010,
0011, 0012, 0013, 0014, 0015, 0016, 0492, 0493, 0494, 0495,
0496, 0497, 0498, 0499, 0500, 0576, 0851, 1785,
};
];
private static ReadOnlySpan<ushort> Pouch_Battle_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Battle_SV =>
[
0055, 0056, 0057, 0058, 0059, 0060, 0061, 0062, 0063,
};
];
private static ReadOnlySpan<ushort> Pouch_Berries_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Berries_SV =>
[
0149, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0158,
0159, 0160, 0161, 0162, 0163, 0169, 0170, 0171, 0172, 0173,
0174, 0184, 0185, 0186, 0187, 0188, 0189, 0190, 0191, 0192,
0193, 0194, 0195, 0196, 0197, 0198, 0199, 0200, 0201, 0202,
0203, 0204, 0205, 0206, 0207, 0208, 0209, 0210, 0211, 0212,
0686, 0687, 0688,
};
];
private static ReadOnlySpan<ushort> Pouch_Other_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Other_SV =>
[
0045, 0046, 0047, 0048, 0049, 0050, 0051, 0052, 0053, 0080,
0081, 0082, 0083, 0084, 0085, 0107, 0108, 0109, 0110, 0111,
0112, 0135, 0136, 0213, 0214, 0217, 0218, 0219, 0220, 0221,
@ -61,10 +61,10 @@ public sealed class ItemStorage9SV : IItemStorage
1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882,
1883, 1884, 1885, 1886, 2344, 2345, 2401, 2402, 2403, 2404,
2406, 2407, 2408, 2411, 2412, 2413, 2414, 2415, 2416, 2479,
};
];
private static ReadOnlySpan<ushort> Pouch_TM_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_TM_SV =>
[
0328, 0329, 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
0338, 0339, 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
0348, 0349, 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
@ -86,16 +86,16 @@ public sealed class ItemStorage9SV : IItemStorage
2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249,
2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259,
2260, 2261,
};
];
private static ReadOnlySpan<ushort> Pouch_Treasure_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Treasure_SV =>
[
0086, 0087, 0088, 0089, 0090, 0091, 0092, 0094, 0106, 0571,
0580, 0581, 0582, 0583, 1842, 1843,
};
];
private static ReadOnlySpan<ushort> Pouch_Picnic_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Picnic_SV =>
[
1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897,
1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907,
1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917,
@ -113,17 +113,17 @@ public sealed class ItemStorage9SV : IItemStorage
2399, 2400, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424,
2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434,
2435, 2436, 2437,
};
];
private static ReadOnlySpan<ushort> Pouch_Event_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Event_SV =>
[
0078, 0466, 0631, 0632, 0638, 0703, 0765, 1267, 1278, 1587,
1589, 1590, 1591, 1829, 1830, 1831, 1832, 1833, 1834, 1835,
1836, 1857, 1858, 2405, 2409, 2410, 2480, 2481,
};
];
private static ReadOnlySpan<ushort> Pouch_Material_SV => new ushort[]
{
private static ReadOnlySpan<ushort> Pouch_Material_SV =>
[
1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965,
1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975,
1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
@ -147,28 +147,28 @@ public sealed class ItemStorage9SV : IItemStorage
2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466,
2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476,
2477, 2478,
};
];
internal static ReadOnlySpan<InventoryType> ValidTypes => new[]
{
internal static ReadOnlySpan<InventoryType> ValidTypes =>
[
InventoryType.Items, InventoryType.KeyItems,
InventoryType.TMHMs,
InventoryType.Medicine, InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems,
InventoryType.Treasure,
InventoryType.Ingredients, InventoryType.Candy,
};
];
private static ReadOnlySpan<InventoryType> ValidHeldTypes => new[]
{
private static ReadOnlySpan<InventoryType> ValidHeldTypes =>
[
InventoryType.Items,
InventoryType.TMHMs,
InventoryType.Medicine, InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems,
InventoryType.Treasure,
};
];
// [AUCTION] Porto Marinada specialty auctioneer, locked behind HOME in 2023.
public static ReadOnlySpan<ushort> Unreleased => new ushort[]
{
public static ReadOnlySpan<ushort> Unreleased =>
[
0005, // Safari Ball
0016, // Cherish Ball
@ -193,7 +193,7 @@ public sealed class ItemStorage9SV : IItemStorage
1592, // Galarica Wreath
1785, // Strange Ball
};
];
public int GetMax(InventoryType type) => type switch
{

View file

@ -1,6 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
@ -41,14 +41,14 @@ public readonly ref struct BinLinkerAccessor
/// </summary>
/// <param name="data">Data reference</param>
/// <param name="identifier">Expected identifier (debug verification only)</param>
public static BinLinkerAccessor Get(ReadOnlySpan<byte> data, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> identifier)
public static BinLinkerAccessor Get(ReadOnlySpan<byte> data, [Length(2, 2)] ReadOnlySpan<byte> identifier)
{
SanityCheckIdentifier(data, identifier);
return new BinLinkerAccessor(data);
}
[Conditional("DEBUG")]
private static void SanityCheckIdentifier(ReadOnlySpan<byte> data, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> identifier)
private static void SanityCheckIdentifier(ReadOnlySpan<byte> data, [Length(2, 2)] ReadOnlySpan<byte> identifier)
{
Debug.Assert(data.Length > 4);
Debug.Assert(identifier[0] == data[0] && identifier[1] == data[1]);

Some files were not shown because too many files have changed in this diff Show more