using System.Collections.Immutable; using PkmnLib.Static.Utils; namespace PkmnLib.Static.Species; /// <summary> /// An ability is a passive effect in battle that is attached to a Pokémon. /// </summary> public interface IAbility : INamedValue { /// <summary> /// The name of the script effect of the ability. This should refer to the name of the script that will be executed /// when the ability is triggered. /// </summary> StringKey? Effect { get; } /// <summary> /// The parameters for the script effect of the ability. /// </summary> IReadOnlyDictionary<StringKey, object?> Parameters { get; } bool HasFlag(StringKey key); } /// <inheritdoc /> public class AbilityImpl : IAbility { /// <inheritdoc cref="AbilityImpl" /> public AbilityImpl(StringKey name, StringKey? effect, IReadOnlyDictionary<StringKey, object?> parameters, ImmutableHashSet<StringKey> flags) { Name = name; Effect = effect; Parameters = parameters; Flags = flags; } /// <inheritdoc /> public StringKey Name { get; } /// <inheritdoc /> public StringKey? Effect { get; } /// <inheritdoc /> public IReadOnlyDictionary<StringKey, object?> Parameters { get; } public ImmutableHashSet<StringKey> Flags; /// <inheritdoc /> public bool HasFlag(StringKey key) { return Flags.Contains(key); } } /// <summary> /// An ability index allows us to find an ability on a form. It combines a bool for whether the /// ability is hidden or not, and then an index of the ability. /// </summary> public readonly record struct AbilityIndex { /// <summary> /// Whether the ability we're referring to is a hidden ability. /// </summary> public required bool IsHidden { get; init; } /// <summary> /// The index of the ability. /// </summary> public required byte Index { get; init; } }