2024-07-27 14:26:45 +00:00
|
|
|
using PkmnLib.Dynamic.ScriptHandling;
|
2024-12-29 12:51:59 +00:00
|
|
|
using PkmnLib.Static.Utils;
|
2024-07-27 14:26:45 +00:00
|
|
|
|
|
|
|
namespace PkmnLib.Dynamic.Models.Choices;
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A choice that is made at the beginning of a turn. This can be a switch, flee, item, or pass choice.
|
|
|
|
/// </summary>
|
2024-12-29 12:51:59 +00:00
|
|
|
public interface ITurnChoice : IScriptSource, IDeepCloneable
|
2024-07-27 14:26:45 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The user of the turn choice
|
|
|
|
/// </summary>
|
|
|
|
IPokemon User { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The speed of the user at the beginning of the turn.
|
|
|
|
/// </summary>
|
|
|
|
uint Speed { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// This random value is set at the beginning of the turn. It is used for tie breaking of the
|
|
|
|
/// turn order in a predictable way, regardless of implementation and hardware.
|
|
|
|
/// </summary>
|
|
|
|
uint RandomValue { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether the choice has failed. A failed choice will stop running, and execute special
|
|
|
|
/// fail handling during turn execution.
|
|
|
|
/// </summary>
|
|
|
|
bool HasFailed { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Fails the choice. This will prevent it from executing and run a specific fail handling during
|
|
|
|
/// execution. Note that this can not be undone.
|
|
|
|
/// </summary>
|
|
|
|
public void Fail();
|
|
|
|
}
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A basic implementation of a <see cref="ITurnChoice"/>.
|
|
|
|
/// </summary>
|
2024-07-27 14:26:45 +00:00
|
|
|
public abstract class TurnChoice : ScriptSource, ITurnChoice
|
|
|
|
{
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <inheritdoc cref="TurnChoice"/>
|
2024-07-27 14:26:45 +00:00
|
|
|
protected TurnChoice(IPokemon user)
|
|
|
|
{
|
|
|
|
User = user;
|
|
|
|
}
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The Pokemon for which the choice is made.
|
|
|
|
/// </summary>
|
2024-07-27 14:26:45 +00:00
|
|
|
public IPokemon User { get; }
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The speed of the user at the beginning of the turn.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// As a developer you do not need to set this value. It is set at the beginning of a turn automatically.
|
|
|
|
/// </remarks>
|
2024-07-27 14:26:45 +00:00
|
|
|
public uint Speed { get; set; }
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A random value that is set at the beginning of the turn. This is used for tie breaking of the turn order.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// As a developer you do not need to set this value. It is set at the beginning of a turn automatically.
|
|
|
|
/// </remarks>
|
2024-07-27 14:26:45 +00:00
|
|
|
public uint RandomValue { get; set; }
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether the choice has failed. A failed choice will stop running, and execute special fail handling
|
|
|
|
/// during turn execution.
|
|
|
|
/// </summary>
|
2024-07-27 14:26:45 +00:00
|
|
|
public bool HasFailed { get; private set; }
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Fail the choice. This will prevent it from executing and run a specific fail handling during execution.
|
|
|
|
/// </summary>
|
2024-07-27 14:26:45 +00:00
|
|
|
public void Fail()
|
|
|
|
{
|
|
|
|
HasFailed = true;
|
|
|
|
}
|
2024-07-28 10:52:17 +00:00
|
|
|
}
|