namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Cheek Pouch is an ability that heals the user for 1/3 of its maximum HP after consuming a berry.
/// This effect applies to any berry item consumed by the Pokémon.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Cheek_Pouch_(Ability)">Bulbapedia - Cheek Pouch</see>
/// </summary>
[Script(ScriptCategory.Ability, "cheek_pouch")]
public class CheekPouch : Script, IScriptOnAfterItemConsume
{
    /// <inheritdoc />
    public void OnAfterItemConsume(IPokemon pokemon, IItem item)
    {
        if (item.Category == ItemCategory.Berry)
        {
            pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
            pokemon.Heal(pokemon.MaxHealth / 3);
        }
    }
}