using System;
using static PKHeX.Core.LearnMethod;
using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core;
///
/// Egg Moveset Building Order for Generation 2
///
public enum EggSource2 : byte
{
None,
/// Initial moveset for the egg's level.
Base,
/// Egg move inherited from the Father.
FatherEgg,
/// Technical Machine move inherited from the Father.
FatherTM,
/// Level Up move inherited from a parent.
ParentLevelUp,
/// Tutor move (Elemental Beam) inherited from a parent.
Tutor,
Max,
}
///
/// Egg Moveset Building Order for Generation 3 & 4
///
public enum EggSource34 : byte
{
None,
/// Initial moveset for the egg's level.
Base,
/// Egg move inherited from the Father.
FatherEgg,
/// Technical Machine move inherited from the Father.
FatherTM,
/// Level Up move inherited from a parent.
ParentLevelUp,
Max,
/// Special Move applied at the end if certain conditions are satisfied.
VoltTackle,
}
///
/// Egg Moveset Building Order for Generation 5
///
public enum EggSource5 : byte
{
None,
/// Initial moveset for the egg's level.
Base,
/// Egg move inherited from the Father.
FatherEgg,
/// Technical Machine move inherited from the Father.
ParentLevelUp,
/// Technical Machine move inherited from the Father.
/// After level up, unlike Gen3/4!
FatherTM,
Max,
/// Special Move applied at the end if certain conditions are satisfied.
VoltTackle,
}
///
/// Egg Moveset Building Order for Generation 6+
///
public enum EggSource6 : byte
{
None,
/// Initial moveset for the egg's level.
Base,
/// Level Up move inherited from a parent.
ParentLevelUp,
/// Egg move inherited from a parent.
ParentEgg,
Max,
/// Special Move applied at the end if certain conditions are satisfied.
VoltTackle,
}
///
/// Utility logic for converting a move result into a user friendly string.
///
public static class EggSourceUtil
{
///
/// Unboxes the parse result and returns a user friendly string for the move result.
///
public static string GetSourceString(Array parse, int generation, int index)
{
if (index >= parse.Length)
return LMoveSourceEmpty;
return generation switch
{
2 => ((EggSource2[])parse)[index].GetSourceString(),
3 or 4 => ((EggSource34[])parse)[index].GetSourceString(),
5 => ((EggSource5[])parse)[index].GetSourceString(),
>= 6 => ((EggSource6[])parse)[index].GetSourceString(),
_ => LMoveSourceEmpty,
};
}
public static string GetSourceString(this EggSource2 source) => source switch
{
EggSource2.Base => LMoveRelearnEgg,
EggSource2.FatherEgg => LMoveEggInherited,
EggSource2.FatherTM => LMoveEggTMHM,
EggSource2.ParentLevelUp => LMoveEggLevelUp,
EggSource2.Tutor => LMoveEggInheritedTutor,
EggSource2.Max => "Any",
_ => LMoveEggInvalid,
};
public static string GetSourceString(this EggSource34 source) => source switch
{
EggSource34.Base => LMoveRelearnEgg,
EggSource34.FatherEgg => LMoveEggInherited,
EggSource34.FatherTM => LMoveEggTMHM,
EggSource34.ParentLevelUp => LMoveEggLevelUp,
EggSource34.Max => "Any",
EggSource34.VoltTackle => LMoveSourceSpecial,
_ => LMoveEggInvalid,
};
public static string GetSourceString(this EggSource5 source) => source switch
{
EggSource5.Base => LMoveRelearnEgg,
EggSource5.FatherEgg => LMoveEggInherited,
EggSource5.ParentLevelUp => LMoveEggLevelUp,
EggSource5.FatherTM => LMoveEggTMHM,
EggSource5.Max => "Any",
EggSource5.VoltTackle => LMoveSourceSpecial,
_ => LMoveEggInvalid,
};
public static string GetSourceString(this EggSource6 source) => source switch
{
EggSource6.Base => LMoveRelearnEgg,
EggSource6.ParentLevelUp => LMoveEggLevelUp,
EggSource6.ParentEgg => LMoveEggInherited,
EggSource6.Max => "Any",
EggSource6.VoltTackle => LMoveSourceSpecial,
_ => LMoveEggInvalid,
};
///
/// Converts the parse result and returns a user friendly string for the move result.
///
public static LearnMethod GetSource(byte value, int generation) => generation switch
{
2 => ((EggSource2)value).GetSource(),
3 or 4 => ((EggSource34)value).GetSource(),
5 => ((EggSource5)value).GetSource(),
>= 6 => ((EggSource6)value).GetSource(),
_ => None,
};
public static LearnMethod GetSource(this EggSource2 source) => source switch
{
EggSource2.Base => Initial,
EggSource2.FatherEgg => EggMove,
EggSource2.FatherTM => TMHM,
EggSource2.ParentLevelUp => InheritLevelUp,
EggSource2.Tutor => Tutor,
_ => None,
};
public static LearnMethod GetSource(this EggSource34 source) => source switch
{
EggSource34.Base => Initial,
EggSource34.FatherEgg => EggMove,
EggSource34.FatherTM => TMHM,
EggSource34.ParentLevelUp => InheritLevelUp,
EggSource34.VoltTackle => SpecialEgg,
_ => None,
};
public static LearnMethod GetSource(this EggSource5 source) => source switch
{
EggSource5.Base => Initial,
EggSource5.FatherEgg => EggMove,
EggSource5.ParentLevelUp => InheritLevelUp,
EggSource5.FatherTM => TMHM,
EggSource5.VoltTackle => SpecialEgg,
_ => None,
};
public static LearnMethod GetSource(this EggSource6 source) => source switch
{
EggSource6.Base => Initial,
EggSource6.ParentLevelUp => InheritLevelUp,
EggSource6.ParentEgg => EggMove,
EggSource6.VoltTackle => SpecialEgg,
_ => None,
};
}