Support for eggmoves
This commit is contained in:
parent
c088386ba3
commit
38e6630c67
|
@ -87,6 +87,10 @@ public static class SpeciesDataLoader
|
|||
{
|
||||
learnableMoves.AddLevelMove((byte)levelMove.Level, new StringKey(levelMove.Name));
|
||||
}
|
||||
foreach (var eggMove in moves.EggMoves)
|
||||
{
|
||||
learnableMoves.AddEggMove(new StringKey(eggMove));
|
||||
}
|
||||
|
||||
return learnableMoves;
|
||||
}
|
||||
|
|
|
@ -154,6 +154,11 @@ public interface IPokemon : IScriptSource
|
|||
/// are null.
|
||||
/// </summary>
|
||||
IReadOnlyList<ILearnedMove?> Moves { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the Pokemon has a specific move in its current moveset.
|
||||
/// </summary>
|
||||
public bool HasMove(StringKey moveName);
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the Pokemon is allowed to gain experience.
|
||||
|
@ -528,6 +533,9 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||
/// <inheritdoc />
|
||||
public IReadOnlyList<ILearnedMove?> Moves => _learnedMoves;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasMove(StringKey moveName) => Moves.Any(move => move?.MoveData.Name == moveName);
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool AllowedExperience { get; set; }
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@ public interface ILearnableMoves
|
|||
/// <param name="move">The move the Pokémon learns.</param>
|
||||
/// <returns>Whether the move was added successfully.</returns>
|
||||
void AddLevelMove(LevelInt level, StringKey move);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new egg move the Pokémon can learn.
|
||||
/// </summary>
|
||||
/// <param name="move"></param>
|
||||
void AddEggMove(StringKey move);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all moves a Pokémon can learn when leveling up to a specific level.
|
||||
|
@ -27,6 +33,11 @@ public interface ILearnableMoves
|
|||
/// </summary>
|
||||
/// <returns>The moves the Pokémon can learn through leveling up.</returns>
|
||||
IReadOnlyList<StringKey> GetDistinctLevelMoves();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all moves a Pokémon can learn by breeding.
|
||||
/// </summary>
|
||||
IReadOnlyList<StringKey> GetEggMoves();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -34,6 +45,8 @@ public class LearnableMovesImpl : ILearnableMoves
|
|||
{
|
||||
private readonly Dictionary<LevelInt, List<StringKey>> _learnedByLevel = new();
|
||||
private readonly HashSet<StringKey> _distinctLevelMoves = new();
|
||||
|
||||
private readonly List<StringKey> _eggMoves = new();
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -46,6 +59,14 @@ public class LearnableMovesImpl : ILearnableMoves
|
|||
_distinctLevelMoves.Add(move);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddEggMove(StringKey move)
|
||||
{
|
||||
if (_eggMoves.Contains(move))
|
||||
return;
|
||||
_eggMoves.Add(move);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<StringKey> GetLearnedByLevel(LevelInt level)
|
||||
{
|
||||
|
@ -59,4 +80,7 @@ public class LearnableMovesImpl : ILearnableMoves
|
|||
{
|
||||
return _distinctLevelMoves.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<StringKey> GetEggMoves() => _eggMoves;
|
||||
}
|
Loading…
Reference in New Issue