namespace PkmnLib.Plugin.Gen7.Scripts.Items.Pokeballs;

[ItemScript("love_ball")]
public class LoveBall : PokeballScript
{
    /// <inheritdoc />
    public LoveBall(IItem item) : base(item)
    {
    }

    /// <inheritdoc />
    public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
    {
        if (target.BattleData is null)
            return;
        var opponentSide = target.BattleData.SideIndex == 0 ? 1 : 0;
        var opponent = target.BattleData.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
        if (opponent is null)
            return;

        if (opponent.Species == target.Species && opponent.Gender != target.Gender)
        {
            catchRate = catchRate.MultiplyOrMax(8f);
        }
    }
}