Files

48 lines
2.0 KiB
C#

namespace SOR.Game.Abilities.Models;
/// <summary>How long an applied effect persists.</summary>
public enum DurationType
{
/// <summary>One-time change; no ongoing tracking required.</summary>
Instant,
/// <summary>Expires at the end of the current active player's turn.</summary>
UntilEndOfTurn,
/// <summary>Expires at the start of the ability-owner's next turn.</summary>
UntilStartOfOwnerTurn,
/// <summary>Expires at the start of the source unit's owner's next turn.</summary>
UntilStartOfSourceOwnerTurn,
/// <summary>Expires after exactly N turns have elapsed.</summary>
ForNTurns,
/// <summary>Active while a condition evaluates to true; expires when it becomes false.</summary>
WhileCondition,
/// <summary>Active while the ability's source unit is on the battlefield; revoked on leave/death.</summary>
WhileSourceOnBattlefield,
/// <summary>Persists for the entire match; never expires.</summary>
PermanentInMatch,
}
/// <summary>
/// Duration descriptor attached to every Action in the ability model.
/// Governs how long the action's effects remain active.
/// </summary>
public sealed class DurationModel
{
public DurationType Type { get; set; } = DurationType.Instant;
/// <summary>Turn count for <see cref="DurationType.ForNTurns"/>.</summary>
public int? N { get; set; }
/// <summary>Condition evaluated each turn for <see cref="DurationType.WhileCondition"/>.</summary>
public Condition? Condition { get; set; }
/// <summary>
/// Optional ownership scope for timing anchors.
/// E.g., "Owner" scopes "UntilEndOfTurn" to the ability-owner's turn end specifically.
/// </summary>
public string? PlayerScope { get; set; }
public static DurationModel Instant => new() { Type = DurationType.Instant };
public static DurationModel Permanent => new() { Type = DurationType.PermanentInMatch };
public static DurationModel EndOfTurn => new() { Type = DurationType.UntilEndOfTurn };
}