mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-30 13:31:15 -05:00
Move Breeding.CanGameGenerateEggs to generator
Already have a reference to it, no need to re-pivot off version. Remove old method for checking if a Daycare exists; not all daycares give eggs, and not all egg-producing games have daycares.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using static PKHeX.Core.GameVersion;
|
||||
using static PKHeX.Core.Species;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
@@ -8,25 +7,6 @@ namespace PKHeX.Core;
|
||||
/// </summary>
|
||||
public static class Breeding
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the game has a Daycare, and returns true if it does.
|
||||
/// </summary>
|
||||
/// <param name="game">Version ID to check for.</param>
|
||||
public static bool CanGameGenerateEggs(GameVersion game) => game switch
|
||||
{
|
||||
R or S or E or FR or LG => true,
|
||||
D or P or Pt or HG or SS => true,
|
||||
B or W or B2 or W2 => true,
|
||||
X or Y or OR or AS => true,
|
||||
SN or MN or US or UM => true,
|
||||
GD or SI or C => true,
|
||||
SW or SH or BD or SP => true,
|
||||
SL or VL => true,
|
||||
|
||||
GS => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Species that have special handling for breeding.
|
||||
/// </summary>
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace PKHeX.Core;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator3GC : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator3GC Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion __, EncounterTypeGroup groups)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator4 : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator4 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
// Utility
|
||||
internal static readonly PGT RangerManaphy = new() { Data = { [0] = 7, [8] = 1 } };
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator5 : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator5 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator7GG : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator7GG Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator7GO : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator7GO Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion __, EncounterTypeGroup groups)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator8GO : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator8GO Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion __, EncounterTypeGroup groups)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator8a : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator8a Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion __, EncounterTypeGroup groups)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator8b : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator8b Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator9 : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator9 Instance = new();
|
||||
public bool CanGenerateEggs => true;
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGenerator12 : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGenerator12 Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM pk, LegalInfo info)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace PKHeX.Core;
|
||||
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
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace PKHeX.Core;
|
||||
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
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace PKHeX.Core;
|
||||
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> GetEncounters(PKM pk, EvoCriteria[] chain, LegalInfo info) => [];
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace PKHeX.Core;
|
||||
public sealed class EncounterGeneratorGO : IEncounterGenerator
|
||||
{
|
||||
public static readonly EncounterGeneratorGO Instance = new();
|
||||
public bool CanGenerateEggs => false;
|
||||
|
||||
public IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, LegalInfo info)
|
||||
{
|
||||
|
||||
@@ -7,4 +7,5 @@ public interface IEncounterGenerator
|
||||
IEnumerable<IEncounterable> GetEncounters(PKM pk, EvoCriteria[] chain, LegalInfo info);
|
||||
|
||||
IEnumerable<IEncounterable> GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups);
|
||||
bool CanGenerateEggs { get; }
|
||||
}
|
||||
|
||||
@@ -259,11 +259,11 @@ private static IEnumerable<IEncounterable> GetPossibleOfType(PKM pk, ReadOnlyMem
|
||||
/// <param name="needs">Moves which cannot be taught by the player.</param>
|
||||
/// <param name="chain">Origin possible evolution chain</param>
|
||||
/// <param name="version">Specific version to iterate for. Necessary for retrieving possible Egg Moves.</param>
|
||||
/// <param name="generator"></param>
|
||||
/// <param name="generator">Encounter generator to use.</param>
|
||||
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
|
||||
private static IEnumerable<IEncounterable> GetEggs(PKM pk, ReadOnlyMemory<ushort> needs, EvoCriteria[] chain, GameVersion version, IEncounterGenerator generator)
|
||||
{
|
||||
if (!Breeding.CanGameGenerateEggs(version))
|
||||
if (!generator.CanGenerateEggs)
|
||||
yield break; // no eggs from these games
|
||||
|
||||
var eggs = generator.GetPossible(pk, chain, version, Egg);
|
||||
@@ -303,7 +303,7 @@ private static IEnumerable<IEncounterable> GetGifts(PKM pk, ReadOnlyMemory<ushor
|
||||
/// <param name="needs">Moves which cannot be taught by the player.</param>
|
||||
/// <param name="chain">Origin possible evolution chain</param>
|
||||
/// <param name="version">Specific version to iterate for.</param>
|
||||
/// <param name="generator"></param>
|
||||
/// <param name="generator">Encounter generator to use.</param>
|
||||
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
|
||||
private static IEnumerable<IEncounterable> GetStatic(PKM pk, ReadOnlyMemory<ushort> needs, EvoCriteria[] chain, GameVersion version, IEncounterGenerator generator)
|
||||
{
|
||||
@@ -325,7 +325,7 @@ private static IEnumerable<IEncounterable> GetStatic(PKM pk, ReadOnlyMemory<usho
|
||||
/// <param name="needs">Moves which cannot be taught by the player.</param>
|
||||
/// <param name="chain">Origin possible evolution chain</param>
|
||||
/// <param name="version">Specific version to iterate for.</param>
|
||||
/// <param name="generator"></param>
|
||||
/// <param name="generator">Encounter generator to use.</param>
|
||||
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
|
||||
private static IEnumerable<IEncounterable> GetTrades(PKM pk, ReadOnlyMemory<ushort> needs, EvoCriteria[] chain, GameVersion version, IEncounterGenerator generator)
|
||||
{
|
||||
@@ -347,7 +347,7 @@ private static IEnumerable<IEncounterable> GetTrades(PKM pk, ReadOnlyMemory<usho
|
||||
/// <param name="needs">Moves which cannot be taught by the player.</param>
|
||||
/// <param name="chain">Origin possible evolution chain</param>
|
||||
/// <param name="version">Origin version</param>
|
||||
/// <param name="generator"></param>
|
||||
/// <param name="generator">Encounter generator to use.</param>
|
||||
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
|
||||
private static IEnumerable<IEncounterable> GetSlots(PKM pk, ReadOnlyMemory<ushort> needs, EvoCriteria[] chain, GameVersion version, IEncounterGenerator generator)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user