using PkmnLib.Static.Utils;
namespace PkmnLib.Static.Species;
///
/// The storage of the moves a Pokémon can learn.
///
public interface ILearnableMoves
{
///
/// Adds a new level move the Pokémon can learn.
///
/// The level the Pokémon learns the move at.
/// The move the Pokémon learns.
/// Whether the move was added successfully.
void AddLevelMove(LevelInt level, StringKey move);
///
/// Adds a new egg move the Pokémon can learn.
///
///
void AddEggMove(StringKey move);
///
/// Gets all moves a Pokémon can learn when leveling up to a specific level.
///
/// The level the Pokémon is learning moves at.
/// The moves the Pokémon learns at that level.
IReadOnlyList GetLearnedByLevel(LevelInt level);
///
/// Gets the distinct moves a Pokémon can learn through leveling up.
///
/// The moves the Pokémon can learn through leveling up.
IReadOnlyList GetDistinctLevelMoves();
///
/// Gets all moves a Pokémon can learn by breeding.
///
IReadOnlyList GetEggMoves();
}
///
public class LearnableMovesImpl : ILearnableMoves
{
private readonly Dictionary> _learnedByLevel = new();
private readonly HashSet _distinctLevelMoves = new();
private readonly List _eggMoves = new();
///
public void AddLevelMove(LevelInt level, StringKey move)
{
if (!_learnedByLevel.TryGetValue(level, out var value))
_learnedByLevel[level] = [move];
else
value.Add(move);
_distinctLevelMoves.Add(move);
}
///
public void AddEggMove(StringKey move)
{
if (_eggMoves.Contains(move))
return;
_eggMoves.Add(move);
}
///
public IReadOnlyList GetLearnedByLevel(LevelInt level)
{
if (!_learnedByLevel.TryGetValue(level, out var value))
return Array.Empty();
return value;
}
///
public IReadOnlyList GetDistinctLevelMoves()
{
return _distinctLevelMoves.ToList();
}
///
public IReadOnlyList GetEggMoves() => _eggMoves;
}