From bc65e8b9d43b3b5246fa79887d5d7e63543bfc2b Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 8 Mar 2026 17:47:59 -0400 Subject: [PATCH] Fix: add ExactSelf to TargetOwnership enum + resolve in AbilitySystem `ExactSelf` was accepted by the admin builder dropdown but crashed on deserialization because the TargetOwnership enum was missing the value. - Added `ExactSelf` to `TargetOwnership` enum in Action.cs - BuildCandidates treats ExactSelf like Self/Owner (actor's player pool) - ResolveTargets post-filters to ctx.Source.InstanceId when ExactSelf Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Server/src/SOR.Game/Abilities/AbilitySystem.cs | 6 +++++- Server/src/SOR.Game/Abilities/Models/Action.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Server/src/SOR.Game/Abilities/AbilitySystem.cs b/Server/src/SOR.Game/Abilities/AbilitySystem.cs index 10401c2..93f987d 100644 --- a/Server/src/SOR.Game/Abilities/AbilitySystem.cs +++ b/Server/src/SOR.Game/Abilities/AbilitySystem.cs @@ -407,6 +407,10 @@ public static class AbilitySystem var candidates = BuildCandidates(selector, state, ctx.ActorId); + // ExactSelf: narrow to the exact unit instance that owns this ability. + if (selector.Ownership == TargetOwnership.ExactSelf && ctx.Source is not null) + candidates = candidates.Where(c => c.InstanceId == ctx.Source.InstanceId).ToList(); + if (selector.Filters is { Length: > 0 }) candidates = candidates.Where(c => FiltersMatch(selector.Filters, c, ctx)).ToList(); @@ -442,7 +446,7 @@ public static class AbilitySystem IEnumerable ownerIds = selector.Ownership switch { - TargetOwnership.Owner or TargetOwnership.Self => [actorId], + TargetOwnership.Owner or TargetOwnership.Self or TargetOwnership.ExactSelf => [actorId], TargetOwnership.Enemy => state.Players.Keys.Where(k => k != actorId), TargetOwnership.Ally => state.Players.Keys.Where(k => k != actorId), _ => state.Players.Keys, diff --git a/Server/src/SOR.Game/Abilities/Models/Action.cs b/Server/src/SOR.Game/Abilities/Models/Action.cs index 311e541..7d0a2eb 100644 --- a/Server/src/SOR.Game/Abilities/Models/Action.cs +++ b/Server/src/SOR.Game/Abilities/Models/Action.cs @@ -32,7 +32,7 @@ public sealed class AffinityExpr public enum TargetScope { Hand, Deck, Discard, Battlefield, Player, AnyZone } public enum TargetType { Unit, ArchSpirit, Spirit, SpiritToken, Ruin, Tile, Card, Player } -public enum TargetOwnership { Self, Owner, Ally, Enemy, Any, Random, Target } +public enum TargetOwnership { Self, ExactSelf, Owner, Ally, Enemy, Any, Random, Target } public sealed class TargetCount {