Minor clean

This commit is contained in:
Kurt
2024-09-30 23:54:03 -05:00
parent a970f05a62
commit ee00a21f90
8 changed files with 13 additions and 72 deletions

View File

@@ -46,6 +46,9 @@ private static T GetRandomChoice<T>(IReadOnlyList<T> list)
private ITrainerInfo? GetTrainerFromGroup(GameVersion version, LanguageID? lang = null)
{
var possible = Database.Where(z => version.Contains(z.Key)).ToList();
if (possible.Count == 0)
return null;
if (lang != null)
{
possible = possible.Select(z =>
@@ -66,6 +69,9 @@ private static T GetRandomChoice<T>(IReadOnlyList<T> list)
public ITrainerInfo? GetTrainerFromGen(byte generation, LanguageID? lang = null)
{
var possible = Database.Where(z => z.Key.GetGeneration() == generation).ToList();
if (possible.Count == 0)
return null;
if (lang != null)
{
possible = possible.Select(z =>

View File

@@ -139,10 +139,6 @@ private void SetPINGA_EReader(CK3 pk)
break;
}
while (++ctr <= max);
#if DEBUG
System.Diagnostics.Debug.Assert(ctr < max);
#endif
}
#endregion

View File

@@ -34,7 +34,7 @@ private EncounterArea4(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion g
Type = (SlotType4)data[2];
Rate = data[3];
Version = game;
// although GroundTilePermission flags are 32bit, none have values > 16bit.
// although flags are 32bit, none have values > 16bit.
GroundTile = (GroundTileAllowed)ReadUInt16LittleEndian(data[4..]);
Slots = ReadRegularSlots(data[6..]);

View File

@@ -50,7 +50,6 @@ public PIDIV(PIDType type, ulong seed)
#if DEBUG
public override string ToString() => NoSeed ? Type.ToString() : $"{Type} - 0x{OriginSeed:X8}";
#endif
public bool IsClassicMethod() => Type.IsClassicMethod();
public bool IsSeed64() => Type is PIDType.Xoroshiro;

View File

@@ -107,23 +107,11 @@ public override string CardTitle
public bool GiftEquals(PGT pgt)
{
// Skip over the PGT's "Corresponding PCD Slot" @ 0x02
byte[] g = pgt.Data;
byte[] c = Gift.Data;
ReadOnlySpan<byte> g = pgt.Data;
ReadOnlySpan<byte> c = Gift.Data;
if (g.Length != c.Length || g.Length < 3)
return false;
for (int i = 0; i < 2; i++)
{
if (g[i] != c[i])
return false;
}
for (int i = 3; i < g.Length; i++)
{
if (g[i] != c[i])
return false;
}
return true;
return g[..2].SequenceEqual(c[..2]) && g[3..].SequenceEqual(c[3..]);
}
public override PK4 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)

View File

@@ -11,12 +11,7 @@ public sealed class PK9 : PKM, ISanityChecksum, ITeraType, ITechRecord, IObedien
{
public override ReadOnlySpan<ushort> ExtraBytes =>
[
0x17,
0x1A, 0x1B,
0x23,
0x33,
0x3E, 0x3F,
0x90, 0x91, 0x92, 0x93, // Status condition
0x17, 0x1A, 0x1B, 0x23, 0x33, 0x3E, 0x3F,
0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
0xC5,
0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,

View File

@@ -1,8 +1,3 @@
namespace PKHeX.Core;
namespace PKHeX.Core;
public sealed record SlotGroup(string GroupName, PKM[] Slots)
{
#if DEBUG
public override string ToString() => $"{GroupName}: {Slots.Length} {Slots.GetType().Name}";
#endif
}
public sealed record SlotGroup(string GroupName, PKM[] Slots);

View File

@@ -130,20 +130,6 @@ public static List<Zukan8EntryInfo> GetRawIndexes(PersonalTable8SWSH pt, int dex
_ => lang - 1,
};
#if DEBUG
public IList<string> GetEntryNames(IReadOnlyList<string> speciesNames)
{
var dex = new List<string>();
foreach (var (species, entry) in DexLookup)
{
var name = entry.GetEntryName(speciesNames, species);
dex.Add(name);
}
dex.Sort();
return dex;
}
#endif
#region Structure
internal const int EntrySize = 0x30;
@@ -718,30 +704,6 @@ private int GetSavedIndex()
private const int Rigel1Count = 211; // Count within Armor dex
private const int Rigel2Count = 210; // Count within Crown dex
public const int TotalCount = GalarCount + Rigel1Count + Rigel2Count;
#if DEBUG
/// <summary>
/// Gets the <see cref="Zukan8Index"/> from the absolute (overall) dex index. Don't use this method unless you're analyzing things.
/// </summary>
/// <param name="index">Unique Pokédex index (incremental). Should be 0-indexed.</param>
public static Zukan8Index GetFromAbsoluteIndex(ushort index)
{
if (index > TotalCount)
return new Zukan8Index();
if (index < GalarCount)
return new Zukan8Index(Zukan8Type.Galar, ++index);
index -= GalarCount;
if (index < Rigel1Count)
return new Zukan8Index(Zukan8Type.Armor, ++index);
index -= Rigel1Count;
if (index < Rigel2Count)
return new Zukan8Index(Zukan8Type.Crown, ++index);
throw new ArgumentOutOfRangeException(nameof(index));
}
#endif
public string DexPrefix => DexType.GetZukanTypeInternalPrefix();