Add all missing docs
This commit is contained in:
@@ -106,11 +106,25 @@ public interface IItem : INamedValue
|
||||
/// </summary>
|
||||
ImmutableHashSet<StringKey> Flags { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The effect of the item when used outside of battle.
|
||||
/// </summary>
|
||||
ISecondaryEffect? Effect { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The effect of the item when used in battle.
|
||||
/// </summary>
|
||||
ISecondaryEffect? BattleEffect { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A set of arbitrary data that can be set on the item.
|
||||
/// </summary>
|
||||
IReadOnlyDictionary<StringKey, object?> AdditionalData { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get additional data from the item. If the data is not present, the value will be null.
|
||||
/// If the data is present, but cannot be converted to the requested type, the value will be null.
|
||||
/// </summary>
|
||||
bool TryGetAdditionalData<T>(StringKey key, out T? value);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -28,6 +28,9 @@ public interface IReadOnlyTypeLibrary
|
||||
/// </summary>
|
||||
float GetEffectiveness(TypeIdentifier attacking, IEnumerable<TypeIdentifier> defending);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the effectiveness for a single attacking type against all defending types.
|
||||
/// </summary>
|
||||
IEnumerable<(TypeIdentifier type, float effectiveness)> GetAllEffectivenessFromAttacking(TypeIdentifier attacking);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ public interface IAbility : INamedValue
|
||||
/// </summary>
|
||||
IReadOnlyDictionary<StringKey, object?> Parameters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the ability has a specific flag.
|
||||
/// </summary>
|
||||
bool HasFlag(StringKey key);
|
||||
}
|
||||
|
||||
@@ -44,6 +47,9 @@ public class AbilityImpl : IAbility
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyDictionary<StringKey, object?> Parameters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of arbitrary flags that can be used to mark the ability with specific properties.
|
||||
/// </summary>
|
||||
public ImmutableHashSet<StringKey> Flags;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -51,6 +51,7 @@ public record ImmutableStatisticSet<T> where T : struct
|
||||
Speed = speed;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ImmutableStatisticSet{T}"/>
|
||||
public ImmutableStatisticSet(ImmutableStatisticSet<T> set)
|
||||
{
|
||||
Hp = set.Hp;
|
||||
@@ -97,6 +98,7 @@ public record StatisticSet<T> : ImmutableStatisticSet<T>, IEnumerable<(Statistic
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="StatisticSet{T}"/>
|
||||
public StatisticSet(StatisticSet<T> set) : base(set)
|
||||
{
|
||||
}
|
||||
@@ -174,8 +176,16 @@ public record StatisticSet<T> : ImmutableStatisticSet<T>, IEnumerable<(Statistic
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a statistic that is not one of the standard statistics. This can be used for sets where there are
|
||||
/// additional statistics, such as evasion or accuracy.
|
||||
/// </summary>
|
||||
protected virtual T GetUnknownStat(Statistic stat) => throw new ArgumentException($"Invalid statistic {stat}");
|
||||
|
||||
/// <summary>
|
||||
/// Sets a statistic that is not one of the standard statistics. This can be used for sets where there are
|
||||
/// additional statistics, such as evasion or accuracy.
|
||||
/// </summary>
|
||||
protected virtual void SetUnknownStat(Statistic stat, T value)
|
||||
{
|
||||
throw new ArgumentException($"Invalid statistic {stat}");
|
||||
@@ -249,10 +259,14 @@ public abstract record ClampedStatisticSet<T> : StatisticSet<T> where T : struct
|
||||
Speed = Clamp(Speed, Min, Max);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ClampedStatisticSet{T}"/>
|
||||
protected ClampedStatisticSet(ClampedStatisticSet<T> set) : base(set)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clamps a value to be between the minimum and maximum values.
|
||||
/// </summary>
|
||||
protected static T Clamp(T value, T min, T max)
|
||||
{
|
||||
if (value.CompareTo(min) < 0)
|
||||
@@ -314,6 +328,9 @@ public record StatBoostStatisticSet : ClampedStatisticSet<sbyte>
|
||||
|
||||
private sbyte _evasion;
|
||||
|
||||
/// <summary>
|
||||
/// The evasion stat value.
|
||||
/// </summary>
|
||||
public sbyte Evasion
|
||||
{
|
||||
get => _evasion;
|
||||
@@ -322,6 +339,9 @@ public record StatBoostStatisticSet : ClampedStatisticSet<sbyte>
|
||||
|
||||
private sbyte _accuracy;
|
||||
|
||||
/// <summary>
|
||||
/// The accuracy stat value.
|
||||
/// </summary>
|
||||
public sbyte Accuracy
|
||||
{
|
||||
get => _accuracy;
|
||||
@@ -403,6 +423,7 @@ public record IndividualValueStatisticSet : ClampedStatisticSet<byte>
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IndividualValueStatisticSet"/>
|
||||
public IndividualValueStatisticSet(IndividualValueStatisticSet ivs) : base(ivs)
|
||||
{
|
||||
}
|
||||
@@ -430,6 +451,7 @@ public record EffortValueStatisticSet : ClampedStatisticSet<byte>
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EffortValueStatisticSet"/>
|
||||
public EffortValueStatisticSet(EffortValueStatisticSet evs) : base(evs)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
namespace PkmnLib.Static.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Helpers for working with dictionaries.
|
||||
/// </summary>
|
||||
public static class DictionaryHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the value for a key in a dictionary, or returns a default value if the key is not found.
|
||||
/// </summary>
|
||||
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key,
|
||||
TValue defaultValue)
|
||||
{
|
||||
if (dictionary.TryGetValue(key, out var value))
|
||||
return value;
|
||||
return defaultValue;
|
||||
}
|
||||
TValue defaultValue) =>
|
||||
dictionary.TryGetValue(key, out var value) ? value : defaultValue;
|
||||
}
|
||||
@@ -34,6 +34,9 @@ public static class EnumerableHelpers
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all elements from a list that match the given predicate.
|
||||
/// </summary>
|
||||
public static void RemoveAll<T>(this IList<T> list, Func<T, bool> predicate)
|
||||
{
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
|
||||
@@ -50,12 +50,18 @@ public static class NumericHelpers
|
||||
return result > short.MaxValue ? short.MaxValue : (short)result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two values. If this overflows, returns <see cref="uint.MaxValue"/>.
|
||||
/// </summary>
|
||||
public static uint MultiplyOrMax(this uint value, uint multiplier)
|
||||
{
|
||||
var result = (ulong)value * multiplier;
|
||||
return result > uint.MaxValue ? uint.MaxValue : (uint)result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two values. If this overflows, returns <see cref="uint.MaxValue"/>.
|
||||
/// </summary>
|
||||
public static uint MultiplyOrMax(this uint value, float multiplier)
|
||||
{
|
||||
var result = value * multiplier;
|
||||
|
||||
Reference in New Issue
Block a user