diff --git a/PkmnLib.Dynamic/Events/AbilityTriggerEvent.cs b/PkmnLib.Dynamic/Events/AbilityTriggerEvent.cs index 1d140d2..ddfee0a 100644 --- a/PkmnLib.Dynamic/Events/AbilityTriggerEvent.cs +++ b/PkmnLib.Dynamic/Events/AbilityTriggerEvent.cs @@ -1,14 +1,24 @@ using PkmnLib.Dynamic.Models; using PkmnLib.Static.Species; -using PkmnLib.Static.Utils; namespace PkmnLib.Dynamic.Events; +/// +/// AbilityTriggerEvent is triggered when a Pokémon's ability is activated. +/// public record AbilityTriggerEvent : IEventData { + /// + /// The Pokémon whose ability is being triggered. + /// public IPokemon Pokemon { get; } + + /// + /// The ability that is being triggered for the Pokémon. + /// public IAbility? Ability { get; } + /// public AbilityTriggerEvent(IPokemon pokemon) { Pokemon = pokemon; diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs index c2fb6ad..cf9afdd 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs @@ -20,5 +20,8 @@ public class SerializedAbility /// public string[] Flags { get; set; } = []; + /// + /// Indicates whether the ability can be changed by effects such as Skill Swap or Role Play. + /// public bool? CanBeChanged { get; set; } } \ No newline at end of file diff --git a/PkmnLib.Dynamic/Models/Pokemon.cs b/PkmnLib.Dynamic/Models/Pokemon.cs index 217cb4b..b7761a2 100644 --- a/PkmnLib.Dynamic/Models/Pokemon.cs +++ b/PkmnLib.Dynamic/Models/Pokemon.cs @@ -814,6 +814,10 @@ public class PokemonImpl : ScriptSource, IPokemon return true; } + /// + /// Uses an item on this Pokémon. + /// + /// public void UseItem(IItem item) { // TODO: actually consume the item @@ -851,6 +855,7 @@ public class PokemonImpl : ScriptSource, IPokemon } RecalculateBoostedStats(); + this.RunScriptHook(script => script.OnAfterStatBoostChange(this, stat, selfInflicted, change)); return true; } diff --git a/PkmnLib.Dynamic/ScriptHandling/Script.cs b/PkmnLib.Dynamic/ScriptHandling/Script.cs index e6ec591..511aaa4 100644 --- a/PkmnLib.Dynamic/ScriptHandling/Script.cs +++ b/PkmnLib.Dynamic/ScriptHandling/Script.cs @@ -418,6 +418,13 @@ public abstract class Script : IDeepCloneable { } + /// + /// This function allows a script to run after a stat boost change has been applied. + /// + public virtual void OnAfterStatBoostChange(IPokemon pokemon, Statistic stat, bool selfInflicted, sbyte change) + { + } + /// /// This function allows a script attached to a Pokemon or its parents to prevent an incoming /// secondary effect. This means the move will still hit and do damage, but not trigger its diff --git a/PkmnLib.Dynamic/ScriptHandling/ScriptExecution.cs b/PkmnLib.Dynamic/ScriptHandling/ScriptExecution.cs index 06154d8..f1e6430 100644 --- a/PkmnLib.Dynamic/ScriptHandling/ScriptExecution.cs +++ b/PkmnLib.Dynamic/ScriptHandling/ScriptExecution.cs @@ -37,6 +37,34 @@ public static class ScriptExecution } } + /// + /// Executes a hook on all scripts in a source. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void RunScriptHook(this IEnumerable sources, Action