mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
game->version
This commit is contained in:
parent
89cb15b9cd
commit
e25b2037e2
|
|
@ -133,9 +133,9 @@ private static ComboItem[] GetVersionList(GameStrings s)
|
|||
return Util.GetUnsortedCBList(list, OrderedVersionArray);
|
||||
}
|
||||
|
||||
public List<ComboItem> GetItemDataSource(GameVersion game, EntityContext context, ReadOnlySpan<ushort> allowed, bool HaX = false)
|
||||
public List<ComboItem> GetItemDataSource(GameVersion version, EntityContext context, ReadOnlySpan<ushort> allowed, bool HaX = false)
|
||||
{
|
||||
var items = Strings.GetItemStrings(context, game);
|
||||
var items = Strings.GetItemStrings(context, version);
|
||||
return HaX ? Util.GetCBList(items) : Util.GetCBList(items, allowed);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -729,11 +729,11 @@ private static void Deduplicate(Span<string> arr, int group)
|
|||
}
|
||||
}
|
||||
|
||||
public string[] GetItemStrings(EntityContext context, GameVersion game = GameVersion.Any) => context switch
|
||||
public string[] GetItemStrings(EntityContext context, GameVersion version = GameVersion.Any) => context switch
|
||||
{
|
||||
EntityContext.Gen1 => g1items,
|
||||
EntityContext.Gen2 => g2items,
|
||||
EntityContext.Gen3 => GetItemStrings3(game),
|
||||
EntityContext.Gen3 => GetItemStrings3(version),
|
||||
EntityContext.Gen4 => g4items, // mail names changed 4->5
|
||||
EntityContext.Gen8b => GetItemStrings8b(),
|
||||
EntityContext.Gen9 => GetItemStrings9(),
|
||||
|
|
@ -778,9 +778,9 @@ static void InsertZero(Span<string> arr, string insert)
|
|||
}
|
||||
}
|
||||
|
||||
private string[] GetItemStrings3(GameVersion game)
|
||||
private string[] GetItemStrings3(GameVersion version)
|
||||
{
|
||||
switch (game)
|
||||
switch (version)
|
||||
{
|
||||
case GameVersion.COLO:
|
||||
return g3coloitems;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ private static GameVersion[] GetValidGameVersions()
|
|||
/// <summary>
|
||||
/// Indicates if the <see cref="GameVersion"/> value is a value used by the games or is an aggregate indicator.
|
||||
/// </summary>
|
||||
/// <param name="game">Game to check</param>
|
||||
public static bool IsValidSavedVersion(this GameVersion game) => game is > 0 and <= HighestGameID;
|
||||
/// <param name="version">Game to check</param>
|
||||
public static bool IsValidSavedVersion(this GameVersion version) => version is > 0 and <= HighestGameID;
|
||||
|
||||
/// <summary>
|
||||
/// Most recent game ID utilized by official games.
|
||||
|
|
@ -105,27 +105,27 @@ private static GameVersion[] GetValidGameVersions()
|
|||
/// <summary>
|
||||
/// Gets the Generation the <see cref="GameVersion"/> belongs to.
|
||||
/// </summary>
|
||||
/// <param name="game">Game to retrieve the generation for</param>
|
||||
/// <param name="version">Game to retrieve the generation for</param>
|
||||
/// <returns>Generation ID</returns>
|
||||
public static byte GetGeneration(this GameVersion game)
|
||||
public static byte GetGeneration(this GameVersion version)
|
||||
{
|
||||
if (game.IsValidSavedVersion())
|
||||
return game.GetGenerationFromSaved();
|
||||
if (version.IsValidSavedVersion())
|
||||
return version.GetGenerationFromSaved();
|
||||
|
||||
if (Gen1.Contains(game)) return 1;
|
||||
if (Gen2.Contains(game)) return 2;
|
||||
if (Gen3.Contains(game)) return 3;
|
||||
if (Gen4.Contains(game)) return 4;
|
||||
if (Gen5.Contains(game)) return 5;
|
||||
if (Gen6.Contains(game)) return 6;
|
||||
if (Gen7.Contains(game)) return 7;
|
||||
if (Gen7b.Contains(game)) return 7;
|
||||
if (Gen8.Contains(game)) return 8;
|
||||
if (Gen9.Contains(game)) return 9;
|
||||
if (Gen1.Contains(version)) return 1;
|
||||
if (Gen2.Contains(version)) return 2;
|
||||
if (Gen3.Contains(version)) return 3;
|
||||
if (Gen4.Contains(version)) return 4;
|
||||
if (Gen5.Contains(version)) return 5;
|
||||
if (Gen6.Contains(version)) return 6;
|
||||
if (Gen7.Contains(version)) return 7;
|
||||
if (Gen7b.Contains(version)) return 7;
|
||||
if (Gen8.Contains(version)) return 8;
|
||||
if (Gen9.Contains(version)) return 9;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static byte GetGenerationFromSaved(this GameVersion game) => game switch
|
||||
public static byte GetGenerationFromSaved(this GameVersion version) => version switch
|
||||
{
|
||||
RD or GN or BU or YW => 1,
|
||||
GD or SI or C => 2,
|
||||
|
|
@ -146,9 +146,9 @@ public static byte GetGeneration(this GameVersion game)
|
|||
/// <summary>
|
||||
/// Gets the Generation the <see cref="GameVersion"/> belongs to.
|
||||
/// </summary>
|
||||
/// <param name="game">Game to retrieve the generation for</param>
|
||||
/// <param name="version">Game to retrieve the generation for</param>
|
||||
/// <returns>Generation ID</returns>
|
||||
public static ushort GetMaxSpeciesID(this GameVersion game) => game switch
|
||||
public static ushort GetMaxSpeciesID(this GameVersion version) => version switch
|
||||
{
|
||||
RD or GN or BU or YW => Legal.MaxSpeciesID_1,
|
||||
GD or SI or C => Legal.MaxSpeciesID_2,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ internal static class Encounters3FRLG
|
|||
internal static readonly EncounterArea3[] SlotsFR = GetRegular("fr", "fr"u8, FR);
|
||||
internal static readonly EncounterArea3[] SlotsLG = GetRegular("lg", "lg"u8, LG);
|
||||
|
||||
private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan<byte> ident, [ConstantExpected] GameVersion game) => EncounterArea3.GetAreas(Get(resource, ident), game);
|
||||
private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan<byte> ident, [ConstantExpected] GameVersion version)
|
||||
=> EncounterArea3.GetAreas(Get(resource, ident), version);
|
||||
|
||||
private const string tradeFRLG = "tradefrlg";
|
||||
private static readonly string[][] TradeNames = Util.GetLanguageStrings7(tradeFRLG);
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ internal static class Encounters3RSE
|
|||
internal static readonly EncounterArea3[] SlotsS = GetRegular("s", "sa"u8, S);
|
||||
internal static readonly EncounterArea3[] SlotsE = GetRegular("e", "em"u8, E);
|
||||
|
||||
private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan<byte> ident, [ConstantExpected] GameVersion game)
|
||||
=> EncounterArea3.GetAreas(Get(resource, ident), game);
|
||||
private static EncounterArea3[] GetSwarm([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan<byte> ident, [ConstantExpected] GameVersion game)
|
||||
=> EncounterArea3.GetAreasSwarm(Get(resource, ident), game);
|
||||
private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan<byte> ident, [ConstantExpected] GameVersion version)
|
||||
=> EncounterArea3.GetAreas(Get(resource, ident), version);
|
||||
private static EncounterArea3[] GetSwarm([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan<byte> ident, [ConstantExpected] GameVersion version)
|
||||
=> EncounterArea3.GetAreasSwarm(Get(resource, ident), version);
|
||||
|
||||
private static readonly string[] TrainersPikachu = [string.Empty, "コロシアム", "COLOS", "COLOSSEUM", "ARENA", "COLOSSEUM", string.Empty, "CLAUDIO"];
|
||||
private static readonly string[] TrainersCelebi = [string.Empty, "アゲト", "AGATE", "SAMARAGD", "SOFO", "EMERITAE", string.Empty, "ÁGATA"];
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ public static bool IsInaccessibleRank12Nest(byte nestID, byte location)
|
|||
new(SWSH) { Species = 133, Level = 25, Ability = A2, IVs = new(31,31,31,-1,-1,-1), DynamaxLevel = 5, Moves = new(606,273,038,129), CanGigantamax = true }, // ★Sgr7194 Gigantamax Eevee
|
||||
];
|
||||
|
||||
private static EncounterStatic8N[] GetBase([Length(2, 2), ConstantExpected] string name, [ConstantExpected] GameVersion game)
|
||||
private static EncounterStatic8N[] GetBase([Length(2, 2), ConstantExpected] string name, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var data = EncounterUtil.Get(name);
|
||||
const int size = 10;
|
||||
|
|
@ -315,13 +315,13 @@ private static EncounterStatic8N[] GetBase([Length(2, 2), ConstantExpected] stri
|
|||
for (int i = 0; i < result.Length; i++)
|
||||
{
|
||||
var slice = data.Slice(i * size, size);
|
||||
result[i] = EncounterStatic8N.Read(slice, game);
|
||||
result[i] = EncounterStatic8N.Read(slice, version);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static EncounterStatic8ND[] GetDist([Length(2, 2), ConstantExpected] string name, [ConstantExpected] GameVersion game)
|
||||
private static EncounterStatic8ND[] GetDist([Length(2, 2), ConstantExpected] string name, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var data = EncounterUtil.Get(name);
|
||||
const int size = 0x10;
|
||||
|
|
@ -330,7 +330,7 @@ private static EncounterStatic8ND[] GetDist([Length(2, 2), ConstantExpected] str
|
|||
for (int i = 0; i < result.Length; i++)
|
||||
{
|
||||
var slice = data.Slice(i * size, size);
|
||||
result[i] = EncounterStatic8ND.Read(slice, game);
|
||||
result[i] = EncounterStatic8ND.Read(slice, version);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ public sealed class EncounterGenerator1 : IEncounterGenerator
|
|||
public static readonly EncounterGenerator1 Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible1(chain, groups, game);
|
||||
var iterator = new EncounterPossible1(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ public sealed class EncounterGenerator2 : IEncounterGenerator
|
|||
public static readonly EncounterGenerator2 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible2(chain, groups, game, pk);
|
||||
var iterator = new EncounterPossible2(chain, groups, version, pk);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ public sealed class EncounterGenerator3 : IEncounterGenerator
|
|||
public static readonly EncounterGenerator3 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible3(chain, groups, game);
|
||||
var iterator = new EncounterPossible3(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
|||
return GetEncounters(pk, chain, info);
|
||||
}
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible4(chain, groups, game, pk);
|
||||
var iterator = new EncounterPossible4(chain, groups, version, pk);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
|||
return GetEncounters(pk, chain, info);
|
||||
}
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible5(chain, groups, game);
|
||||
var iterator = new EncounterPossible5(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ public sealed class EncounterGenerator6 : IEncounterGenerator
|
|||
public static readonly EncounterGenerator6 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible6(chain, groups, game);
|
||||
var iterator = new EncounterPossible6(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ public sealed class EncounterGenerator7 : IEncounterGenerator
|
|||
public static readonly EncounterGenerator7 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible7(chain, groups, game);
|
||||
var iterator = new EncounterPossible7(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ public sealed class EncounterGenerator7GG : IEncounterGenerator
|
|||
public static readonly EncounterGenerator7GG Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible7GG(chain, groups, game);
|
||||
var iterator = new EncounterPossible7GG(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ public sealed class EncounterGenerator8 : IEncounterGenerator
|
|||
public static readonly EncounterGenerator8 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible8(chain, groups, game);
|
||||
var iterator = new EncounterPossible8(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
public sealed class EncounterGenerator8b : IEncounterGenerator
|
||||
public sealed class EncounterGenerator8b : IEncounterGenerator, IEncounterGeneratorSWSH
|
||||
{
|
||||
public static readonly EncounterGenerator8b Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible8b(chain, groups, game, pk);
|
||||
var iterator = new EncounterPossible8b(chain, groups, version, pk);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
@ -24,11 +24,11 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, Le
|
|||
yield return enc.Encounter;
|
||||
}
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncountersSWSH(PKM pk, EvoCriteria[] chain, GameVersion game)
|
||||
public IEnumerable<IEncounterable> GetEncountersSWSH(PKM pk, EvoCriteria[] chain, GameVersion version)
|
||||
{
|
||||
if (pk is not PK8 pk8)
|
||||
yield break;
|
||||
var iterator = new EncounterEnumerator8bSWSH(pk8, chain, game);
|
||||
var iterator = new EncounterEnumerator8bSWSH(pk8, chain, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc.Encounter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
public sealed class EncounterGenerator9 : IEncounterGenerator
|
||||
public sealed class EncounterGenerator9 : IEncounterGenerator, IEncounterGeneratorSWSH
|
||||
{
|
||||
public static readonly EncounterGenerator9 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
|
@ -23,18 +23,18 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
|||
};
|
||||
}
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var iterator = new EncounterPossible9(chain, groups, game);
|
||||
var iterator = new EncounterPossible9(chain, groups, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc;
|
||||
}
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncountersSWSH(PKM pk, EvoCriteria[] chain, GameVersion game)
|
||||
public IEnumerable<IEncounterable> GetEncountersSWSH(PKM pk, EvoCriteria[] chain, GameVersion version)
|
||||
{
|
||||
if (pk is not PK8 pk8)
|
||||
yield break;
|
||||
var iterator = new EncounterEnumerator9SWSH(pk8, chain, game);
|
||||
var iterator = new EncounterEnumerator9SWSH(pk8, chain, version);
|
||||
foreach (var enc in iterator)
|
||||
yield return enc.Encounter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,11 +116,11 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, Le
|
|||
return GetEncounters(pk, info);
|
||||
}
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
// Don't call this method.
|
||||
if (game.GetGeneration() == 1)
|
||||
return EncounterGenerator1.Instance.GetPossible(pk, chain, game, groups);
|
||||
return EncounterGenerator2.Instance.GetPossible(pk, chain, game, groups);
|
||||
if (version.GetGeneration() == 1)
|
||||
return EncounterGenerator1.Instance.GetPossible(pk, chain, version, groups);
|
||||
return EncounterGenerator2.Instance.GetPossible(pk, chain, version, groups);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ public sealed class EncounterGenerator7X : IEncounterGenerator
|
|||
public static readonly EncounterGenerator7X Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) => pk.Version switch
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups) => pk.Version switch
|
||||
{
|
||||
GameVersion.GO => EncounterGenerator7GO.Instance.GetPossible(pk, chain, game, groups),
|
||||
> GameVersion.GO => EncounterGenerator7GG.Instance.GetPossible(pk, chain, game, groups),
|
||||
_ => EncounterGenerator7.Instance.GetPossible(pk, chain, game, groups),
|
||||
GameVersion.GO => EncounterGenerator7GO.Instance.GetPossible(pk, chain, version, groups),
|
||||
> GameVersion.GO => EncounterGenerator7GG.Instance.GetPossible(pk, chain, version, groups),
|
||||
_ => EncounterGenerator7.Instance.GetPossible(pk, chain, version, groups),
|
||||
};
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ public sealed class EncounterGenerator8X : IEncounterGenerator
|
|||
public static readonly EncounterGenerator8X Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) => game switch
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups) => version switch
|
||||
{
|
||||
GO => EncounterGenerator8GO.Instance.GetPossible(pk, chain, game, groups),
|
||||
PLA => EncounterGenerator8a.Instance.GetPossible(pk, chain, game, groups),
|
||||
BD or SP => EncounterGenerator8b.Instance.GetPossible(pk, chain, game, groups),
|
||||
_ => EncounterGenerator8.Instance.GetPossible(pk, chain, game, groups),
|
||||
GO => EncounterGenerator8GO.Instance.GetPossible(pk, chain, version, groups),
|
||||
PLA => EncounterGenerator8a.Instance.GetPossible(pk, chain, version, groups),
|
||||
BD or SP => EncounterGenerator8b.Instance.GetPossible(pk, chain, version, groups),
|
||||
_ => EncounterGenerator8.Instance.GetPossible(pk, chain, version, groups),
|
||||
};
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ internal sealed class EncounterGeneratorDummy : IEncounterGenerator
|
|||
public static readonly EncounterGeneratorDummy Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) => [];
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups) => [];
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, LegalInfo info) => [];
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM _, LegalInfo __) => [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, Le
|
|||
return [];
|
||||
}
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups)
|
||||
{
|
||||
var lgpe = EncounterGenerator7GO.Instance.GetPossible(pk, chain, game, groups);
|
||||
var lgpe = EncounterGenerator7GO.Instance.GetPossible(pk, chain, version, groups);
|
||||
foreach (var enc in lgpe)
|
||||
yield return enc;
|
||||
|
||||
if (pk is PB7)
|
||||
yield break;
|
||||
|
||||
var home = EncounterGenerator8GO.Instance.GetPossible(pk, chain, game, groups);
|
||||
var home = EncounterGenerator8GO.Instance.GetPossible(pk, chain, version, groups);
|
||||
foreach (var enc in home)
|
||||
yield return enc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ public interface IEncounterGenerator
|
|||
{
|
||||
IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, LegalInfo info);
|
||||
|
||||
IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups);
|
||||
IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion version, EncounterTypeGroup groups);
|
||||
bool CanGenerateEggs { get; }
|
||||
}
|
||||
|
||||
public interface IEncounterGeneratorSWSH
|
||||
{
|
||||
IEnumerable<IEncounterable> GetEncountersSWSH(PKM pk, EvoCriteria[] chain, GameVersion version);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,21 +15,21 @@ public sealed record EncounterArea1 : IEncounterArea<EncounterSlot1>
|
|||
public readonly SlotType1 Type;
|
||||
public readonly byte Rate;
|
||||
|
||||
public static EncounterArea1[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea1[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea1[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea1(input[i], game);
|
||||
result[i] = new EncounterArea1(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea1(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea1(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = data[0];
|
||||
// 1 byte unused
|
||||
Type = (SlotType1)data[2];
|
||||
Rate = data[3];
|
||||
Version = game;
|
||||
Version = version;
|
||||
Slots = ReadSlots(data[4..]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,22 +30,22 @@ public sealed record EncounterArea2 : IEncounterArea<EncounterSlot2>, IAreaLocat
|
|||
_ => Rates,
|
||||
};
|
||||
|
||||
public static EncounterArea2[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea2[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea2[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea2(input[i], game);
|
||||
result[i] = new EncounterArea2(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea2(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea2(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = data[0];
|
||||
Time = (EncounterTime)data[1];
|
||||
Type = (SlotType2)data[2];
|
||||
Rate = data[3];
|
||||
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
var slotData = data[4..];
|
||||
if (Type > Surf) // Not Grass/Surf
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ public sealed record EncounterGift3Colo : IEncounterable, IEncounterMatch, IEnco
|
|||
public required ushort TID16 { get; init; }
|
||||
public required byte OriginalTrainerGender { get; init; }
|
||||
|
||||
public EncounterGift3Colo(ushort species, byte level, ReadOnlyMemory<string> trainers, GameVersion game)
|
||||
public EncounterGift3Colo(ushort species, byte level, ReadOnlyMemory<string> trainers, GameVersion version)
|
||||
{
|
||||
Species = species;
|
||||
Level = level;
|
||||
TrainerNames = trainers;
|
||||
Version = game;
|
||||
Version = version;
|
||||
}
|
||||
|
||||
public string Name => "Gift Encounter";
|
||||
|
|
|
|||
|
|
@ -19,40 +19,40 @@ public sealed record EncounterArea3 : IEncounterArea<EncounterSlot3>, IAreaLocat
|
|||
|
||||
public bool IsMatchLocation(ushort location) => location == Location;
|
||||
|
||||
public static EncounterArea3[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea3[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea3[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea3(input[i], game);
|
||||
result[i] = new EncounterArea3(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static EncounterArea3[] GetAreasSwarm(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea3[] GetAreasSwarm(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea3[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea3(input[i], game, SwarmGrass50);
|
||||
result[i] = new EncounterArea3(input[i], version, SwarmGrass50);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea3(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea3(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = data[0];
|
||||
// data[1] is unused because location is always <= 255.
|
||||
Type = (SlotType3)data[2];
|
||||
Rate = data[3];
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
Slots = ReadRegularSlots(data[4..]);
|
||||
}
|
||||
|
||||
private EncounterArea3(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game, [ConstantExpected] SlotType3 type)
|
||||
private EncounterArea3(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version, [ConstantExpected] SlotType3 type)
|
||||
{
|
||||
Location = data[0];
|
||||
// data[1] is unused because location is always <= 255.
|
||||
Type = type; // data[2] but it's always the same value
|
||||
Rate = data[3];
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
Slots = ReadSwarmSlots(data[4..]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,11 +67,11 @@ public sealed record EncounterTrade3 : IEncounterable, IEncounterMatch, IFixedTr
|
|||
}
|
||||
}
|
||||
|
||||
public EncounterTrade3(ReadOnlySpan<string[]> names, byte index, GameVersion game, uint pid, ushort species, byte level)
|
||||
public EncounterTrade3(ReadOnlySpan<string[]> names, byte index, GameVersion version, uint pid, ushort species, byte level)
|
||||
{
|
||||
Nicknames = EncounterUtil.GetNamesForLanguage(names, index);
|
||||
TrainerNames = EncounterUtil.GetNamesForLanguage(names, (uint)(index + (names[1].Length >> 1)));
|
||||
Version = game;
|
||||
Version = version;
|
||||
PID = pid;
|
||||
Species = species;
|
||||
Level = level;
|
||||
|
|
|
|||
|
|
@ -19,21 +19,21 @@ public sealed record EncounterArea4 : IEncounterArea<EncounterSlot4>, IGroundTyp
|
|||
|
||||
public bool IsMatchLocation(ushort location) => location == Location;
|
||||
|
||||
public static EncounterArea4[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea4[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea4[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea4(input[i], game);
|
||||
result[i] = new EncounterArea4(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea4(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea4(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = data[0];
|
||||
// data[1] is unused because location is always <= 255.
|
||||
Type = (SlotType4)data[2];
|
||||
Rate = data[3];
|
||||
Version = game;
|
||||
Version = version;
|
||||
// although flags are 32bit, none have values > 16bit.
|
||||
GroundTile = (GroundTileAllowed)ReadUInt16LittleEndian(data[4..]);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ public sealed record EncounterTrade4PID : IEncounterable, IEncounterMatch, IEnco
|
|||
public byte ContestTough => Contest;
|
||||
public byte ContestSheen => 0;
|
||||
|
||||
public EncounterTrade4PID(ReadOnlySpan<string[]> names, byte index, GameVersion game, uint pid, ushort species, byte level)
|
||||
public EncounterTrade4PID(ReadOnlySpan<string[]> names, byte index, GameVersion version, uint pid, ushort species, byte level)
|
||||
{
|
||||
Version = game;
|
||||
Version = version;
|
||||
Nicknames = EncounterUtil.GetNamesForLanguage(names, index);
|
||||
TrainerNames = EncounterUtil.GetNamesForLanguage(names, (uint)(index + (names[1].Length >> 1)));
|
||||
PID = pid;
|
||||
|
|
@ -121,10 +121,10 @@ public PK4 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
|
|||
return pk;
|
||||
}
|
||||
|
||||
private int GetReceivedLanguage(int lang, GameVersion game)
|
||||
private int GetReceivedLanguage(int lang, GameVersion version)
|
||||
{
|
||||
if (Version == GameVersion.DPPt)
|
||||
return GetLanguageDPPt(lang, game);
|
||||
return GetLanguageDPPt(lang, version);
|
||||
|
||||
// HG/SS
|
||||
// Has English Language ID for all except English origin, which is French
|
||||
|
|
@ -133,13 +133,13 @@ private int GetReceivedLanguage(int lang, GameVersion game)
|
|||
return lang;
|
||||
}
|
||||
|
||||
private int GetLanguageDPPt(int lang, GameVersion game)
|
||||
private int GetLanguageDPPt(int lang, GameVersion version)
|
||||
{
|
||||
// Has German Language ID for all except German origin, which is English
|
||||
if (Species == (int)Core.Species.Magikarp)
|
||||
return (int)(lang == (int)LanguageID.German ? LanguageID.English : LanguageID.German);
|
||||
// All other trades received (D/P only): English games have a Japanese language ID instead of English.
|
||||
if (game is not GameVersion.Pt && lang == (int)LanguageID.English)
|
||||
if (version is not GameVersion.Pt && lang == (int)LanguageID.English)
|
||||
return (int)LanguageID.Japanese;
|
||||
return lang;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,26 +9,26 @@ namespace PKHeX.Core;
|
|||
{
|
||||
private int EntryCount => Move1 == 0 ? 1 : Move2 == 0 ? 1 : Move3 == 0 ? 2 : 3;
|
||||
|
||||
private void AddTo(GameVersion game, Span<EncounterStatic5Entree> result, ref int ctr)
|
||||
private void AddTo(GameVersion version, Span<EncounterStatic5Entree> result, ref int ctr)
|
||||
{
|
||||
var p = PersonalTable.B2W2[Species];
|
||||
var a = p.HasHiddenAbility ? AbilityPermission.OnlyHidden : AbilityPermission.OnlyFirst;
|
||||
if (Move1 == 0)
|
||||
{
|
||||
result[ctr++] = new EncounterStatic5Entree(game, Species, Level, Form, Gender, a);
|
||||
result[ctr++] = new EncounterStatic5Entree(version, Species, Level, Form, Gender, a);
|
||||
return;
|
||||
}
|
||||
|
||||
result[ctr++] = new EncounterStatic5Entree(game, Species, Level, Form, Gender, a, Move1);
|
||||
result[ctr++] = new EncounterStatic5Entree(version, Species, Level, Form, Gender, a, Move1);
|
||||
if (Move2 == 0)
|
||||
return;
|
||||
result[ctr++] = new EncounterStatic5Entree(game, Species, Level, Form, Gender, a, Move2);
|
||||
result[ctr++] = new EncounterStatic5Entree(version, Species, Level, Form, Gender, a, Move2);
|
||||
if (Move3 == 0)
|
||||
return;
|
||||
result[ctr++] = new EncounterStatic5Entree(game, Species, Level, Form, Gender, a, Move3);
|
||||
result[ctr++] = new EncounterStatic5Entree(version, Species, Level, Form, Gender, a, Move3);
|
||||
}
|
||||
|
||||
public static EncounterStatic5Entree[] GetArray(GameVersion game, ReadOnlySpan<DreamWorldEntry> t)
|
||||
public static EncounterStatic5Entree[] GetArray(GameVersion version, ReadOnlySpan<DreamWorldEntry> t)
|
||||
{
|
||||
// Split encounters with multiple permitted special moves -- a pk can only be obtained with 1 of the special moves!
|
||||
int count = 0;
|
||||
|
|
@ -39,7 +39,7 @@ public static EncounterStatic5Entree[] GetArray(GameVersion game, ReadOnlySpan<D
|
|||
int ctr = 0;
|
||||
var tmp = result.AsSpan();
|
||||
foreach (var s in t)
|
||||
s.AddTo(game, tmp, ref ctr);
|
||||
s.AddTo(version, tmp, ref ctr);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ public sealed record EncounterArea5 : IEncounterArea<EncounterSlot5>, IAreaLocat
|
|||
|
||||
public bool IsMatchLocation(ushort location) => Location == location;
|
||||
|
||||
public static EncounterArea5[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea5[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea5[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea5(input[i], game);
|
||||
result[i] = new EncounterArea5(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea5(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea5(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = ReadUInt16LittleEndian(data);
|
||||
Type = (SlotType5)data[2];
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
Slots = ReadSlots(data[4..]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ public sealed record EncounterArea6AO : IEncounterArea<EncounterSlot6AO>, IAreaL
|
|||
|
||||
public bool IsMatchLocation(ushort location) => Location == location;
|
||||
|
||||
public static EncounterArea6AO[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea6AO[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea6AO[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea6AO(input[i], game);
|
||||
result[i] = new EncounterArea6AO(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea6AO(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea6AO(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = ReadUInt16LittleEndian(data);
|
||||
Type = (SlotType6)data[2];
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
Slots = ReadSlots(data[4..]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ public sealed record EncounterArea6XY : IEncounterArea<EncounterSlot6XY>, IAreaL
|
|||
|
||||
public bool IsMatchLocation(ushort location) => Location == location;
|
||||
|
||||
public static EncounterArea6XY[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game, EncounterArea6XY safari)
|
||||
public static EncounterArea6XY[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version, EncounterArea6XY safari)
|
||||
{
|
||||
int count = input.Length;
|
||||
var result = new EncounterArea6XY[count + 1];
|
||||
for (int i = 0; i < count; i++)
|
||||
result[i] = new EncounterArea6XY(input[i], game);
|
||||
result[i] = new EncounterArea6XY(input[i], version);
|
||||
result[^1] = safari;
|
||||
return result;
|
||||
}
|
||||
|
|
@ -50,11 +50,11 @@ public EncounterArea6XY()
|
|||
Slots = LoadSafariSlots();
|
||||
}
|
||||
|
||||
private EncounterArea6XY(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea6XY(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = ReadUInt16LittleEndian(data);
|
||||
Type = (SlotType6)data[2];
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
Slots = ReadSlots(data[4..]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,19 +23,19 @@ public sealed record EncounterArea7 : IEncounterArea<EncounterSlot7>, IAreaLocat
|
|||
|
||||
public bool IsMatchLocation(ushort location) => Location == location;
|
||||
|
||||
public static EncounterArea7[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea7[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea7[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea7(input[i], game);
|
||||
result[i] = new EncounterArea7(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea7(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea7(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = ReadUInt16LittleEndian(data);
|
||||
Type = (SlotType7)data[2];
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
Slots = ReadSlots(data[4..]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,20 +25,20 @@ public bool IsMatchLocation(ushort location)
|
|||
return location == ToArea1 || location == ToArea2;
|
||||
}
|
||||
|
||||
public static EncounterArea7b[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea7b[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea7b[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea7b(input[i], game);
|
||||
result[i] = new EncounterArea7b(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea7b(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea7b(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = data[0]; // Always < 255
|
||||
ToArea1 = data[2];
|
||||
ToArea2 = data[3];
|
||||
Version = game;
|
||||
Version = version;
|
||||
Slots = ReadSlots(data[4..]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -308,19 +308,19 @@ public static bool IsWeatherBleedPossible(SlotType8 type, AreaWeather8 permit, b
|
|||
_ => None,
|
||||
};
|
||||
|
||||
public static EncounterArea8[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game, [ConstantExpected] bool symbol = false)
|
||||
public static EncounterArea8[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version, bool symbol = false)
|
||||
{
|
||||
var result = new EncounterArea8[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea8(input[i], symbol, game);
|
||||
result[i] = new EncounterArea8(input[i], symbol, version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea8(ReadOnlySpan<byte> areaData, [ConstantExpected] bool symbol, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea8(ReadOnlySpan<byte> areaData, bool symbol, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
PermitCrossover = symbol;
|
||||
Location = areaData[0];
|
||||
Version = game;
|
||||
Version = version;
|
||||
Slots = ReadSlots(areaData, areaData[1]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public sealed record EncounterStatic8N : EncounterStatic8Nest<EncounterStatic8N>
|
|||
public override byte LevelMin => LevelCaps[MinRank * 2];
|
||||
public override byte LevelMax => LevelCaps[(MaxRank * 2) + 1];
|
||||
|
||||
public EncounterStatic8N(byte nestIndex, byte minRank, byte maxRank, byte flawless, [ConstantExpected] GameVersion game) : base(game)
|
||||
public EncounterStatic8N(byte nestIndex, byte minRank, byte maxRank, byte flawless, [ConstantExpected] GameVersion version) : base(version)
|
||||
{
|
||||
NestIndex = nestIndex;
|
||||
MinRank = minRank;
|
||||
|
|
@ -33,7 +33,7 @@ public EncounterStatic8N(byte nestIndex, byte minRank, byte maxRank, byte flawle
|
|||
FlawlessIVCount = flawless;
|
||||
}
|
||||
|
||||
public static EncounterStatic8N Read(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game) => new(data[6], data[7], data[8], data[9], game)
|
||||
public static EncounterStatic8N Read(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version) => new(data[6], data[7], data[8], data[9], version)
|
||||
{
|
||||
Species = ReadUInt16LittleEndian(data),
|
||||
Form = data[2],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public sealed record EncounterStatic8ND : EncounterStatic8Nest<EncounterStatic8N
|
|||
public byte Index { get; }
|
||||
public override string Name => $"Distribution Raid Den Encounter - {Index:000}";
|
||||
|
||||
public EncounterStatic8ND(byte lvl, byte dyna, byte flawless, byte index, [ConstantExpected] GameVersion game) : base(game)
|
||||
public EncounterStatic8ND(byte lvl, byte dyna, byte flawless, byte index, [ConstantExpected] GameVersion version) : base(version)
|
||||
{
|
||||
Level = lvl;
|
||||
DynamaxLevel = dyna;
|
||||
|
|
@ -25,7 +25,7 @@ public EncounterStatic8ND(byte lvl, byte dyna, byte flawless, byte index, [Const
|
|||
Index = index;
|
||||
}
|
||||
|
||||
public static EncounterStatic8ND Read(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
public static EncounterStatic8ND Read(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var d = data[13];
|
||||
var dlvl = (byte)(d & 0x7F);
|
||||
|
|
@ -45,7 +45,7 @@ public static EncounterStatic8ND Read(ReadOnlySpan<byte> data, [ConstantExpected
|
|||
var move4 = ReadUInt16LittleEndian(data[10..]);
|
||||
var moves = new Moveset(move1, move2, move3, move4);
|
||||
|
||||
return new EncounterStatic8ND(data[12], dlvl, flawless, data[15], game)
|
||||
return new EncounterStatic8ND(data[12], dlvl, flawless, data[15], version)
|
||||
{
|
||||
Species = ReadUInt16LittleEndian(data),
|
||||
Form = data[2],
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ public sealed record EncounterTrade8 : IEncounterable, IEncounterMatch, IEncount
|
|||
public byte LevelMin => Level;
|
||||
public byte LevelMax => Level;
|
||||
|
||||
public EncounterTrade8(ReadOnlySpan<string[]> names, byte index, GameVersion game, ushort species, byte level, byte memory, ushort arg, byte feel, byte intensity)
|
||||
public EncounterTrade8(ReadOnlySpan<string[]> names, byte index, GameVersion version, ushort species, byte level, byte memory, ushort arg, byte feel, byte intensity)
|
||||
{
|
||||
Version = game;
|
||||
Version = version;
|
||||
Nicknames = EncounterUtil.GetNamesForLanguage(names, index);
|
||||
TrainerNames = EncounterUtil.GetNamesForLanguage(names, (uint)(index + (names[1].Length >> 1)));
|
||||
Species = species;
|
||||
|
|
@ -72,9 +72,9 @@ public EncounterTrade8(ReadOnlySpan<string[]> names, byte index, GameVersion gam
|
|||
}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public EncounterTrade8(ReadOnlyMemory<string> trainerNames, GameVersion game, ushort species, byte level, byte memory, ushort arg, byte feel, byte intensity)
|
||||
public EncounterTrade8(ReadOnlyMemory<string> trainerNames, GameVersion version, ushort species, byte level, byte memory, ushort arg, byte feel, byte intensity)
|
||||
{
|
||||
Version = game;
|
||||
Version = version;
|
||||
Nicknames = ReadOnlyMemory<string>.Empty;
|
||||
TrainerNames = trainerNames;
|
||||
Species = species;
|
||||
|
|
|
|||
|
|
@ -16,19 +16,19 @@ public sealed record EncounterArea8b : IEncounterArea<EncounterSlot8b>, IAreaLoc
|
|||
public readonly ushort Location;
|
||||
public readonly SlotType8b Type;
|
||||
|
||||
public static EncounterArea8b[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea8b[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea8b[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea8b(input[i], game);
|
||||
result[i] = new EncounterArea8b(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea8b(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea8b(ReadOnlySpan<byte> data, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = ReadUInt16LittleEndian(data);
|
||||
Type = (SlotType8b)data[2];
|
||||
Version = game;
|
||||
Version = version;
|
||||
|
||||
Slots = ReadSlots(data[4..]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ public sealed record EncounterTrade8b : IEncounterable, IEncounterMatch, IEncoun
|
|||
public byte LevelMin => Level;
|
||||
public byte LevelMax => Level;
|
||||
|
||||
public EncounterTrade8b(ReadOnlySpan<string[]> names, byte index, GameVersion game)
|
||||
public EncounterTrade8b(ReadOnlySpan<string[]> names, byte index, GameVersion version)
|
||||
{
|
||||
Version = game;
|
||||
Version = version;
|
||||
Nicknames = EncounterUtil.GetNamesForLanguage(names, index);
|
||||
TrainerNames = EncounterUtil.GetNamesForLanguage(names, (uint)(index + (names[1].Length >> 1)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,19 +18,19 @@ public sealed record EncounterArea9 : IEncounterArea<EncounterSlot9>, IAreaLocat
|
|||
|
||||
public bool IsMatchLocation(ushort location) => Location == location;
|
||||
|
||||
public static EncounterArea9[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion game)
|
||||
public static EncounterArea9[] GetAreas(BinLinkerAccessor input, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
var result = new EncounterArea9[input.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = new EncounterArea9(input[i], game);
|
||||
result[i] = new EncounterArea9(input[i], version);
|
||||
return result;
|
||||
}
|
||||
|
||||
private EncounterArea9(ReadOnlySpan<byte> areaData, [ConstantExpected] GameVersion game)
|
||||
private EncounterArea9(ReadOnlySpan<byte> areaData, [ConstantExpected] GameVersion version)
|
||||
{
|
||||
Location = areaData[0];
|
||||
CrossFrom = areaData[2];
|
||||
Version = game;
|
||||
Version = version;
|
||||
Slots = ReadSlots(areaData[4..]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ public sealed record EncounterTrade9 : IEncounterable, IEncounterMatch, IEncount
|
|||
public required GemType TeraType { get; init; }
|
||||
public bool RibbonPartner { get; }
|
||||
|
||||
public EncounterTrade9(ReadOnlySpan<string[]> names, byte index, GameVersion game, ushort species, byte level)
|
||||
public EncounterTrade9(ReadOnlySpan<string[]> names, byte index, GameVersion version, ushort species, byte level)
|
||||
{
|
||||
Version = game;
|
||||
Version = version;
|
||||
bool partner = RibbonPartner = index is (>= 2 and <= 31);
|
||||
Nicknames = partner ? [] : EncounterUtil.GetNamesForLanguage(names, index);
|
||||
TrainerNames = EncounterUtil.GetNamesForLanguage(names, (uint)(index + (names[1].Length >> 1)));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public static class EggHatchLocation3
|
|||
/// <summary>
|
||||
/// Returns true if the hatch location is valid for the specified Generation 3 game.
|
||||
/// </summary>
|
||||
public static bool IsValidMet3(ushort location, GameVersion game) => game switch
|
||||
public static bool IsValidMet3(ushort location, GameVersion version) => version switch
|
||||
{
|
||||
R or S => IsValidMet3RS(location),
|
||||
E => IsValidMet3E(location),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public static class EggHatchLocation4
|
|||
/// <summary>
|
||||
/// Returns true if the hatch location is valid for the specified Generation 4 game.
|
||||
/// </summary>
|
||||
public static bool IsValidMet4(ushort location, GameVersion game) => game switch
|
||||
public static bool IsValidMet4(ushort location, GameVersion version) => version switch
|
||||
{
|
||||
D or P => IsValidMet4DP(location),
|
||||
Pt => IsValidMet4Pt(location),
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ public static class EggHatchLocation5
|
|||
/// <summary>
|
||||
/// Returns true if the location is valid for the specified Generation 5 game.
|
||||
/// </summary>
|
||||
public static bool IsValidMet5(ushort location, GameVersion game)
|
||||
public static bool IsValidMet5(ushort location, GameVersion version)
|
||||
{
|
||||
var shift = (uint)(game - W);
|
||||
var shift = (uint)(version - W);
|
||||
if (shift >= 4)
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -320,10 +320,10 @@ private static void AppendFrameTimeStamp3(uint frame, StringBuilder sb, Encounte
|
|||
sb.AppendFormat(loc.SuffixDays, (int)time.TotalDays);
|
||||
}
|
||||
|
||||
private static (uint Seed, uint Advances) GetInitialSeed3(uint seed, GameVersion game)
|
||||
private static (uint Seed, uint Advances) GetInitialSeed3(uint seed, GameVersion version)
|
||||
{
|
||||
// Emerald is always initial seed of 0 for startups other than E4/New Game.
|
||||
if (game is GameVersion.E)
|
||||
if (version is GameVersion.E)
|
||||
return (0, LCRNG.GetDistance(0, seed));
|
||||
|
||||
var nearest16 = seed;
|
||||
|
|
@ -333,7 +333,7 @@ private static (uint Seed, uint Advances) GetInitialSeed3(uint seed, GameVersion
|
|||
nearest16 = LCRNG.Prev(nearest16);
|
||||
ctr++;
|
||||
}
|
||||
if (game is GameVersion.R or GameVersion.S)
|
||||
if (version is GameVersion.R or GameVersion.S)
|
||||
{
|
||||
const uint drySeed = 0x05A0;
|
||||
var advances = LCRNG.GetDistance(drySeed, seed);
|
||||
|
|
|
|||
|
|
@ -152,13 +152,13 @@ private static bool VerifyBaseMoves(in BreedInfo<EggSource34> info)
|
|||
return true;
|
||||
}
|
||||
|
||||
private static void MarkMovesForOrigin(in BreedInfo<EggSource34> value, ReadOnlySpan<ushort> eggMoves, int count, bool inheritLevelUp, PersonalInfo4 info, GameVersion gameVersion)
|
||||
private static void MarkMovesForOrigin(in BreedInfo<EggSource34> value, ReadOnlySpan<ushort> eggMoves, int count, bool inheritLevelUp, PersonalInfo4 info, GameVersion version)
|
||||
{
|
||||
var possible = value.Possible;
|
||||
var learn = value.Learnset;
|
||||
var baseEgg = value.Learnset.GetBaseEggMoves(value.Level);
|
||||
var tmlist = MachineMovesTechnical;
|
||||
var hmlist = gameVersion is HG or SS ? MachineMovesHiddenHGSS : MachineMovesHiddenDPPt;
|
||||
var hmlist = version is HG or SS ? MachineMovesHiddenHGSS : MachineMovesHiddenDPPt;
|
||||
|
||||
var moves = value.Moves;
|
||||
for (int i = 0; i < count; i++)
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ public static class GameData
|
|||
/// <summary>
|
||||
/// Gets the Personal table for the specified game version.
|
||||
/// </summary>
|
||||
/// <param name="game">The game version to retrieve data for.</param>
|
||||
/// <param name="version">The game version to retrieve data for.</param>
|
||||
/// <returns>The Personal table for the specified game version.</returns>
|
||||
public static IPersonalTable GetPersonal(GameVersion game) => Personal(game);
|
||||
public static IPersonalTable GetPersonal(GameVersion version) => Personal(version);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the LearnSource for the specified game version.
|
||||
/// </summary>
|
||||
/// <param name="game">The game version to retrieve data for.</param>
|
||||
/// <param name="version">The game version to retrieve data for.</param>
|
||||
/// <returns>The LearnSource for the specified game version.</returns>
|
||||
public static ILearnSource GetLearnSource(GameVersion game) => game switch
|
||||
public static ILearnSource GetLearnSource(GameVersion version) => version switch
|
||||
{
|
||||
RD or GN or BU or RB => LearnSource1RB.Instance,
|
||||
YW or RBY => LearnSource1YW.Instance,
|
||||
|
|
@ -66,15 +66,15 @@ public static class GameData
|
|||
Stadium => LearnSource1YW.Instance,
|
||||
Stadium2 => LearnSource2Stadium.Instance,
|
||||
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(game), $"{game} is not a valid entry in the expression."),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(version), $"{version} is not a valid entry in the expression."),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the personal table for the specified game version.
|
||||
/// </summary>
|
||||
/// <param name="game">The game version to retrieve data for.</param>
|
||||
/// <param name="version">The game version to retrieve data for.</param>
|
||||
/// <returns>The Personal table of the specified game version.</returns>
|
||||
private static IPersonalTable Personal(GameVersion game) => game switch
|
||||
private static IPersonalTable Personal(GameVersion version) => version switch
|
||||
{
|
||||
RD or GN or BU or RB => PersonalTable.RB,
|
||||
YW or RBY => PersonalTable.Y,
|
||||
|
|
@ -119,6 +119,6 @@ public static class GameData
|
|||
Stadium => PersonalTable.Y,
|
||||
Stadium2 => PersonalTable.GS,
|
||||
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(game), $"{game} is not a valid entry in the expression."),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(version), $"{version} is not a valid entry in the expression."),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,18 +32,18 @@ private static bool GetCanBeCaptured(ushort species, ReadOnlySpan<byte> flags)
|
|||
return (flags[offset] & (1 << bitIndex)) != 0;
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<byte> GetPokeCenterLocations(GameVersion game)
|
||||
private static ReadOnlySpan<byte> GetPokeCenterLocations(GameVersion version)
|
||||
{
|
||||
return game is GameVersion.X or GameVersion.Y ? LocationsWithPokeCenter_XY : LocationsWithPokeCenter_AO;
|
||||
return version is GameVersion.X or GameVersion.Y ? LocationsWithPokeCenter_XY : LocationsWithPokeCenter_AO;
|
||||
}
|
||||
|
||||
public static bool GetHasPokeCenterLocation(GameVersion game, ushort loc)
|
||||
public static bool GetHasPokeCenterLocation(GameVersion version, ushort loc)
|
||||
{
|
||||
if (game == GameVersion.Any)
|
||||
if (version == GameVersion.Any)
|
||||
return GetHasPokeCenterLocation(GameVersion.X, loc) || GetHasPokeCenterLocation(GameVersion.AS, loc);
|
||||
if (loc > byte.MaxValue)
|
||||
return false;
|
||||
return GetPokeCenterLocations(game).Contains((byte)loc);
|
||||
return GetPokeCenterLocations(version).Contains((byte)loc);
|
||||
}
|
||||
|
||||
public static int GetMemoryRarity(byte memory) => memory >= MemoryRandChance.Length ? -1 : MemoryRandChance[memory];
|
||||
|
|
|
|||
|
|
@ -23,18 +23,18 @@ public static bool IsBallPermitted(ulong permit, byte ball)
|
|||
return (permit & (1ul << ball)) != 0;
|
||||
}
|
||||
|
||||
public static ulong GetWildBalls(byte generation, GameVersion game) => generation switch
|
||||
public static ulong GetWildBalls(byte generation, GameVersion version) => generation switch
|
||||
{
|
||||
1 => WildPokeBalls1,
|
||||
2 => WildPokeBalls2,
|
||||
3 => WildPokeBalls3,
|
||||
4 => GameVersion.HGSS.Contains(game) ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt,
|
||||
4 => GameVersion.HGSS.Contains(version) ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt,
|
||||
5 => WildPokeBalls5,
|
||||
6 => WildPokeballs6,
|
||||
7 => GameVersion.Gen7b.Contains(game) ? WildPokeballs7b : WildPokeballs7,
|
||||
8 when GameVersion.BDSP.Contains(game) => WildPokeBalls4_HGSS,
|
||||
8 when GameVersion.PLA == game => WildPokeBalls8a,
|
||||
8 => GameVersion.GO == game ? WildPokeballs8g_WithRaid : WildPokeballs8,
|
||||
7 => GameVersion.Gen7b.Contains(version) ? WildPokeballs7b : WildPokeballs7,
|
||||
8 when GameVersion.BDSP.Contains(version) => WildPokeBalls4_HGSS,
|
||||
8 when GameVersion.PLA == version => WildPokeBalls8a,
|
||||
8 => GameVersion.GO == version ? WildPokeballs8g_WithRaid : WildPokeballs8,
|
||||
9 => WildPokeballs9,
|
||||
_ => 0,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -128,11 +128,11 @@ public static int GetMaximumEggHatchCycles(PKM pk, IEncounterTemplate enc)
|
|||
/// <summary>
|
||||
/// Gets a valid <see cref="PKM.MetLocation"/> for an egg hatched in the origin game, accounting for future format transfers altering the data.
|
||||
/// </summary>
|
||||
public static ushort GetEggHatchLocation(GameVersion game, byte format) => game switch
|
||||
public static ushort GetEggHatchLocation(GameVersion version, byte format) => version switch
|
||||
{
|
||||
R or S or E or FR or LG => format switch
|
||||
{
|
||||
3 => game is FR or LG ? Locations.HatchLocationFRLG : Locations.HatchLocationRSE,
|
||||
3 => version is FR or LG ? Locations.HatchLocationFRLG : Locations.HatchLocationRSE,
|
||||
4 => Locations.Transfer3, // Pal Park
|
||||
_ => Locations.Transfer4,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -13,28 +13,28 @@ public interface IVersion
|
|||
|
||||
public static partial class Extensions
|
||||
{
|
||||
private static bool CanBeReceivedBy(this IVersion version, GameVersion game) => version.Version.Contains(game);
|
||||
private static bool CanBeReceivedBy(this IVersion v, GameVersion version) => v.Version.Contains(version);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a compatible saved version value for the given <see cref="IVersion"/>.
|
||||
/// </summary>
|
||||
/// <param name="version">Object requesting a saved version.</param>
|
||||
/// <param name="v">Object requesting a saved version.</param>
|
||||
/// <param name="prefer">Preferred version to use, if possible.</param>
|
||||
public static GameVersion GetCompatibleVersion(this IVersion version, GameVersion prefer)
|
||||
public static GameVersion GetCompatibleVersion(this IVersion v, GameVersion prefer)
|
||||
{
|
||||
if (!version.CanBeReceivedBy(prefer))
|
||||
return version.GetSingleVersion();
|
||||
if (!v.CanBeReceivedBy(prefer))
|
||||
return v.GetSingleVersion();
|
||||
if (!prefer.IsValidSavedVersion())
|
||||
return prefer.GetSingleVersion();
|
||||
return prefer;
|
||||
}
|
||||
|
||||
public static GameVersion GetSingleVersion(this IVersion version)
|
||||
public static GameVersion GetSingleVersion(this IVersion v)
|
||||
{
|
||||
var v = version.Version;
|
||||
if (v.IsValidSavedVersion())
|
||||
return v;
|
||||
return v.GetSingleVersion();
|
||||
var version = v.Version;
|
||||
if (version.IsValidSavedVersion())
|
||||
return version;
|
||||
return version.GetSingleVersion();
|
||||
}
|
||||
|
||||
public static GameVersion GetSingleVersion(this GameVersion lump)
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ public static class Language
|
|||
/// </summary>
|
||||
/// <param name="generation">Generation to check.</param>
|
||||
/// <param name="prefer">Preferred language.</param>
|
||||
/// <param name="game">Game version to check.</param>
|
||||
/// <param name="version">Game version to check.</param>
|
||||
/// <returns>Language that is safe to use for the given generation.</returns>
|
||||
public static LanguageID GetSafeLanguage(byte generation, LanguageID prefer, GameVersion game) => generation switch
|
||||
public static LanguageID GetSafeLanguage(byte generation, LanguageID prefer, GameVersion version) => generation switch
|
||||
{
|
||||
1 when game == GameVersion.BU => Japanese,
|
||||
1 when version == GameVersion.BU => Japanese,
|
||||
1 => HasLanguage(Languages_3, (byte)prefer) ? prefer : SafeLanguage,
|
||||
2 => HasLanguage(Languages_GB, (byte)prefer) ? prefer : SafeLanguage,
|
||||
3 => HasLanguage(Languages_3 , (byte)prefer) ? prefer : SafeLanguage,
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ public sealed record SimpleTrainerInfo : ITrainerInfo, IRegionOriginReadOnly, IT
|
|||
public byte Generation { get; init; } = Latest.Generation;
|
||||
public EntityContext Context { get; init; } = Latest.Context;
|
||||
|
||||
public SimpleTrainerInfo(GameVersion game = Latest.Version)
|
||||
public SimpleTrainerInfo(GameVersion version = Latest.Version)
|
||||
{
|
||||
Version = game;
|
||||
Version = version;
|
||||
Context = Version.GetContext();
|
||||
Generation = Context.Generation();
|
||||
if (Context is not (EntityContext.Gen6 or EntityContext.Gen7))
|
||||
|
|
@ -80,9 +80,9 @@ public sealed record MutableTrainerInfo : ITrainerInfo, IRegionOrigin, ITrainerI
|
|||
public byte Generation { get; set; } = Latest.Generation;
|
||||
public EntityContext Context { get; set; } = Latest.Context;
|
||||
|
||||
public MutableTrainerInfo(GameVersion game = Latest.Version)
|
||||
public MutableTrainerInfo(GameVersion version = Latest.Version)
|
||||
{
|
||||
Version = game;
|
||||
Version = version;
|
||||
Context = Version.GetContext();
|
||||
Generation = Context.Generation();
|
||||
if (Context is not (EntityContext.Gen6 or EntityContext.Gen7))
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ public override int SetString(Span<byte> destBuffer, ReadOnlySpan<char> value, i
|
|||
public override uint ID32 { get => MyStatus.ID32; set => MyStatus.ID32 = value; }
|
||||
public override ushort TID16 { get => MyStatus.TID16; set => MyStatus.TID16 = value; }
|
||||
public override ushort SID16 { get => MyStatus.SID16; set => MyStatus.SID16 = value; }
|
||||
public override GameVersion Version { get => MyStatus.Game; set => MyStatus.Game = value; }
|
||||
public override GameVersion Version { get => MyStatus.Version; set => MyStatus.Version = value; }
|
||||
public override byte Gender { get => MyStatus.Male ? (byte)0 : (byte)1; set => MyStatus.Male = value == 0; }
|
||||
public override int Language { get => Config.Language; set => Config.Language = value; }
|
||||
public override string OT { get => MyStatus.OT; set => MyStatus.OT = value; }
|
||||
|
|
|
|||
|
|
@ -77,12 +77,12 @@ private static bool ReadTrainer(List<string> result, ReadOnlySpan<byte> data)
|
|||
return false;
|
||||
}
|
||||
|
||||
private static string GetGameName(GameVersion game)
|
||||
private static string GetGameName(GameVersion version)
|
||||
{
|
||||
const string unk = "UNKNOWN GAME";
|
||||
if (game is not (GameVersion.X or GameVersion.Y or GameVersion.OR or GameVersion.AS))
|
||||
if (!version.IsGen6())
|
||||
return unk;
|
||||
var list = GameInfo.Strings.gamelist;
|
||||
return list[(byte)game];
|
||||
return list[(byte)version];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,19 +76,19 @@ public MoveType StarterType
|
|||
|
||||
// end structure!
|
||||
|
||||
public GameVersion Game
|
||||
public GameVersion Version
|
||||
{
|
||||
get => ROMCode switch
|
||||
{
|
||||
0 => GameVersion.BD,
|
||||
1 => GameVersion.SP,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(Game)),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(Version)),
|
||||
};
|
||||
set => ROMCode = value switch
|
||||
{
|
||||
GameVersion.BD => 0,
|
||||
GameVersion.SP => 1,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(Game)),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(Version)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,10 +190,10 @@ public static SaveLanguageResult InferFrom1(ReadOnlySpan<char> name, GameVersion
|
|||
}
|
||||
return default;
|
||||
|
||||
static bool MaybeRD(GameVersion game) => game is RD or RB or RBY or Any;
|
||||
static bool MaybeGN(GameVersion game) => game is GN or RB or RBY or Any;
|
||||
static bool MaybeBU(GameVersion game) => game is BU or RBY or Any;
|
||||
static bool MaybeYW(GameVersion game) => game is YW or RBY or Any;
|
||||
static bool MaybeRD(GameVersion version) => version is RD or RB or RBY or Any;
|
||||
static bool MaybeGN(GameVersion version) => version is GN or RB or RBY or Any;
|
||||
static bool MaybeBU(GameVersion version) => version is BU or RBY or Any;
|
||||
static bool MaybeYW(GameVersion version) => version is YW or RBY or Any;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="InferFrom(SAV1)"/>
|
||||
|
|
@ -237,9 +237,9 @@ public static SaveLanguageResult InferFrom2(ReadOnlySpan<char> name, GameVersion
|
|||
if (MaybeSI(hint) && Contains(name, "si")) return (OverrideLanguageGen2, SI);
|
||||
return default;
|
||||
|
||||
static bool MaybeGD(GameVersion game) => game is GD or GS or Any;
|
||||
static bool MaybeSI(GameVersion game) => game is SI or GS or Any;
|
||||
static bool MaybeC(GameVersion game) => game is C or Any;
|
||||
static bool MaybeGD(GameVersion version) => version is GD or GS or Any;
|
||||
static bool MaybeSI(GameVersion version) => version is SI or GS or Any;
|
||||
static bool MaybeC (GameVersion version) => version is C or Any;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="InferFrom(SAV1)"/>
|
||||
|
|
@ -309,11 +309,11 @@ public static SaveLanguageResult InferFrom3(ReadOnlySpan<char> name, GameVersion
|
|||
}
|
||||
return default;
|
||||
|
||||
static bool MaybeFR(GameVersion game) => game is FR or FRLG or Any;
|
||||
static bool MaybeLG(GameVersion game) => game is LG or FRLG or Any;
|
||||
static bool MaybeR(GameVersion game) => game is R or RS or Any;
|
||||
static bool MaybeS(GameVersion game) => game is S or RS or Any;
|
||||
static bool MaybeE(GameVersion game) => game is E or RS or Any;
|
||||
static bool MaybeFR(GameVersion version) => version is FR or FRLG or Any;
|
||||
static bool MaybeLG(GameVersion version) => version is LG or FRLG or Any;
|
||||
static bool MaybeR (GameVersion version) => version is R or RS or Any;
|
||||
static bool MaybeS (GameVersion version) => version is S or RS or Any;
|
||||
static bool MaybeE (GameVersion version) => version is E or RS or Any;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ public abstract class SpriteBuilder : ISpriteBuilder<Bitmap>
|
|||
/// <summary>
|
||||
/// Ensures all data is set up to generate sprites for the save file.
|
||||
/// </summary>
|
||||
/// <param name="sav"></param>
|
||||
public void Initialize(SaveFile sav)
|
||||
{
|
||||
if (sav.Generation != 3)
|
||||
|
|
@ -71,14 +70,14 @@ public void Initialize(SaveFile sav)
|
|||
|
||||
// If the game is indeterminate, we might have different form sprites.
|
||||
// Currently, this only applies to Gen3's FireRed / LeafGreen
|
||||
Game = sav.Version;
|
||||
if (Game == GameVersion.FRLG)
|
||||
Game = ReferenceEquals(sav.Personal, PersonalTable.FR) ? GameVersion.FR : GameVersion.LG;
|
||||
Version = sav.Version;
|
||||
if (Version == GameVersion.FRLG)
|
||||
Version = ReferenceEquals(sav.Personal, PersonalTable.FR) ? GameVersion.FR : GameVersion.LG;
|
||||
}
|
||||
|
||||
private GameVersion Game;
|
||||
private GameVersion Version;
|
||||
|
||||
private static byte GetDeoxysForm(GameVersion game) => game switch
|
||||
private static byte GetDeoxysForm(GameVersion version) => version switch
|
||||
{
|
||||
GameVersion.FR => 1, // Attack
|
||||
GameVersion.LG => 2, // Defense
|
||||
|
|
@ -110,7 +109,7 @@ public Bitmap GetSprite(ushort species, byte form, byte gender, uint formarg, in
|
|||
return None;
|
||||
|
||||
if (context == EntityContext.Gen3 && species == (int)Species.Deoxys) // Depends on Gen3 save file version
|
||||
form = GetDeoxysForm(Game);
|
||||
form = GetDeoxysForm(Version);
|
||||
else if (context == EntityContext.Gen4 && species == (int)Species.Arceus) // Curse type's existence in Gen4
|
||||
form = GetArceusForm4(form);
|
||||
|
||||
|
|
|
|||
|
|
@ -250,10 +250,10 @@ private void LoadSAV(object sender, string path)
|
|||
ChangeSAV();
|
||||
}
|
||||
|
||||
private static string GetGameFilePrefix(GameVersion game) => game switch
|
||||
private static string GetGameFilePrefix(GameVersion version) => version switch
|
||||
{
|
||||
BD or SP or BDSP => "bdsp",
|
||||
_ => throw new IndexOutOfRangeException(nameof(game)),
|
||||
_ => throw new IndexOutOfRangeException(nameof(version)),
|
||||
};
|
||||
|
||||
private void DiffSaves()
|
||||
|
|
|
|||
|
|
@ -242,13 +242,13 @@ private void LoadSAV(object sender, string path)
|
|||
ChangeSAV();
|
||||
}
|
||||
|
||||
private static string[] GetStringList(GameVersion game, [ConstantExpected] string type)
|
||||
private static string[] GetStringList(GameVersion version, [ConstantExpected] string type)
|
||||
{
|
||||
var gamePrefix = GetGameFilePrefix(game);
|
||||
var gamePrefix = GetGameFilePrefix(version);
|
||||
return GameLanguage.GetStrings(gamePrefix, GameInfo.CurrentLanguage, type);
|
||||
}
|
||||
|
||||
private static string GetGameFilePrefix(GameVersion game) => game switch
|
||||
private static string GetGameFilePrefix(GameVersion version) => version switch
|
||||
{
|
||||
SL or VL or SV => "sv",
|
||||
BD or SP or BDSP => "bdsp",
|
||||
|
|
@ -267,7 +267,7 @@ private static string[] GetStringList(GameVersion game, [ConstantExpected] strin
|
|||
C => "c",
|
||||
R or S or RS => "rs",
|
||||
FR or LG or FRLG => "frlg",
|
||||
_ => throw new IndexOutOfRangeException(nameof(game)),
|
||||
_ => throw new IndexOutOfRangeException(nameof(version)),
|
||||
};
|
||||
|
||||
private void DiffSaves()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user