Files
PkmnLib.NET/PkmnLib.Dynamic/Models/Choices/SwitchChoice.cs
Deukhoofd cc091d5327
Some checks failed
Build / Build (push) Failing after 35s
Update TUnit, warning cleanup
2026-07-05 13:46:57 +02:00

65 lines
1.7 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() =>
// ReSharper disable twice ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
User?.GetHashCode() ?? 0 ^ SwitchTo?.GetHashCode() ?? 0;
}