Remove FluentResults, documentation
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
namespace PkmnLib.Dynamic.Models;
|
||||
|
||||
/// <summary>
|
||||
/// The result of a battle.
|
||||
/// </summary>
|
||||
public record struct BattleResult
|
||||
{
|
||||
private BattleResult(bool conclusiveResult, byte? winningSide)
|
||||
@@ -8,7 +11,14 @@ public record struct BattleResult
|
||||
WinningSide = winningSide;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An inconclusive battle result. This means no side has won.
|
||||
/// </summary>
|
||||
public static BattleResult Inconclusive => new(false, null);
|
||||
|
||||
/// <summary>
|
||||
/// A conclusive battle result. This means one side has won.
|
||||
/// </summary>
|
||||
public static BattleResult Conclusive(byte winningSide) => new(true, winningSide);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace PkmnLib.Dynamic.Models.Choices;
|
||||
|
||||
/// <summary>
|
||||
/// A choice to flee from a battle.
|
||||
/// </summary>
|
||||
public interface IFleeChoice : ITurnChoice
|
||||
{
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace PkmnLib.Dynamic.Models.Choices;
|
||||
|
||||
/// <summary>
|
||||
/// A choice to use an item
|
||||
/// </summary>
|
||||
public interface IItemChoice : ITurnChoice
|
||||
{
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace PkmnLib.Dynamic.Models.Choices;
|
||||
|
||||
/// <summary>
|
||||
/// A choice to pass a turn.
|
||||
/// </summary>
|
||||
public interface IPassChoice : ITurnChoice
|
||||
{
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace PkmnLib.Dynamic.Models.Choices;
|
||||
|
||||
/// <summary>
|
||||
/// A choice to switch to a different Pokémon.
|
||||
/// </summary>
|
||||
public interface ISwitchChoice : ITurnChoice
|
||||
{
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ using PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
namespace PkmnLib.Dynamic.Models.Choices;
|
||||
|
||||
/// <summary>
|
||||
/// A choice that is made at the beginning of a turn. This can be a switch, flee, item, or pass choice.
|
||||
/// </summary>
|
||||
public interface ITurnChoice : IScriptSource
|
||||
{
|
||||
/// <summary>
|
||||
@@ -33,24 +36,49 @@ public interface ITurnChoice : IScriptSource
|
||||
public void Fail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A basic implementation of a <see cref="ITurnChoice"/>.
|
||||
/// </summary>
|
||||
public abstract class TurnChoice : ScriptSource, ITurnChoice
|
||||
{
|
||||
/// <inheritdoc cref="TurnChoice"/>
|
||||
protected TurnChoice(IPokemon user)
|
||||
{
|
||||
User = user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Pokemon for which the choice is made.
|
||||
/// </summary>
|
||||
public IPokemon User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The speed of the user at the beginning of the turn.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// As a developer you do not need to set this value. It is set at the beginning of a turn automatically.
|
||||
/// </remarks>
|
||||
public uint Speed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A random value that is set at the beginning of the turn. This is used for tie breaking of the turn order.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// As a developer you do not need to set this value. It is set at the beginning of a turn automatically.
|
||||
/// </remarks>
|
||||
public uint RandomValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the choice has failed. A failed choice will stop running, and execute special fail handling
|
||||
/// during turn execution.
|
||||
/// </summary>
|
||||
public bool HasFailed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fail the choice. This will prevent it from executing and run a specific fail handling during execution.
|
||||
/// </summary>
|
||||
public void Fail()
|
||||
{
|
||||
HasFailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,9 @@ using PkmnLib.Static.Moves;
|
||||
|
||||
namespace PkmnLib.Dynamic.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Data for a single hit on a target.
|
||||
/// </summary>
|
||||
public interface IHitData
|
||||
{
|
||||
/// <summary>
|
||||
@@ -40,11 +43,6 @@ public interface IHitData
|
||||
/// Fails the hit.
|
||||
/// </summary>
|
||||
void Fail();
|
||||
|
||||
bool Equals(HitData? other);
|
||||
bool Equals(object? other);
|
||||
int GetHashCode();
|
||||
string ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -81,6 +81,7 @@ public class LearnedMoveImpl : ILearnedMove
|
||||
{
|
||||
private byte _maxPpModification = 0;
|
||||
|
||||
/// <inheritdoc cref="LearnedMoveImpl" />
|
||||
public LearnedMoveImpl(IMoveData moveData, MoveLearnMethod learnMethod)
|
||||
{
|
||||
MoveData = moveData;
|
||||
@@ -97,8 +98,15 @@ public class LearnedMoveImpl : ILearnedMove
|
||||
/// <inheritdoc />
|
||||
public MoveLearnMethod LearnMethod { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The available power points for this move.
|
||||
/// </summary>
|
||||
public byte CurrentPp { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Try to use the move. This subtracts the amount of PP from the current PP. If the amount requested is
|
||||
/// higher than the current PP, this will return false, and the PP will not be reduced.
|
||||
/// </summary>
|
||||
public bool TryUse(byte amount = 1)
|
||||
{
|
||||
if (CurrentPp < amount)
|
||||
@@ -108,7 +116,13 @@ public class LearnedMoveImpl : ILearnedMove
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore the PP to the maximum amount of PP.
|
||||
/// </summary>
|
||||
public void RestoreAllUses() => CurrentPp = MaxPp;
|
||||
|
||||
/// <summary>
|
||||
/// Restore the PP by a certain amount. This will prevent the PP from going above the maximum PP.
|
||||
/// </summary>
|
||||
public void RestoreUses(byte amount) => CurrentPp = (byte)Math.Min(CurrentPp + amount, MaxPp);
|
||||
}
|
||||
@@ -288,5 +288,8 @@ public interface IPokemon : IScriptSource
|
||||
/// </summary>
|
||||
public interface IPokemonBattleData
|
||||
{
|
||||
/// <summary>
|
||||
/// The optional battle the Pokemon is in.
|
||||
/// </summary>
|
||||
IBattle? Battle { get; }
|
||||
}
|
||||
@@ -2,6 +2,9 @@ using System.Collections;
|
||||
|
||||
namespace PkmnLib.Dynamic.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A collection of Pokemon.
|
||||
/// </summary>
|
||||
public interface IPokemonParty : IReadOnlyList<IPokemon?>
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,13 +17,21 @@ public interface IPokemonParty : IReadOnlyList<IPokemon?>
|
||||
/// </summary>
|
||||
void Swap(int index1, int index2);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the party has any Pokemon that could be used in battle.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This will return false if all Pokemon are fainted, or eggs, etc.
|
||||
/// </remarks>
|
||||
bool HasUsablePokemon();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public class PokemonParty : IPokemonParty
|
||||
{
|
||||
private readonly IPokemon?[] _pokemon;
|
||||
|
||||
/// <inheritdoc cref="PokemonParty" />
|
||||
public PokemonParty(int size)
|
||||
{
|
||||
_pokemon = new IPokemon[size];
|
||||
@@ -43,7 +54,8 @@ public class PokemonParty : IPokemonParty
|
||||
(_pokemon[index1], _pokemon[index2]) = (_pokemon[index2], _pokemon[index1]);
|
||||
|
||||
|
||||
public bool HasUsablePokemon() => _pokemon.Any(p => p != null && p.IsUsable);
|
||||
/// <inheritdoc />
|
||||
public bool HasUsablePokemon() => _pokemon.Any(p => p is { IsUsable: true });
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerator<IPokemon?> GetEnumerator() => ((IEnumerable<IPokemon?>)_pokemon).GetEnumerator();
|
||||
|
||||
Reference in New Issue
Block a user