Adds several convenience features

This commit is contained in:
2024-09-30 14:20:45 +02:00
parent 257c04c98b
commit a39c77745d
9 changed files with 72 additions and 13 deletions

View File

@@ -107,6 +107,11 @@ public interface IPokemon : IScriptSource
/// The stats of the Pokemon including the stat boosts
/// </summary>
StatisticSet<uint> BoostedStats { get; }
/// <summary>
/// The maximum health of the Pokemon.
/// </summary>
uint MaxHealth { get; }
/// <summary>
/// The individual values of the Pokemon.
@@ -268,6 +273,11 @@ public interface IPokemon : IScriptSource
/// heal if the Pokemon has 0 health. If the amount healed is 0, this will return false.
/// </summary>
bool Heal(uint heal, bool allowRevive);
/// <summary>
/// Restores all PP of the Pokemon.
/// </summary>
void RestoreAllPP();
/// <summary>
/// Learn a move by name.
@@ -489,6 +499,9 @@ public class PokemonImpl : ScriptSource, IPokemon
/// <inheritdoc />
public StatisticSet<uint> BoostedStats { get; } = new();
/// <inheritdoc />
public uint MaxHealth => BoostedStats.Hp;
/// <inheritdoc />
public IndividualValueStatisticSet IndividualValues { get; } = new();
@@ -780,6 +793,15 @@ public class PokemonImpl : ScriptSource, IPokemon
return true;
}
/// <inheritdoc />
public void RestoreAllPP()
{
foreach (var move in Moves)
{
move?.RestoreAllUses();
}
}
/// <inheritdoc />
/// <remarks>
/// If the index is 255, it will try to find the first empty move slot.

View File

@@ -40,7 +40,7 @@ public class PokemonParty : IPokemonParty
/// <summary>
/// Sets the Pokemon at an index to a Pokemon, returning the old Pokemon.
/// </summary>
public IPokemon? SwapInto(IPokemon pokemon, int index)
public IPokemon? SwapInto(IPokemon? pokemon, int index)
{
var old = _pokemon[index];
_pokemon[index] = pokemon;
@@ -68,4 +68,21 @@ public class PokemonParty : IPokemonParty
/// <inheritdoc />
public IPokemon? this[int index] => _pokemon[index];
public void Pack()
{
// Pack the party so that all Pokémon are at the front.
for (var i = 0; i < _pokemon.Length; i++)
{
if (_pokemon[i] != null)
continue;
for (var j = i + 1; j < _pokemon.Length; j++)
{
if (_pokemon[j] == null)
continue;
Swap(i, j);
break;
}
}
}
}