253 lines
17 KiB
C#
253 lines
17 KiB
C#
namespace SOR.Game.Abilities.Models;
|
|
|
|
using System.Text.Json.Serialization;
|
|
using SOR.Database.Enums;
|
|
|
|
// ── Effect base ───────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// The atomic unit of game-state mutation delivered to a resolved target.
|
|
/// All effects share a DurationModel (from their containing Action).
|
|
/// </summary>
|
|
// §5.1 Stat modification
|
|
[PolyType(typeof(ModifyHealthEffect), "ModifyHealth")]
|
|
[PolyType(typeof(ModifyDefenseEffect), "ModifyDefense")]
|
|
[PolyType(typeof(ModifyDamageEffect), "ModifyDamage")]
|
|
[PolyType(typeof(ModifyMPEffect), "ModifyMP")]
|
|
[PolyType(typeof(SetMovementTypeEffect), "SetMovementType")]
|
|
[PolyType(typeof(SetAttackRangeEffect), "SetAttackRange")]
|
|
[PolyType(typeof(ModifyMinAttackRangeEffect), "ModifyMinAttackRange")]
|
|
[PolyType(typeof(ModifyMaxAttackRangeEffect), "ModifyMaxAttackRange")]
|
|
[PolyType(typeof(ModifyCostEffect), "ModifyCost")]
|
|
[PolyType(typeof(SetAffinityEffect), "SetAffinity")]
|
|
[PolyType(typeof(GrantAdditionalAttackEffect), "GrantAdditionalAttack")]
|
|
[PolyType(typeof(SetStatModMultiplierEffect), "SetStatModMultiplier")]
|
|
// §5.2 Flag modification — unit
|
|
[PolyType(typeof(SetCanMoveEffect), "SetCanMove")]
|
|
[PolyType(typeof(SetCanAttackEffect), "SetCanAttack")]
|
|
[PolyType(typeof(SetCanDefendEffect), "SetCanDefend")]
|
|
[PolyType(typeof(SetCanBeAttackedEffect), "SetCanBeAttacked")]
|
|
[PolyType(typeof(SetCanBeBlockedEffect), "SetCanBeBlocked")]
|
|
[PolyType(typeof(SetCanBeObstructedEffect), "SetCanBeObstructed")]
|
|
[PolyType(typeof(SetCanUseAbilityEffect), "SetCanUseAbility")]
|
|
[PolyType(typeof(SetCanBeSacrificedEffect), "SetCanBeSacrificed")]
|
|
// §5.2 Flag modification — player
|
|
[PolyType(typeof(SetCanDrawCardsEffect), "SetCanDrawCards")]
|
|
[PolyType(typeof(SetAccumulatesSPEffect), "SetAccumulatesSP")]
|
|
[PolyType(typeof(SetCanChannelSpiritEffect), "SetCanChannelSpirit")]
|
|
[PolyType(typeof(SetCanSacrificeSpiritEffect), "SetCanSacrificeSpirit")]
|
|
[PolyType(typeof(SetCanAscendArchSpiritEffect), "SetCanAscendArchSpirit")]
|
|
[PolyType(typeof(SetCanTransitionArchSpiritEffect), "SetCanTransitionArchSpirit")]
|
|
[PolyType(typeof(SetCanChannelRepentanceEffect), "SetCanChannelRepentance")]
|
|
[PolyType(typeof(SetCanChannelInstinctEffect), "SetCanChannelInstinct")]
|
|
[PolyType(typeof(SetCanChannelRuinEffect), "SetCanChannelRuin")]
|
|
[PolyType(typeof(SetCanChannelTerramorphaMonoEffect), "SetCanChannelTerramorphaMono")]
|
|
[PolyType(typeof(SetCanChannelTerramorphaDiEffect), "SetCanChannelTerramorphaDi")]
|
|
[PolyType(typeof(SetCanChannelTerramorphaTriEffect), "SetCanChannelTerramorphaTri")]
|
|
// §5.3 Ability modification
|
|
[PolyType(typeof(AddAbilityEffect), "AddAbility")]
|
|
[PolyType(typeof(RemoveAbilityEffect), "RemoveAbility")]
|
|
[PolyType(typeof(EnableAbilityEffect), "EnableAbility")]
|
|
[PolyType(typeof(DisableAbilityEffect),"DisableAbility")]
|
|
// §5.4 Genus modification
|
|
[PolyType(typeof(AddGenusEffect), "AddGenus")]
|
|
[PolyType(typeof(RemoveGenusEffect), "RemoveGenus")]
|
|
// §5.5 Player resource modification
|
|
[PolyType(typeof(ModifySPEffect), "ModifySP")]
|
|
[PolyType(typeof(ModifySPAccumulationEffect), "ModifySPAccumulation")]
|
|
[PolyType(typeof(ModifySTEffect), "ModifyST")]
|
|
[PolyType(typeof(ModifyCardsDrawnPerTurnEffect), "ModifyCardsDrawnPerTurn")]
|
|
// §5.6 Tile modification
|
|
[PolyType(typeof(SetBaseAffinity1Effect), "SetBaseAffinity1")]
|
|
[PolyType(typeof(SetBaseAffinity2Effect), "SetBaseAffinity2")]
|
|
[PolyType(typeof(PushAffinityEffect), "PushAffinity")]
|
|
[PolyType(typeof(PushFinalAffinityEffect), "PushFinalAffinity")]
|
|
// §5.7 Zone / card operations
|
|
[PolyType(typeof(DrawCardsEffect), "DrawCards")]
|
|
[PolyType(typeof(DiscardCardsEffect), "DiscardCards")]
|
|
[PolyType(typeof(ReturnToHandEffect), "ReturnToHand")]
|
|
[PolyType(typeof(ReturnToDeckEffect), "ReturnToDeck")]
|
|
[PolyType(typeof(ReturnToBattlefieldEffect), "ReturnToBattlefield")]
|
|
[PolyType(typeof(SendToDiscardEffect), "SendToDiscard")]
|
|
[PolyType(typeof(SearchDeckEffect), "SearchDeck")]
|
|
[PolyType(typeof(ShuffleDeckEffect), "ShuffleDeck")]
|
|
[PolyType(typeof(RevealCardsEffect), "RevealCards")]
|
|
[PolyType(typeof(PlaceOnDeckEffect), "PlaceOnDeck")]
|
|
[PolyType(typeof(ChannelCardEffect), "ChannelCard")]
|
|
// §5.8 Combat / damage
|
|
[PolyType(typeof(DealDamageEffect), "DealDamage")]
|
|
[PolyType(typeof(HealEffect), "Heal")]
|
|
[PolyType(typeof(DealDamageToSelfEffect), "DealDamageToSelf")]
|
|
[PolyType(typeof(DOTEffect), "DOT")]
|
|
[PolyType(typeof(HOTEffect), "HOT")]
|
|
// §5.9 Displacement
|
|
[PolyType(typeof(PushUnitEffect), "PushUnit")]
|
|
[PolyType(typeof(PullUnitEffect), "PullUnit")]
|
|
[PolyType(typeof(DisplaceUnitEffect), "DisplaceUnit")]
|
|
// §5.10 Control
|
|
[PolyType(typeof(TakeControlEffect), "TakeControl")]
|
|
[PolyType(typeof(GrantMovementControlEffect), "GrantMovementControl")]
|
|
[PolyType(typeof(SetFixedSacrificeReturnEffect),"SetFixedSacrificeReturn")]
|
|
// §5.11 Token
|
|
[PolyType(typeof(SummonTokenEffect), "SummonToken")]
|
|
// §5.12 Deferred
|
|
[PolyType(typeof(ApplyOnEventEffect), "ApplyOnEvent")]
|
|
public abstract class Effect { }
|
|
|
|
// ── §5.1 Stat modification ────────────────────────────────────────────────────
|
|
|
|
public enum StatTarget { Current, Max }
|
|
|
|
public sealed class ModifyHealthEffect : Effect { public ValueExpr Amount { get; set; } = new(); public StatTarget StatTarget { get; set; } = StatTarget.Current; }
|
|
public sealed class ModifyDefenseEffect : Effect { public ValueExpr Amount { get; set; } = new(); public StatTarget StatTarget { get; set; } = StatTarget.Current; }
|
|
public sealed class ModifyDamageEffect : Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
public sealed class ModifyMPEffect : Effect { public ValueExpr Amount { get; set; } = new(); public StatTarget StatTarget { get; set; } = StatTarget.Current; }
|
|
|
|
public sealed class SetMovementTypeEffect : Effect { public MovementType MovementType { get; set; } }
|
|
public sealed class SetAttackRangeEffect : Effect { public int Min { get; set; } public int Max { get; set; } }
|
|
public sealed class ModifyMinAttackRangeEffect : Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
public sealed class ModifyMaxAttackRangeEffect : Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
public sealed class ModifyCostEffect : Effect { public int? Sp { get; set; } public int? St { get; set; } }
|
|
public sealed class SetAffinityEffect : Effect { public AffinityExpr Affinity { get; set; } = new(); }
|
|
public sealed class GrantAdditionalAttackEffect : Effect { public int N { get; set; } = 1; }
|
|
public sealed class SetStatModMultiplierEffect : Effect { public string Stat { get; set; } = string.Empty; public double Multiplier { get; set; } = 1.0; }
|
|
|
|
// ── §5.2 Flag modification — unit ─────────────────────────────────────────────
|
|
|
|
public sealed class SetCanMoveEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanAttackEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanDefendEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanBeAttackedEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanBeBlockedEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanBeObstructedEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanUseAbilityEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanBeSacrificedEffect : Effect { public bool Value { get; set; } }
|
|
|
|
// ── §5.2 Flag modification — player ───────────────────────────────────────────
|
|
|
|
public sealed class SetCanDrawCardsEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetAccumulatesSPEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanChannelSpiritEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanSacrificeSpiritEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanAscendArchSpiritEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanTransitionArchSpiritEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanChannelRepentanceEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanChannelInstinctEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanChannelRuinEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanChannelTerramorphaMonoEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanChannelTerramorphaDiEffect : Effect { public bool Value { get; set; } }
|
|
public sealed class SetCanChannelTerramorphaTriEffect : Effect { public bool Value { get; set; } }
|
|
|
|
// ── §5.3 Ability modification ─────────────────────────────────────────────────
|
|
|
|
public sealed class AddAbilityEffect : Effect { public AbilityDefinition AbilityDef { get; set; } = new(); }
|
|
/// <summary>AbilityRef is the ability name (matches AbilityDefinition.Name).</summary>
|
|
public sealed class RemoveAbilityEffect : Effect { public string AbilityRef { get; set; } = string.Empty; }
|
|
public sealed class EnableAbilityEffect : Effect { public string AbilityRef { get; set; } = string.Empty; }
|
|
public sealed class DisableAbilityEffect: Effect { public string AbilityRef { get; set; } = string.Empty; }
|
|
|
|
// ── §5.4 Genus modification ───────────────────────────────────────────────────
|
|
|
|
public sealed class AddGenusEffect : Effect { public string Tag { get; set; } = string.Empty; }
|
|
public sealed class RemoveGenusEffect : Effect { public string Tag { get; set; } = string.Empty; }
|
|
|
|
// ── §5.5 Player resource modification ─────────────────────────────────────────
|
|
|
|
public sealed class ModifySPEffect : Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
public sealed class ModifySPAccumulationEffect : Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
public sealed class ModifySTEffect : Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
public sealed class ModifyCardsDrawnPerTurnEffect: Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
|
|
// ── §5.6 Tile modification ────────────────────────────────────────────────────
|
|
|
|
public sealed class SetBaseAffinity1Effect : Effect { public AffinityExpr Affinity { get; set; } = new(); }
|
|
public sealed class SetBaseAffinity2Effect : Effect { public AffinityExpr Affinity { get; set; } = new(); }
|
|
public sealed class PushAffinityEffect : Effect { public AffinityExpr Affinity { get; set; } = new(); }
|
|
public sealed class PushFinalAffinityEffect : Effect { public AffinityExpr Affinity { get; set; } = new(); }
|
|
|
|
// ── §5.7 Zone / card operations ───────────────────────────────────────────────
|
|
|
|
public sealed class DrawCardsEffect : Effect { public int N { get; set; } = 1; public string Player { get; set; } = "Owner"; }
|
|
public sealed class DiscardCardsEffect : Effect { public int N { get; set; } = 1; public string Player { get; set; } = "Owner"; public Filter[]? Filters { get; set; } }
|
|
public sealed class ReturnToHandEffect : Effect { } // target is the card (from action target)
|
|
public sealed class ReturnToDeckEffect : Effect { public string Position { get; set; } = "top"; } // top | bottom | random
|
|
public sealed class ReturnToBattlefieldEffect : Effect { public string? Controller { get; set; } public Filter[]? TileFilter { get; set; } }
|
|
public sealed class SendToDiscardEffect: Effect { }
|
|
public sealed class SearchDeckEffect : Effect
|
|
{
|
|
public Filter[]? Filters { get; set; }
|
|
public int Count { get; set; } = 1;
|
|
/// <summary>Action applied to each found card (SearchResult references current card).</summary>
|
|
public Action? ThenAction { get; set; }
|
|
}
|
|
public sealed class ShuffleDeckEffect : Effect { public string Player { get; set; } = "Owner"; }
|
|
public sealed class RevealCardsEffect : Effect { public int N { get; set; } = 1; public string ToOwnership { get; set; } = "Any"; }
|
|
public sealed class PlaceOnDeckEffect : Effect { public string Position { get; set; } = "top"; }
|
|
public sealed class ChannelCardEffect : Effect
|
|
{
|
|
public bool PayCost { get; set; } = true;
|
|
public double? CostMultiplier { get; set; }
|
|
}
|
|
|
|
// ── §5.8 Combat / damage ──────────────────────────────────────────────────────
|
|
|
|
public sealed class DealDamageEffect : Effect { public ValueExpr Amount { get; set; } = new(); public bool BypassDefense { get; set; } }
|
|
public sealed class HealEffect : Effect { public ValueExpr Amount { get; set; } = new(); }
|
|
public sealed class DealDamageToSelfEffect : Effect { public ValueExpr Amount { get; set; } = new(); public bool BypassDefense { get; set; } }
|
|
public sealed class DOTEffect : Effect { public ValueExpr Amount { get; set; } = new(); public DurationModel Duration { get; set; } = DurationModel.EndOfTurn; public bool BypassDefense { get; set; } }
|
|
public sealed class HOTEffect : Effect { public ValueExpr Amount { get; set; } = new(); public DurationModel Duration { get; set; } = DurationModel.EndOfTurn; }
|
|
|
|
// ── §5.9 Displacement ─────────────────────────────────────────────────────────
|
|
|
|
public sealed class PushUnitEffect : Effect
|
|
{
|
|
public int Tiles { get; set; } = 1;
|
|
/// <summary>
|
|
/// Direct HP damage dealt to the pushed unit if it cannot complete the full push
|
|
/// (blocked by a boundary or another unit). 0 = no knockback damage.
|
|
/// </summary>
|
|
public int BlockedDamage { get; set; } = 0;
|
|
}
|
|
|
|
public sealed class PullUnitEffect : Effect
|
|
{
|
|
public int Tiles { get; set; } = 1;
|
|
/// <summary>
|
|
/// Direct HP damage dealt to the pulled unit if it cannot complete the full pull
|
|
/// (blocked by a boundary or another unit). 0 = no knockback damage.
|
|
/// </summary>
|
|
public int BlockedDamage { get; set; } = 0;
|
|
}
|
|
public sealed class DisplaceUnitEffect : Effect { public int Tiles { get; set; } = 1; public string Direction { get; set; } = "North"; }
|
|
|
|
// ── §5.10 Control effects ─────────────────────────────────────────────────────
|
|
|
|
public sealed class TakeControlEffect : Effect { public DurationModel Duration { get; set; } = DurationModel.EndOfTurn; }
|
|
public sealed class GrantMovementControlEffect : Effect { public int N { get; set; } = 1; }
|
|
/// <summary>Overrides the sacrifice formula: controller receives exactly StAmount ST instead.</summary>
|
|
public sealed class SetFixedSacrificeReturnEffect : Effect { public int StAmount { get; set; } }
|
|
|
|
// ── §5.11 Token summoning ─────────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Summons a SpiritToken onto a player-selected tile meeting the filter.
|
|
/// TokenDefJson is a JSONB blob matching a mini-CardDefinition for the token.
|
|
/// </summary>
|
|
public sealed class SummonTokenEffect : Effect
|
|
{
|
|
public string TokenDefJson { get; set; } = "{}";
|
|
public Filter[]? TileFilter { get; set; }
|
|
}
|
|
|
|
// ── §5.12 Deferred effects ────────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Schedules effects to fire once the next time the specified trigger event occurs.
|
|
/// Consumed after firing. Cancelled if source leaves battlefield before event fires.
|
|
/// </summary>
|
|
public sealed class ApplyOnEventEffect : Effect
|
|
{
|
|
public TriggerEvent Trigger { get; set; } = null!;
|
|
public Effect[] Effects { get; set; } = [];
|
|
}
|