Deukhoofd 32aaa5150a
All checks were successful
Build / Build (push) Successful in 54s
Initial setup for testing AI performance, random fixes
2025-07-05 13:56:33 +02:00

86 lines
2.2 KiB
C#

using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Static;
namespace PkmnLib.Dynamic.Models.Choices;
/// <summary>
/// A choice to use an item
/// </summary>
public interface IItemChoice : ITurnChoice
{
/// <summary>
/// The item that is used.
/// </summary>
public IItem Item { get; }
/// <summary>
/// The side the move is targeted at.
/// </summary>
byte? TargetSide { get; }
/// <summary>
/// The position the move is targeted at.
/// </summary>
byte? TargetPosition { get; }
}
/// <inheritdoc cref="IItemChoice"/>
public class ItemChoice : TurnChoice, IItemChoice
{
/// <inheritdoc cref="ItemChoice"/>
public ItemChoice(IPokemon user, IItem item, byte? targetSide, byte? targetPosition) : base(user)
{
Item = item;
TargetSide = targetSide;
TargetPosition = targetPosition;
}
/// <summary>
/// The item that is used.
/// </summary>
public IItem Item { get; }
/// <inheritdoc />
public byte? TargetSide { get; }
/// <inheritdoc />
public byte? TargetPosition { get; }
/// <inheritdoc />
public override int ScriptCount => User.ScriptCount;
/// <inheritdoc />
public override void GetOwnScripts(List<IEnumerable<ScriptContainer>> scripts)
{
}
/// <inheritdoc />
public override void CollectScripts(List<IEnumerable<ScriptContainer>> scripts)
{
User.CollectScripts(scripts);
}
/// <inheritdoc />
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;
/// <inheritdoc />
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);
}
/// <inheritdoc />
public override int GetHashCode() =>
HashCode.Combine(User, Item, TargetSide, TargetPosition);
}