Remove FluentResults, documentation
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentResults" Version="3.16.0" />
|
||||
<PackageReference Include="PcgRandom" Version="1.2.0" />
|
||||
<PackageReference Include="PolySharp" Version="1.14.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Immutable;
|
||||
using FluentResults;
|
||||
using PkmnLib.Static.Utils;
|
||||
using PkmnLib.Static.Utils.Errors;
|
||||
|
||||
@@ -59,7 +58,7 @@ public interface IForm : INamedValue
|
||||
/// <summary>
|
||||
/// Get a type of the form at a certain index.
|
||||
/// </summary>
|
||||
Result<TypeIdentifier> GetType(int index);
|
||||
TypeIdentifier GetType(int index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single base stat value.
|
||||
@@ -74,7 +73,7 @@ public interface IForm : INamedValue
|
||||
/// <summary>
|
||||
/// Gets an ability from the form.
|
||||
/// </summary>
|
||||
Result<StringKey> GetAbility(AbilityIndex index);
|
||||
StringKey GetAbility(AbilityIndex index);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random ability from the form.
|
||||
@@ -150,10 +149,10 @@ public class FormImpl : IForm
|
||||
public ImmutableHashSet<StringKey> Flags { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Result<TypeIdentifier> GetType(int index)
|
||||
public TypeIdentifier GetType(int index)
|
||||
{
|
||||
if (index < 0 || index >= Types.Count)
|
||||
return Result.Fail(new OutOfRange("Type", index, Types.Count));
|
||||
throw new OutOfRangeException("Type", index, Types.Count);
|
||||
return Types[index];
|
||||
}
|
||||
|
||||
@@ -185,11 +184,11 @@ public class FormImpl : IForm
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Result<StringKey> GetAbility(AbilityIndex index)
|
||||
public StringKey GetAbility(AbilityIndex index)
|
||||
{
|
||||
var array = index.IsHidden ? HiddenAbilities : Abilities;
|
||||
if (index.Index >= array.Count)
|
||||
return Result.Fail(new OutOfRange("Ability", index.Index, array.Count));
|
||||
throw new OutOfRangeException("Ability", index.Index, array.Count);
|
||||
return array[index.Index];
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,14 @@ public record StatisticSet<T> : ImmutableStatisticSet<T>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper function to add two numerics together.
|
||||
/// </summary>
|
||||
protected T Add(T a, T b) => (T)Convert.ChangeType(Convert.ToInt32(a) + Convert.ToInt32(b), typeof(T));
|
||||
|
||||
/// <summary>
|
||||
/// Helper function to subtract two numerics.
|
||||
/// </summary>
|
||||
protected T Subtract(T a, T b) => (T)Convert.ChangeType(Convert.ToInt32(a) - Convert.ToInt32(b), typeof(T));
|
||||
|
||||
/// <summary>
|
||||
@@ -214,6 +221,7 @@ public abstract record ClampedStatisticSet<T> : StatisticSet<T>
|
||||
/// The minimum value for the statistics.
|
||||
/// </summary>
|
||||
protected abstract T Min { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum value for the statistics.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
using FluentResults;
|
||||
|
||||
namespace PkmnLib.Static.Utils.Errors;
|
||||
|
||||
/// <summary>
|
||||
/// A result that indicates an index is out of range.
|
||||
/// </summary>
|
||||
public class OutOfRange : Error
|
||||
public class OutOfRangeException : Exception
|
||||
{
|
||||
/// <inheritdoc cref="OutOfRange"/>
|
||||
public OutOfRange(string hint, int index, int max)
|
||||
/// <inheritdoc cref="OutOfRangeException"/>
|
||||
public OutOfRangeException(string hint, int index, int max)
|
||||
: base($"{hint} index {index} is out of range. Must be between 0 and {max - 1}.")
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user