Fix: admin ability builder — ExactSelf ownership + target filter dropdown

TargetOwnerships: add "ExactSelf" so action target selectors can restrict to
the specific unit instance that owns the ability (rather than any allied unit).

Target Filter dropdown (new): exposes the TargetSelector.Filters[] field that
previously had no UI. Supports no-param filter types:
  • (none)
  • IsSelf            — any unit with the same card definition
  • IsExactSelf       — only this specific instance (InstanceId match)
  • IsAdjacentToSource

Filter compiles to Target.Filters[0] in the JSON and round-trips correctly
when loading existing ability JSON back into the builder.

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:
dingo
2026-03-08 17:05:46 -04:00
co-authored by Claude Happy
parent 11ebdc40d7
commit 3c16fcfce5
@@ -257,6 +257,18 @@
</div>
</div>
</div>
<!-- Target filter (optional, single filter, no-param types) -->
<div class="row g-2 mb-2 align-items-end">
<div class="col-md-4">
<label class="form-label small mb-0">Target Filter <span class="text-muted">(optional)</span></label>
<select class="form-select form-select-sm" @bind="action.FilterType" @bind:after="Compile">
<option value="">(none)</option>
<option value="IsSelf">IsSelf — same card definition</option>
<option value="IsExactSelf">IsExactSelf — same instance only</option>
<option value="IsAdjacentToSource">IsAdjacentToSource</option>
</select>
</div>
</div>
<!-- Effects -->
<label class="form-label small fw-medium mb-1">Effects</label>
@@ -409,7 +421,7 @@
private static readonly string[] AbilityTypes = ["Active", "Passive", "Aura", "Triggered"];
private static readonly string[] TargetScopes = ["Hand", "Deck", "Discard", "Battlefield", "Player", "AnyZone"];
private static readonly string[] TargetTypes = ["Unit", "ArchSpirit", "Spirit", "SpiritToken", "Ruin", "Tile", "Card", "Player"];
private static readonly string[] TargetOwnerships= ["Self", "Owner", "Ally", "Enemy", "Any", "Random", "Target"];
private static readonly string[] TargetOwnerships= ["Self", "ExactSelf", "Owner", "Ally", "Enemy", "Any", "Random", "Target"];
private static readonly string[] AffinityValues = [
"Void", "Aether", "Lake", "Hill", "Forest", "Field",
@@ -612,7 +624,8 @@
if (node["Actions"] is JsonArray actions)
foreach (var actionNode in actions.OfType<JsonObject>())
{
var target = actionNode["Target"] as JsonObject;
var target = actionNode["Target"] as JsonObject;
var firstFilter= (target?["Filters"] as JsonArray)?.OfType<JsonObject>().FirstOrDefault();
var act = new ActionDraft
{
Scope = target?["Scope"]?.GetValue<string>() ?? "Battlefield",
@@ -620,6 +633,7 @@
Ownership = target?["Ownership"]?.GetValue<string>() ?? "Enemy",
Count = target?["Count"]?["N"]?.GetValue<int>() ?? 1,
All = target?["Count"]?["All"]?.GetValue<bool>() ?? false,
FilterType = firstFilter?["$type"]?.GetValue<string>() ?? "",
};
if (actionNode["Conditions"] is JsonArray actionConds)
@@ -854,21 +868,22 @@
var actionsArr = new JsonArray();
foreach (var action in ab.Actions)
{
var actionNode = new JsonObject
var targetNode = new JsonObject
{
["Target"] = new JsonObject
["Scope"] = action.Scope,
["Type"] = action.TargetType,
["Ownership"] = action.Ownership,
["Count"] = new JsonObject
{
["Scope"] = action.Scope,
["Type"] = action.TargetType,
["Ownership"] = action.Ownership,
["Count"] = new JsonObject
{
["N"] = action.All ? 1 : action.Count,
["UpTo"] = false,
["All"] = action.All,
},
["N"] = action.All ? 1 : action.Count,
["UpTo"] = false,
["All"] = action.All,
},
};
if (!string.IsNullOrEmpty(action.FilterType))
targetNode["Filters"] = new JsonArray(
new JsonObject { ["$type"] = action.FilterType });
var actionNode = new JsonObject { ["Target"] = targetNode };
if (action.Conditions.Count > 0)
{
@@ -1468,6 +1483,11 @@
public string Ownership { get; set; } = "Enemy";
public int Count { get; set; } = 1;
public bool All { get; set; }
/// <summary>
/// Optional filter type applied to the target pool (single filter, no-param variant).
/// "" = no filter. Maps to Target.Filters[0] in the compiled JSON.
/// </summary>
public string FilterType { get; set; } = "";
public List<ConditionDraft> Conditions { get; set; } = new();
public List<EffectDraft> Effects { get; set; } = new();
}