namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "floral_healing")]
public class FloralHealing : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        if (target.IsFainted)
            return;
        var battleData = target.BattleData;
        if (battleData == null)
            return;

        var modifier = 1f / 2;
        if (battleData.Battle.TerrainName == ScriptUtils.ResolveName<GrassyTerrain>())
            modifier = 2f / 3;

        var healing = target.BoostedStats.Hp * modifier;
        target.Heal((uint)healing);
    }
}