using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Static;
namespace PkmnLib.Dynamic.Models.Choices;
///
/// A choice to use an item
///
public interface IItemChoice : ITurnChoice
{
///
/// The item that is used.
///
public IItem Item { get; }
///
/// The side the move is targeted at.
///
byte? TargetSide { get; }
///
/// The position the move is targeted at.
///
byte? TargetPosition { get; }
}
///
public class ItemChoice : TurnChoice, IItemChoice
{
///
public ItemChoice(IPokemon user, IItem item, byte? targetSide, byte? targetPosition) : base(user)
{
Item = item;
TargetSide = targetSide;
TargetPosition = targetPosition;
}
///
/// The item that is used.
///
public IItem Item { get; }
///
public byte? TargetSide { get; }
///
public byte? TargetPosition { get; }
///
public override int ScriptCount => User.ScriptCount;
///
public override void GetOwnScripts(List> scripts)
{
}
///
public override void CollectScripts(List> scripts)
{
User.CollectScripts(scripts);
}
///
public override string ToString() =>
$"ItemChoice: User: {User}, Item: {Item.Name}, TargetSide: {TargetSide}, TargetPosition: {TargetPosition}";
protected bool Equals(ItemChoice other) =>
other.User == User && other.Item.Equals(Item) && other.TargetSide == TargetSide &&
other.TargetPosition == TargetPosition;
///
public override bool Equals(object? obj)
{
if (obj is null)
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj is not ItemChoice other)
return false;
return Equals(other);
}
///
public override int GetHashCode() =>
HashCode.Combine(User, Item, TargetSide, TargetPosition);
}