137 lines
5.5 KiB
C#
137 lines
5.5 KiB
C#
namespace SOR.Game.Abilities.Models;
|
|
|
|
// ── Value expression ──────────────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// An integer value that may be a fixed constant or a dynamic runtime reference.
|
|
/// Dynamic references (§4.5) use dot-path notation, e.g.:
|
|
/// "EventData.Amount", "Self.Damage", "Action1.Target.Defense"
|
|
/// </summary>
|
|
public sealed class ValueExpr
|
|
{
|
|
public int? Fixed { get; set; }
|
|
public string? Ref { get; set; }
|
|
|
|
[System.Text.Json.Serialization.JsonIgnore]
|
|
public bool IsDynamic => Ref is not null;
|
|
|
|
public static implicit operator ValueExpr(int n) => new() { Fixed = n };
|
|
}
|
|
|
|
/// <summary>
|
|
/// An affinity value that may be fixed or a dynamic reference.
|
|
/// E.g.: "Self.Affinity", "Action1.Target.Affinity".
|
|
/// </summary>
|
|
public sealed class AffinityExpr
|
|
{
|
|
public SOR.Database.Enums.Affinity? Fixed { get; set; }
|
|
public string? Ref { get; set; }
|
|
}
|
|
|
|
// ── Target selector ───────────────────────────────────────────────────────────
|
|
|
|
public enum TargetScope { Hand, Deck, Discard, Battlefield, Player, AnyZone }
|
|
public enum TargetType { Unit, ArchSpirit, Spirit, SpiritToken, Ruin, Tile, Card, Player }
|
|
public enum TargetOwnership { Self, ExactSelf, Owner, Ally, Enemy, Any, Random, Target }
|
|
|
|
public sealed class TargetCount
|
|
{
|
|
/// <summary>Exact number of targets; or the maximum when UpTo=true.</summary>
|
|
public int N { get; set; } = 1;
|
|
/// <summary>Player may select fewer than N valid targets.</summary>
|
|
public bool UpTo { get; set; }
|
|
/// <summary>Target all valid entities (N is ignored).</summary>
|
|
public bool All { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Defines how targets are resolved for a single Action.
|
|
/// Scope + Type + Ownership narrow the pool; Filters refine further.
|
|
/// </summary>
|
|
public sealed class TargetSelector
|
|
{
|
|
public TargetScope Scope { get; set; }
|
|
public TargetType Type { get; set; }
|
|
public TargetOwnership Ownership { get; set; }
|
|
public TargetCount Count { get; set; } = new();
|
|
public Filter[]? Filters { get; set; }
|
|
}
|
|
|
|
// ── Action ────────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// The atomic unit of targeting and effect delivery within an ability.
|
|
/// All effects within one action share the same target and duration.
|
|
/// Actions within an ability resolve sequentially; a prior action's resolved
|
|
/// target is accessible in subsequent actions via chained targeting filters.
|
|
/// </summary>
|
|
public sealed class Action
|
|
{
|
|
public TargetSelector Target { get; set; } = new();
|
|
public Condition[]? Conditions { get; set; }
|
|
public Effect[] Effects { get; set; } = [];
|
|
public DurationModel? Duration { get; set; }
|
|
}
|
|
|
|
// ── ChooseOne ─────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Presents the controlling player with a set of mutually exclusive action branches.
|
|
/// Exactly one branch is selected and its actions resolve; other branches are skipped.
|
|
/// ChooseOne may appear anywhere an Action[] is accepted.
|
|
/// </summary>
|
|
public sealed class ChooseOne
|
|
{
|
|
public Branch[] Branches { get; set; } = [];
|
|
}
|
|
|
|
public sealed class Branch
|
|
{
|
|
public string Label { get; set; } = string.Empty;
|
|
public Action[] Actions { get; set; } = [];
|
|
}
|
|
|
|
// ── Cost entry ────────────────────────────────────────────────────────────────
|
|
|
|
public enum CostType
|
|
{
|
|
SpiritPoints,
|
|
SacrificeTokens,
|
|
DiscardFromHand,
|
|
MillTopOfDeck,
|
|
MillBottomOfDeck,
|
|
SendSpiritFromBattlefieldToDiscard,
|
|
DealDamageToOwnArchSpirit,
|
|
DealDamageToOwnSpirit,
|
|
}
|
|
|
|
/// <summary>
|
|
/// A single cost element for an Active ability.
|
|
/// Multiple CostEntry items must all be paid simultaneously before the ability resolves.
|
|
/// </summary>
|
|
public sealed class CostEntry
|
|
{
|
|
public CostType Type { get; set; }
|
|
public int Amount { get; set; } = 1;
|
|
/// <summary>Optional filter for targeted costs (e.g. "Discard a Spirit card from hand").</summary>
|
|
public Filter[]? Filters { get; set; }
|
|
}
|
|
|
|
// ── Ability range ─────────────────────────────────────────────────────────────
|
|
|
|
public sealed class AbilityRange
|
|
{
|
|
public int Min { get; set; } = 1;
|
|
public int Max { get; set; } = 1;
|
|
/// <summary>
|
|
/// When true, the engine validates that a clear line of sight exists between the
|
|
/// caster and the target tile/unit before allowing the ability to be used.
|
|
/// </summary>
|
|
public bool RequiresLos { get; set; } = false;
|
|
/// <summary>
|
|
/// When true, only targets that lie on a straight cardinal or diagonal line from
|
|
/// the caster are valid (e.g. Push, Pull, beam-style abilities).
|
|
/// </summary>
|
|
public bool LinearOnly { get; set; } = false;
|
|
}
|