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

64 lines
1.6 KiB
C#

using PkmnLib.Dynamic.ScriptHandling;
namespace PkmnLib.Dynamic.Models.Choices;
/// <summary>
/// A choice to switch to a different Pokémon.
/// </summary>
public interface ISwitchChoice : ITurnChoice
{
/// <summary>
/// The Pokémon to switch to.
/// </summary>
IPokemon SwitchTo { get; }
}
/// <inheritdoc cref="ISwitchChoice"/>
public class SwitchChoice : TurnChoice, ISwitchChoice
{
/// <inheritdoc cref="SwitchChoice"/>
public SwitchChoice(IPokemon user, IPokemon switchTo) : base(user)
{
SwitchTo = switchTo;
}
/// <inheritdoc />
public IPokemon SwitchTo { 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() =>
$"SwitchChoice: {User} -> {SwitchTo}";
protected bool Equals(SwitchChoice other) =>
other.User == User && other.SwitchTo == SwitchTo;
/// <inheritdoc />
public override bool Equals(object? obj)
{
if (obj is null)
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj is not SwitchChoice other)
return false;
return Equals(other);
}
/// <inheritdoc />
public override int GetHashCode() =>
User?.GetHashCode() ?? 0 ^ SwitchTo?.GetHashCode() ?? 0;
}