feat(phase7): complete ability revamp gap items 1-11
- Fix [PolyType] attribute placement bug in Effects.cs (silent poly-deser failure) - Add SpiritToken guard to BazaarBuyPrebuiltDeck and CollectionSelectStarterDeck handlers - Wire CostGroup payment into ActivateAbility with PendingCostGroupPick pause support - Add PendingActionGroupPick, PendingCostGroupPick, PendingBranchPick models + GameState props - Add Phase 5 engine switch cases: ModifyChannelRange, RelocateRuin, ActivateRuinAbility, DisableRuinForDuration, CloneSpiritAsToken, DestroyToken, SkipTurn, ModifyCardsDrawnThisTurn, StackDeck, SearchAndPlace, ChangeAttackType, ObstructMovement, AscendFromZone stubs - Add ActionGroup recursion (ResolveActionGroup AND-flatten / OR-XOR interactive pick) - Add ResumeActionGroupPick, ResumeCostGroupPick, ResumeBranchPick methods - Add ChooseOne ChooserRole branching + TargetSelector.Chooser (Random early-return) - Change SearchDeckEffect.ThenAction → ThenGroup: ActionGroup? - Change ApplyOnEventEffect.Effects → Actions: Action[] - Add SOR.Tools console project with cutover-abilities command (EffectsJsonCutover) - AbilityBuilder: add ActionGroupDraft, SubGroups, Compile Groups[], ParseJson Groups[], CompileActionNode/ParseActionNode helpers, nested sub-group UI section - Add Tile.RuinDisabledUntilTurn, PlayerState.SkipTurnCount/CardsDrawnThisTurnBonus, CardInstance.AttackType nullable override - Add SOR.Tools to solution Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -98,6 +98,29 @@ using SOR.Database.Enums;
|
||||
[PolyType(typeof(SummonTokenEffect), "SummonToken")]
|
||||
// §5.12 Deferred
|
||||
[PolyType(typeof(ApplyOnEventEffect), "ApplyOnEvent")]
|
||||
// §5.13 ArchSpirit zone operations
|
||||
[PolyType(typeof(AscendFromZoneEffect), "AscendFromZone")]
|
||||
[PolyType(typeof(TransitionFromZoneEffect), "TransitionFromZone")]
|
||||
[PolyType(typeof(ModifyChannelRangeEffect), "ModifyChannelRange")]
|
||||
// §5.14 Ruin manipulation
|
||||
[PolyType(typeof(RelocateRuinEffect), "RelocateRuin")]
|
||||
[PolyType(typeof(ActivateRuinAbilityEffect), "ActivateRuinAbility")]
|
||||
[PolyType(typeof(DisableRuinForDurationEffect), "DisableRuinForDuration")]
|
||||
// §5.15 Enhanced channeling
|
||||
[PolyType(typeof(ChannelCardFromZoneEffect), "ChannelCardFromZone")]
|
||||
// §5.16 Token / spirit operations
|
||||
[PolyType(typeof(CloneSpiritAsTokenEffect), "CloneSpiritAsToken")]
|
||||
[PolyType(typeof(DestroyTokenEffect), "DestroyToken")]
|
||||
[PolyType(typeof(ModifySacrificeTokenReturnEffect),"ModifySacrificeTokenReturn")]
|
||||
// §5.17 Player operations
|
||||
[PolyType(typeof(SkipTurnEffect), "SkipTurn")]
|
||||
[PolyType(typeof(ModifyCardsDrawnThisTurnEffect), "ModifyCardsDrawnThisTurn")]
|
||||
// §5.18 Zone operations
|
||||
[PolyType(typeof(StackDeckEffect), "StackDeck")]
|
||||
[PolyType(typeof(SearchAndPlaceEffect), "SearchAndPlace")]
|
||||
// §5.19 Unit manipulation
|
||||
[PolyType(typeof(ChangeAttackTypeEffect), "ChangeAttackType")]
|
||||
[PolyType(typeof(ObstructMovementTypeEffect), "ObstructMovementType")]
|
||||
public abstract class Effect { }
|
||||
|
||||
// ── §5.1 Stat modification ────────────────────────────────────────────────────
|
||||
@@ -190,10 +213,14 @@ public sealed class ReturnToBattlefieldEffect : Effect { public string? Controll
|
||||
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 Filter[]? Filters { get; set; }
|
||||
public int Count { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// Action group applied to each found card. The found card is pre-loaded as the resolved
|
||||
/// target so chained targeting within the group can reference it via "Action0.Target".
|
||||
/// Null means the card is moved to hand.
|
||||
/// </summary>
|
||||
public ActionGroup? ThenGroup { 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"; }
|
||||
@@ -281,45 +308,6 @@ public sealed class SummonTokenEffect : Effect
|
||||
|
||||
// ── §5.13 ArchSpirit zone operations ─────────────────────────────────────────
|
||||
|
||||
[PolyType(typeof(AscendFromZoneEffect), "AscendFromZone")]
|
||||
[PolyType(typeof(TransitionFromZoneEffect), "TransitionFromZone")]
|
||||
[PolyType(typeof(ModifyChannelRangeEffect), "ModifyChannelRange")]
|
||||
|
||||
// ── §5.14 Ruin manipulation ───────────────────────────────────────────────────
|
||||
|
||||
[PolyType(typeof(RelocateRuinEffect), "RelocateRuin")]
|
||||
[PolyType(typeof(ActivateRuinAbilityEffect), "ActivateRuinAbility")]
|
||||
[PolyType(typeof(DisableRuinForDurationEffect), "DisableRuinForDuration")]
|
||||
|
||||
// ── §5.15 Enhanced channeling ─────────────────────────────────────────────────
|
||||
|
||||
[PolyType(typeof(ChannelCardFromZoneEffect), "ChannelCardFromZone")]
|
||||
|
||||
// ── §5.16 Token / spirit operations ──────────────────────────────────────────
|
||||
|
||||
[PolyType(typeof(CloneSpiritAsTokenEffect), "CloneSpiritAsToken")]
|
||||
[PolyType(typeof(DestroyTokenEffect), "DestroyToken")]
|
||||
[PolyType(typeof(ModifySacrificeTokenReturnEffect),"ModifySacrificeTokenReturn")]
|
||||
|
||||
// ── §5.17 Player operations ───────────────────────────────────────────────────
|
||||
|
||||
[PolyType(typeof(SkipTurnEffect), "SkipTurn")]
|
||||
[PolyType(typeof(ModifyCardsDrawnThisTurnEffect), "ModifyCardsDrawnThisTurn")]
|
||||
|
||||
// ── §5.18 Zone operations ─────────────────────────────────────────────────────
|
||||
|
||||
[PolyType(typeof(StackDeckEffect), "StackDeck")]
|
||||
[PolyType(typeof(SearchAndPlaceEffect), "SearchAndPlace")]
|
||||
|
||||
// ── §5.19 Unit manipulation ───────────────────────────────────────────────────
|
||||
|
||||
[PolyType(typeof(ChangeAttackTypeEffect), "ChangeAttackType")]
|
||||
[PolyType(typeof(ObstructMovementTypeEffect), "ObstructMovementType")]
|
||||
|
||||
// ── §5.12 Deferred effects ────────────────────────────────────────────────────
|
||||
|
||||
// ── §5.13 ArchSpirit zone operations ──────────────────────────────────────────
|
||||
|
||||
/// <summary>Ascend the target ArchSpirit using a previous-tier card from the given zone.</summary>
|
||||
public sealed class AscendFromZoneEffect : Effect
|
||||
{
|
||||
@@ -476,5 +464,9 @@ public sealed class ObstructMovementTypeEffect : Effect
|
||||
public sealed class ApplyOnEventEffect : Effect
|
||||
{
|
||||
public TriggerEvent Trigger { get; set; } = null!;
|
||||
public Effect[] Effects { get; set; } = [];
|
||||
/// <summary>
|
||||
/// Full action tree executed when the trigger fires. Supports chained targeting and
|
||||
/// nested ActionGroups. Replaces the old flat Effect[] for recursive ability trees.
|
||||
/// </summary>
|
||||
public Action[] Actions { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace SOR.Game.Abilities.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Stored in GameState when an ActionGroup with OR/XOR logic requires a player to choose
|
||||
/// which child (leaf Action or nested ActionGroup) executes.
|
||||
///
|
||||
/// The game is paused until the chooser submits a <c>game.action_group_pick</c> response
|
||||
/// with a <see cref="ChoiceIndex"/> matching one of the available children.
|
||||
/// </summary>
|
||||
public sealed class PendingActionGroupPick
|
||||
{
|
||||
/// <summary>Correlation ID sent to the client so responses can be matched.</summary>
|
||||
public string RequestId { get; set; } = Guid.NewGuid().ToString("N");
|
||||
|
||||
/// <summary>AccountId of the player who activated the ability.</summary>
|
||||
public string ActorId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>AccountId of the player who must choose ("Self" = ActorId, "Opponent" = other player).</summary>
|
||||
public string ChooserActorId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>InstanceId of the source unit (may be empty for card-triggered abilities).</summary>
|
||||
public string SourceInstanceId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// JSON-serialized ActionGroup — the full group being picked from.
|
||||
/// Actions[0..n-1] are leaf actions; Groups[0..m-1] are nested groups.
|
||||
/// The combined pool is Actions then Groups (indices 0..n+m-1).
|
||||
/// </summary>
|
||||
public string ActionGroupJson { get; set; } = "{}";
|
||||
|
||||
/// <summary>JSON-serialized Action[] — the full action list to execute AFTER the picked branch finishes.</summary>
|
||||
public string ContinuationActionsJson { get; set; } = "[]";
|
||||
|
||||
/// <summary>JSON-serialized AbilityRange? — passed through to ExecuteActions on resume.</summary>
|
||||
public string? RangeJson { get; set; }
|
||||
|
||||
/// <summary>JSON-serialized DurationModel? — forceDuration passed to ExecuteActions on resume.</summary>
|
||||
public string? ForceDurationJson { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace SOR.Game.Abilities.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Stored in GameState when a ChooseOne action has ChooserRole="Opponent" (or "Ally") and
|
||||
/// requires the non-activating player to select a branch.
|
||||
///
|
||||
/// The game is paused until the chooser submits a <c>game.branch_pick</c> response
|
||||
/// with a <see cref="BranchIndex"/> in range.
|
||||
/// </summary>
|
||||
public sealed class PendingBranchPick
|
||||
{
|
||||
/// <summary>Correlation ID sent to the client so responses can be matched.</summary>
|
||||
public string RequestId { get; set; } = Guid.NewGuid().ToString("N");
|
||||
|
||||
/// <summary>AccountId of the player who activated the ability.</summary>
|
||||
public string ActorId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>AccountId of the player who must pick the branch.</summary>
|
||||
public string ChooserActorId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>InstanceId of the source unit (may be empty for card-triggered abilities).</summary>
|
||||
public string SourceInstanceId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Number of available branches.</summary>
|
||||
public int BranchCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// JSON-serialized Branch[] from the ChooseOne — passed to the client for display.
|
||||
/// The chooser picks an index 0..BranchCount-1.
|
||||
/// </summary>
|
||||
public string BranchesJson { get; set; } = "[]";
|
||||
|
||||
/// <summary>JSON-serialized Action[] — the remaining actions to execute AFTER the chosen branch.</summary>
|
||||
public string ContinuationActionsJson { get; set; } = "[]";
|
||||
|
||||
/// <summary>JSON-serialized AbilityRange? — passed through to ExecuteActions on resume.</summary>
|
||||
public string? RangeJson { get; set; }
|
||||
|
||||
/// <summary>JSON-serialized DurationModel? — forceDuration applied to all continuation actions.</summary>
|
||||
public string? ForceDurationJson { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace SOR.Game.Abilities.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Stored in GameState when a CostGroup with OR/XOR logic requires a player to choose
|
||||
/// which cost option (leaf CostEntry[] or nested CostGroup) to pay.
|
||||
///
|
||||
/// The game is paused until the chooser submits a <c>game.cost_group_pick</c> response
|
||||
/// with a <see cref="ChoiceIndex"/> matching one of the available options.
|
||||
/// </summary>
|
||||
public sealed class PendingCostGroupPick
|
||||
{
|
||||
/// <summary>Correlation ID sent to the client so responses can be matched.</summary>
|
||||
public string RequestId { get; set; } = Guid.NewGuid().ToString("N");
|
||||
|
||||
/// <summary>AccountId of the player who activated the ability.</summary>
|
||||
public string ActorId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>AccountId of the player who must choose (may differ from ActorId for Opponent chooser).</summary>
|
||||
public string ChooserActorId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>InstanceId of the source unit (may be empty for card-triggered abilities).</summary>
|
||||
public string SourceInstanceId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>0-based ability index on the source unit.</summary>
|
||||
public int AbilityIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// JSON-serialized CostGroup — the full group being picked from.
|
||||
/// Entries[0..n-1] are leaf cost entries (each a CostEntry[]);
|
||||
/// Groups[0..m-1] are nested groups.
|
||||
/// Combined pool indices: 0..n-1 = entries, n..n+m-1 = nested groups.
|
||||
/// </summary>
|
||||
public string CostGroupJson { get; set; } = "{}";
|
||||
|
||||
/// <summary>JSON-serialized Action[] — the full action list to execute after all costs are paid.</summary>
|
||||
public string ActionsJson { get; set; } = "[]";
|
||||
|
||||
/// <summary>JSON-serialized AbilityRange? — passed through to ExecuteActions on resume.</summary>
|
||||
public string? RangeJson { get; set; }
|
||||
|
||||
/// <summary>JSON-serialized DurationModel? — forceDuration passed to ExecuteActions on resume.</summary>
|
||||
public string? ForceDurationJson { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user