feat(phase4): ability builder revamp -- ActionGroup/CostGroup/TargetChooser + Phase 1 effects/conditions

- AbilityDraft: ActionGroupLogicOp/ChooserRole + CostGroupLogicOp/ChooserRole fields
- ActionDraft: Chooser field (Self/Opponent/Random) on TargetSelector
- EffectDraft: Zone, IgnoreCost, DestinationScope, AttackType new fields
- ConditionDraft: PropertyName, Value, CostType new fields
- Compile(): emits ActionGroup (replaces flat Actions[]) and CostGroup (replaces flat Cost[])
- ParseJson(): reads both new ActionGroup/CostGroup and legacy flat arrays
- New effects: AscendFromZone, TransitionFromZone, ModifyChannelRange, RelocateRuin,
  ActivateRuinAbility, DisableRuinForDuration, ChannelCardFromZone, CloneSpiritAsToken,
  DestroyToken, ModifySacrificeTokenReturn, SkipTurn, ModifyCardsDrawnThisTurn,
  StackDeck, SearchAndPlace, ChangeAttackType, ObstructMovementType
- New conditions: UnitTypeIs, OwnershipIs, IsThisCard, UnitPropertyCompare,
  PlayerPropertyCompare, HandContainsCount, CardDefinitionCountInZone,
  IsInRangeOfUnit, TileOccupant, SurroundingTile, SPAccumulationCompare, CostOfCardsInHand
- UI: ActionGroup LogicOp/Chooser above actions list; Chooser in each action target row;
  CostGroup LogicOp/Chooser in cost editor header

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-04-19 16:10:06 -04:00
co-authored by Claude Happy
parent 405be9790a
commit da220f353d
@@ -92,7 +92,22 @@
<!-- Cost editor -->
<div class="mb-3">
<div class="d-flex justify-content-between align-items-center mb-1">
<label class="form-label small fw-medium mb-0">Cost</label>
<div class="d-flex align-items-center gap-2">
<label class="form-label small fw-medium mb-0">Cost</label>
<select class="form-select form-select-sm" style="width:90px"
@bind="ab.CostGroupLogicOp" @bind:after="Compile" title="CostGroup logic operator">
@foreach (var op in LogicOpValues)
{ <option value="@op">@op</option> }
</select>
@if (ab.CostGroupLogicOp != "And")
{
<select class="form-select form-select-sm" style="width:110px"
@bind="ab.CostGroupChooserRole" @bind:after="Compile" title="Who picks which cost option">
@foreach (var r in ChooserRoleValues)
{ <option value="@r">@r</option> }
</select>
}
</div>
<button class="btn btn-sm btn-outline-secondary py-0 px-2"
@onclick="() => { ab.Costs.Add(new CostDraft()); Compile(); }">
<i class="bi bi-plus-lg me-1"></i>Add Cost
@@ -288,10 +303,29 @@
</div>
<!-- Actions -->
<h6 class="text-muted small mb-2">
Actions
<small class="ms-1 fw-normal">(each action = one targeting context + one or more effects)</small>
</h6>
<div class="d-flex align-items-center gap-2 mb-2">
<h6 class="text-muted small mb-0">
Actions
<small class="ms-1 fw-normal">(each action = one targeting context + one or more effects)</small>
</h6>
<div class="d-flex align-items-center gap-1">
<label class="form-label small mb-0 text-nowrap">Group:</label>
<select class="form-select form-select-sm" style="width:90px"
@bind="ab.ActionGroupLogicOp" @bind:after="Compile" title="ActionGroup logic operator">
@foreach (var op in LogicOpValues)
{ <option value="@op">@op</option> }
</select>
@if (ab.ActionGroupLogicOp != "And")
{
<label class="form-label small mb-0 text-nowrap ms-1">Chooser:</label>
<select class="form-select form-select-sm" style="width:110px"
@bind="ab.ActionGroupChooserRole" @bind:after="Compile" title="Who picks which action branch">
@foreach (var r in ChooserRoleValues)
{ <option value="@r">@r</option> }
</select>
}
</div>
</div>
@for (int aci = 0; aci < ab.Actions.Count; aci++)
{
@@ -321,12 +355,19 @@
@foreach (var t in TargetTypes) { <option value="@t">@t</option> }
</select>
</div>
<div class="col-md-3">
<div class="col-md-2">
<label class="form-label small mb-0">Ownership</label>
<select class="form-select form-select-sm" @bind="action.Ownership" @bind:after="Compile">
@foreach (var o in TargetOwnerships) { <option value="@o">@o</option> }
</select>
</div>
<div class="col-md-2">
<label class="form-label small mb-0">Chooser</label>
<select class="form-select form-select-sm" @bind="action.Chooser" @bind:after="Compile"
title="Who selects the target (Self=controlling player, Opponent, Random=server-side)">
@foreach (var r in ChooserRoleValues) { <option value="@r">@r</option> }
</select>
</div>
<div class="col-md-2">
<label class="form-label small mb-0">Count N</label>
<input type="number" min="1" class="form-control form-control-sm"
@@ -1122,6 +1163,19 @@
private static readonly string[] AnimationTypes = ["Projectile", "LinearProjectile", "ArcProjectile", "Aura"];
private static readonly string[] AnimationEffects = ["Self", "Target", "Some", "All"];
private static readonly string[] LogicOpValues = ["And", "Or", "Xor"];
private static readonly string[] ChooserRoleValues = ["Self", "Opponent", "Random"];
private static readonly string[] ZoneSubsetValues = ["Hand", "Deck", "Discard"];
private static readonly string[] AttackTypeValues = ["Melee", "Ranged"];
private static readonly string[] CloneDestValues = ["NeighborTile", "RandomInChannelRange", "TargetTile"];
private static readonly string[] UnitPropertyNames = [
"Damage", "Defense", "MaxDefense", "Health", "MaxHealth",
"MovementPoints", "MaxMovementPoints", "MinAttackRange", "MaxAttackRange",
"MinChannelRange", "MaxChannelRange", "Tier",
];
private static readonly string[] PlayerPropertyNames = ["SP", "ST", "SPAccumulation", "HandSize", "DeckSize", "DiscardSize"];
private static readonly string[] CostTypeCondValues = ["SP", "ST"];
private static readonly string[] CostTypes = [
"SpiritPoints", "SacrificeTokens", "DiscardFromHand", "MillTopOfDeck",
"MillBottomOfDeck", "SendSpiritFromBattlefieldToDiscard",
@@ -1168,8 +1222,13 @@
"SetBaseAffinity1", "SetBaseAffinity2", "PushAffinity", "PushFinalAffinity"]),
new("Ability Mgmt", ["AddAbility", "RemoveAbility", "EnableAbility", "DisableAbility"]),
new("Displacement", ["PushUnit", "PullUnit", "DisplaceUnit", "RepositionUnit"]),
new("Control", ["TakeControl", "GrantMovementControl", "SetFixedSacrificeReturn"]),
new("Token & Deferred", ["SummonToken", "ApplyOnEvent"]),
new("Control", ["TakeControl", "GrantMovementControl", "SetFixedSacrificeReturn", "SkipTurn"]),
new("Token & Deferred", ["SummonToken", "CloneSpiritAsToken", "DestroyToken", "ModifySacrificeTokenReturn", "ApplyOnEvent"]),
new("ArchSpirit Ops", ["AscendFromZone", "TransitionFromZone", "ModifyChannelRange"]),
new("Ruin Ops", ["RelocateRuin", "ActivateRuinAbility", "DisableRuinForDuration"]),
new("Channeling", ["ChannelCardFromZone"]),
new("Unit Manipulation", ["ChangeAttackType", "ObstructMovementType"]),
new("Deck Ops", ["StackDeck", "SearchAndPlace"]),
];
// ── Condition groups ─────────────────────────────────────────────────────────
@@ -1180,11 +1239,14 @@
new("Unit", ["HealthBelow", "HealthAbove", "DefenseIs", "HasGenus", "HasAbility",
"IsOnTileWithAffinity", "IsAdjacentTo", "WithinRangeOf", "MovementTypeIs",
"DestinationTileAffinityIs", "PreviousTileAffinityIs", "MovedFromOrIntoAffinity",
"IsAdjacentToTileWithAffinity", "IsOnOrAdjacentToTileWithAffinity", "IsCurrentlyMoving"]),
"IsAdjacentToTileWithAffinity", "IsOnOrAdjacentToTileWithAffinity", "IsCurrentlyMoving",
"UnitTypeIs", "OwnershipIs", "IsThisCard", "UnitPropertyCompare",
"IsInRangeOfUnit", "TileOccupant"]),
new("Player", ["SPAtLeast", "SPAtMost", "STAtLeast", "STAtMost",
"HandSizeAtLeast", "HandSizeAtMost", "DeckSizeAtLeast", "DiscardSizeAtLeast"]),
new("Tile", ["TileAffinityMatches", "TileIsOccupied", "TileIsUnoccupied"]),
new("Battlefield", ["UnitCountOnBattlefield", "CardInZone", "ControlledTileCountWithAffinity"]),
"HandSizeAtLeast", "HandSizeAtMost", "DeckSizeAtLeast", "DiscardSizeAtLeast",
"PlayerPropertyCompare", "HandContainsCount", "SPAccumulationCompare", "CostOfCardsInHand"]),
new("Tile", ["TileAffinityMatches", "TileIsOccupied", "TileIsUnoccupied", "SurroundingTile"]),
new("Battlefield", ["UnitCountOnBattlefield", "CardInZone", "ControlledTileCountWithAffinity", "CardDefinitionCountInZone"]),
new("Composite", ["AND", "OR", "XOR", "NOT"]),
];
@@ -1192,7 +1254,7 @@
private static readonly HashSet<string> _amountBypassTypes = ["DealDamage", "DealDamageToSelf"];
private static readonly HashSet<string> _amountOnlyTypes = ["Heal", "ModifyDamage", "ModifySP", "ModifyST", "ModifyCardsDrawnPerTurn", "ModifySPAccumulation",
"ModifyMinAttackRange", "ModifyMaxAttackRange", "PreventNextDamage"];
"ModifyMinAttackRange", "ModifyMaxAttackRange", "PreventNextDamage", "ModifyCardsDrawnThisTurn"];
private static readonly HashSet<string> _amountStatTypes = ["ModifyHealth", "ModifyDefense", "ModifyMP"];
private static readonly HashSet<string> _valueTypes = [
"SetCanMove", "SetCanAttack", "SetCanDefend", "SetCanBeAttacked",
@@ -1203,8 +1265,8 @@
"SetCanChannelTerramorphaMono", "SetCanChannelTerramorphaDi", "SetCanChannelTerramorphaTri",
];
private static readonly HashSet<string> _affinityTypes = ["SetAffinity", "SetBaseAffinity1", "SetBaseAffinity2", "PushAffinity", "PushFinalAffinity"];
private static readonly HashSet<string> _rawJsonTypes = ["AddAbility", "ApplyOnEvent"];
private static readonly HashSet<string> _noFieldTypes = ["ReturnToHand", "SendToDiscard"];
private static readonly HashSet<string> _rawJsonTypes = ["AddAbility", "ApplyOnEvent", "ChannelCardFromZone", "SearchAndPlace", "ActivateRuinAbility"];
private static readonly HashSet<string> _noFieldTypes = ["ReturnToHand", "SendToDiscard", "RelocateRuin", "DestroyToken", "SkipTurn"];
// ── Trigger templates ────────────────────────────────────────────────────────
@@ -1314,7 +1376,20 @@
ab.TriggerAuraOwnership = trig["AuraOwnership"]?.GetValue<string>() ?? "Owner";
}
if (node["Cost"] is JsonArray costs)
// CostGroup (new) or flat Cost array (legacy)
if (node["CostGroup"] is JsonObject cg)
{
ab.CostGroupLogicOp = cg["LogicOp"]?.GetValue<string>() ?? "And";
ab.CostGroupChooserRole = cg["ChooserRole"]?.GetValue<string>() ?? "Self";
if (cg["Entries"] is JsonArray cgEntries)
foreach (var c in cgEntries.OfType<JsonObject>())
ab.Costs.Add(new CostDraft
{
TypeStr = c["Type"]?.GetValue<string>() ?? "SpiritPoints",
Amount = c["Amount"]?.GetValue<int>() ?? 1,
});
}
else if (node["Cost"] is JsonArray costs)
foreach (var c in costs.OfType<JsonObject>())
ab.Costs.Add(new CostDraft
{
@@ -1326,8 +1401,20 @@
foreach (var c in aconds.OfType<JsonObject>())
ab.Conditions.Add(ParseCondition(c));
if (node["Actions"] is JsonArray actions)
foreach (var actionNode in actions.OfType<JsonObject>())
// ActionGroup (new) or flat Actions array (legacy)
JsonArray? actionsSource = null;
if (node["ActionGroup"] is JsonObject ag)
{
ab.ActionGroupLogicOp = ag["LogicOp"]?.GetValue<string>() ?? "And";
ab.ActionGroupChooserRole = ag["ChooserRole"]?.GetValue<string>() ?? "Self";
actionsSource = ag["Actions"] as JsonArray;
}
else
{
actionsSource = node["Actions"] as JsonArray;
}
if (actionsSource != null)
foreach (var actionNode in actionsSource.OfType<JsonObject>())
{
var target = actionNode["Target"] as JsonObject;
var firstFilter= (target?["Filters"] as JsonArray)?.OfType<JsonObject>().FirstOrDefault();
@@ -1336,6 +1423,7 @@
Scope = target?["Scope"]?.GetValue<string>() ?? "Battlefield",
TargetType = target?["Type"]?.GetValue<string>() ?? "Unit",
Ownership = target?["Ownership"]?.GetValue<string>() ?? "Enemy",
Chooser = target?["Chooser"]?.GetValue<string>() ?? "Self",
Count = target?["Count"]?["N"]?.GetValue<int>() ?? 1,
All = target?["Count"]?["All"]?.GetValue<bool>() ?? false,
FilterType = firstFilter?["$type"]?.GetValue<string>() ?? "",
@@ -1386,7 +1474,8 @@
N = c["N"]?.GetValue<int>() ?? 1,
Min = c["Min"]?.GetValue<int>() ?? 1,
Max = c["Max"]?.GetValue<int>() ?? 1,
Tag = c["Tag"]?.GetValue<string>() ?? "",
// Tag covers both HasGenus.Tag and HandContainsCount/CostOfCardsInHand CardType
Tag = c["Tag"]?.GetValue<string>() ?? c["CardType"]?.GetValue<string>() ?? "",
AbilityRef = c["AbilityRef"]?.GetValue<string>() ?? "",
Affinity = c["Affinity"]?.GetValue<string>() ?? "Aether",
UnitType = c["UnitType"]?.GetValue<string>() ?? "Unit",
@@ -1397,6 +1486,10 @@
Zone = c["Zone"]?.GetValue<string>() ?? "Hand",
CardRef = c["CardRef"]?.GetValue<string>() ?? "",
InnerConditionJson = c["Condition"]?.ToJsonString() ?? "{\"$type\":\"IsOwnTurn\"}",
// Phase-1 extended fields
PropertyName = c["PropertyName"]?.GetValue<string>() ?? "",
Value = c["Value"]?.GetValue<int>() ?? 1,
CostType = c["CostType"]?.GetValue<string>() ?? "SP",
};
private static EffectDraft ParseEffect(JsonObject eff)
@@ -1566,6 +1659,36 @@
catch { /* keep defaults */ }
d.TokenMode = "Custom";
}
else if (typeKey is "AscendFromZone" or "TransitionFromZone")
{
d.Zone = ReadStr("Zone", "Hand");
d.IgnoreCost = ReadBool("IgnoreCost");
}
else if (typeKey == "ModifyChannelRange")
{
d.Min = ReadInt("MinDelta", 0); d.Max = ReadInt("MaxDelta", 0);
}
else if (typeKey == "DisableRuinForDuration")
{
d.DurationType = ReadDurType(); d.DurationN = ReadDurN();
}
else if (typeKey == "CloneSpiritAsToken")
{
d.DestinationScope = ReadStr("DestinationScope", "NeighborTile");
}
else if (typeKey == "StackDeck")
{
d.N = ReadInt("Count", 1); d.Player = ReadStr("Chooser", "Self");
}
else if (typeKey == "ChangeAttackType")
{
d.AttackType = ReadStr("AttackType", "Melee");
}
else if (typeKey == "ObstructMovementType")
{
d.MovementType = ReadStr("MovementType", "Walk");
d.DurationType = ReadDurType(); d.DurationN = ReadDurN();
}
else if (_rawJsonTypes.Contains(typeKey))
{
var fields = new JsonObject();
@@ -1612,10 +1735,14 @@
if (ab.Costs.Count > 0)
{
var costsArr = new JsonArray();
var costGroup = new JsonObject { ["LogicOp"] = ab.CostGroupLogicOp };
if (ab.CostGroupLogicOp != "And" || ab.CostGroupChooserRole != "Self")
costGroup["ChooserRole"] = ab.CostGroupChooserRole;
var entriesArr = new JsonArray();
foreach (var cost in ab.Costs)
costsArr.Add(new JsonObject { ["Type"] = cost.TypeStr, ["Amount"] = cost.Amount });
node["Cost"] = costsArr;
entriesArr.Add(new JsonObject { ["Type"] = cost.TypeStr, ["Amount"] = cost.Amount });
costGroup["Entries"] = entriesArr;
node["CostGroup"] = costGroup;
}
}
else if (ab.TypeStr == "Aura")
@@ -1657,6 +1784,7 @@
["Scope"] = action.Scope,
["Type"] = action.TargetType,
["Ownership"] = action.Ownership,
["Chooser"] = action.Chooser,
["Count"] = new JsonObject
{
["N"] = action.All ? 1 : action.Count,
@@ -1683,7 +1811,12 @@
actionsArr.Add(actionNode);
}
node["Actions"] = actionsArr;
// Emit ActionGroup (new format) wrapping all leaf actions
var actionGroup = new JsonObject { ["LogicOp"] = ab.ActionGroupLogicOp };
if (ab.ActionGroupLogicOp != "And" || ab.ActionGroupChooserRole != "Self")
actionGroup["ChooserRole"] = ab.ActionGroupChooserRole;
actionGroup["Actions"] = actionsArr;
node["ActionGroup"] = actionGroup;
if (!string.IsNullOrEmpty(ab.DurationStr))
{
@@ -1778,6 +1911,50 @@
node["Condition"] = new JsonObject { ["$type"] = "IsOwnTurn" };
}
break;
// Phase-1 extended conditions
case "UnitTypeIs":
node["UnitType"] = c.UnitType; break;
case "OwnershipIs":
node["Ownership"] = c.Ownership; break;
// IsThisCard: no fields
case "UnitPropertyCompare":
node["PropertyName"] = c.PropertyName;
node["Comparator"] = c.Comparator;
node["Value"] = c.Value;
break;
case "PlayerPropertyCompare":
node["PropertyName"] = c.PropertyName;
node["Comparator"] = c.Comparator;
node["Value"] = c.Value;
break;
case "HandContainsCount":
if (!string.IsNullOrEmpty(c.Tag)) node["CardType"] = c.Tag;
if (c.Affinity != "Aether") node["Affinity"] = c.Affinity;
node["Comparator"] = c.Comparator;
node["N"] = c.N;
break;
case "CardDefinitionCountInZone":
node["Zone"] = c.Zone; node["Ownership"] = c.Ownership;
node["Comparator"] = c.Comparator; node["N"] = c.N;
break;
case "IsInRangeOfUnit":
node["Min"] = c.Min; node["Max"] = c.Max;
node["UnitType"] = c.UnitType; node["Ownership"] = c.Ownership;
break;
case "TileOccupant":
node["UnitType"] = c.UnitType; node["Ownership"] = c.Ownership; break;
case "SurroundingTile":
node["Min"] = c.Min; node["Max"] = c.Max;
node["TileCountComparator"] = c.Comparator; node["TileCount"] = c.N;
break;
case "SPAccumulationCompare":
node["Comparator"] = c.Comparator; node["Value"] = c.Value; break;
case "CostOfCardsInHand":
node["CostType"] = c.CostType;
if (!string.IsNullOrEmpty(c.Tag)) node["CardType"] = c.Tag;
if (c.Affinity != "Aether") node["Affinity"] = c.Affinity;
node["Comparator"] = c.Comparator; node["Value"] = c.Value;
break;
}
return node;
}
@@ -2065,6 +2242,37 @@
new JsonObject { ["$type"] = "TileAffinityMatches", ["Affinity"] = d.TokenAffinity });
}
}
else if (d.TypeKey is "AscendFromZone" or "TransitionFromZone")
{
node["Zone"] = d.Zone;
if (d.IgnoreCost) node["IgnoreCost"] = true;
}
else if (d.TypeKey == "ModifyChannelRange")
{
if (d.Min != 0) node["MinDelta"] = d.Min;
if (d.Max != 0) node["MaxDelta"] = d.Max;
}
else if (d.TypeKey == "DisableRuinForDuration")
{
node["Duration"] = Duration();
}
else if (d.TypeKey == "CloneSpiritAsToken")
{
node["DestinationScope"] = d.DestinationScope;
}
else if (d.TypeKey == "StackDeck")
{
node["Count"] = d.N; node["Chooser"] = d.Player;
}
else if (d.TypeKey == "ChangeAttackType")
{
node["AttackType"] = d.AttackType;
}
else if (d.TypeKey == "ObstructMovementType")
{
node["MovementType"] = d.MovementType;
node["Duration"] = Duration();
}
else if (_rawJsonTypes.Contains(d.TypeKey))
{
if (!string.IsNullOrWhiteSpace(d.RawJson))
@@ -2191,7 +2399,77 @@
this, e => { c.InnerConditionJson = e.Value?.ToString() ?? ""; Compile(); }));
__builder.CloseElement();
}
// AND/OR/XOR + no-field types: no extra inputs
// ── Phase-1 extended conditions ───────────────────────────────────────
else if (t == "UnitTypeIs")
{
BuildSelect(__builder, UnitTypeValues, c.UnitType, v => { c.UnitType = v; Compile(); }, 120);
}
else if (t == "OwnershipIs")
{
BuildSelect(__builder, OwnershipValues, c.Ownership, v => { c.Ownership = v; Compile(); }, 100);
}
// IsThisCard: no extra fields
else if (t == "UnitPropertyCompare")
{
BuildSelect(__builder, UnitPropertyNames, c.PropertyName == "" ? "Damage" : c.PropertyName,
v => { c.PropertyName = v; Compile(); }, 160);
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 170);
BuildIntInput(__builder, c.Value, v => { c.Value = v; Compile(); }, 70, "Value");
}
else if (t == "PlayerPropertyCompare")
{
BuildSelect(__builder, PlayerPropertyNames, c.PropertyName == "" ? "SP" : c.PropertyName,
v => { c.PropertyName = v; Compile(); }, 150);
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 170);
BuildIntInput(__builder, c.Value, v => { c.Value = v; Compile(); }, 70, "Value");
}
else if (t == "HandContainsCount")
{
BuildOptionalStringSelect(__builder, TriggerCardTypeValues, c.Tag, v => { c.Tag = v; Compile(); }, 130, "Any card type");
BuildOptionalStringSelect(__builder, AffinityValues, c.Affinity, v => { c.Affinity = v; Compile(); }, 130, "Any affinity");
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 170);
BuildIntInput(__builder, c.N, v => { c.N = v; Compile(); }, 60, "N");
}
else if (t == "CardDefinitionCountInZone")
{
BuildSelect(__builder, ZoneValues, c.Zone, v => { c.Zone = v; Compile(); }, 110);
BuildSelect(__builder, OwnershipValues, c.Ownership, v => { c.Ownership = v; Compile(); }, 90);
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 170);
BuildIntInput(__builder, c.N, v => { c.N = v; Compile(); }, 60, "N");
}
else if (t == "IsInRangeOfUnit")
{
BuildIntInput(__builder, c.Min, v => { c.Min = v; Compile(); }, 60, "Min");
BuildIntInput(__builder, c.Max, v => { c.Max = v; Compile(); }, 60, "Max");
BuildSelect(__builder, UnitTypeValues, c.UnitType, v => { c.UnitType = v; Compile(); }, 110);
BuildSelect(__builder, OwnershipValues, c.Ownership, v => { c.Ownership = v; Compile(); }, 90);
}
else if (t == "TileOccupant")
{
BuildSelect(__builder, UnitTypeValues, c.UnitType, v => { c.UnitType = v; Compile(); }, 110);
BuildSelect(__builder, OwnershipValues, c.Ownership, v => { c.Ownership = v; Compile(); }, 90);
}
else if (t == "SurroundingTile")
{
BuildIntInput(__builder, c.Min, v => { c.Min = v; Compile(); }, 60, "Min dist");
BuildIntInput(__builder, c.Max, v => { c.Max = v; Compile(); }, 60, "Max dist");
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 170);
BuildIntInput(__builder, c.N, v => { c.N = v; Compile(); }, 70, "TileCount");
}
else if (t == "SPAccumulationCompare")
{
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 170);
BuildIntInput(__builder, c.Value, v => { c.Value = v; Compile(); }, 70, "Value");
}
else if (t == "CostOfCardsInHand")
{
BuildSelect(__builder, CostTypeCondValues, c.CostType, v => { c.CostType = v; Compile(); }, 80);
BuildOptionalStringSelect(__builder, TriggerCardTypeValues, c.Tag, v => { c.Tag = v; Compile(); }, 130, "Any card type");
BuildOptionalStringSelect(__builder, AffinityValues, c.Affinity, v => { c.Affinity = v; Compile(); }, 130, "Any affinity");
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 170);
BuildIntInput(__builder, c.Value, v => { c.Value = v; Compile(); }, 70, "Value");
}
// AND/OR/XOR + no-field types (IsThisCard, etc.): no extra inputs
};
private RenderFragment RenderEffectFields(EffectDraft d, int actionIdx = 0, bool isTriggered = false) => __builder =>
@@ -2363,6 +2641,38 @@
this, e => { d.AbilityRef = e.Value?.ToString() ?? ""; Compile(); }));
__builder.CloseElement();
}
else if (t is "AscendFromZone" or "TransitionFromZone")
{
BuildSelect(__builder, ZoneSubsetValues, d.Zone, v => { d.Zone = v; Compile(); }, 110);
BuildCheckbox(__builder, "Ignore Cost", d.IgnoreCost, v => { d.IgnoreCost = v; Compile(); });
}
else if (t == "ModifyChannelRange")
{
BuildIntInput(__builder, d.Min, v => { d.Min = v; Compile(); }, 90, "MinDelta");
BuildIntInput(__builder, d.Max, v => { d.Max = v; Compile(); }, 90, "MaxDelta");
}
else if (t == "DisableRuinForDuration")
{
BuildDuration(__builder, d);
}
else if (t == "CloneSpiritAsToken")
{
BuildSelect(__builder, CloneDestValues, d.DestinationScope, v => { d.DestinationScope = v; Compile(); }, 200);
}
else if (t == "StackDeck")
{
BuildIntInput(__builder, d.N, v => { d.N = v; Compile(); }, 70, "Count");
BuildSelect(__builder, ChooserRoleValues, d.Player, v => { d.Player = v; Compile(); }, 110);
}
else if (t == "ChangeAttackType")
{
BuildSelect(__builder, AttackTypeValues, d.AttackType, v => { d.AttackType = v; Compile(); }, 110);
}
else if (t == "ObstructMovementType")
{
BuildSelect(__builder, MovementTypeValues, d.MovementType, v => { d.MovementType = v; Compile(); }, 110);
BuildDuration(__builder, d);
}
else if (_rawJsonTypes.Contains(t))
{
__builder.OpenElement(0, "textarea");
@@ -2763,6 +3073,9 @@
effect.Stat = "Damage"; effect.Multiplier = 1.5f; effect.Sp = null; effect.St = null;
effect.DurationType = "UntilEndOfTurn"; effect.DurationN = 1;
effect.RawJson = "{}";
// Phase-1 new field reset
effect.Zone = "Hand"; effect.IgnoreCost = false;
effect.DestinationScope = "NeighborTile"; effect.AttackType = "Melee";
// SummonToken reset
effect.TokenMode = "Custom"; effect.TokenExistingId = null; effect.TokenExistingSearch = "";
effect.TokenShowDropdown = false;
@@ -2812,6 +3125,12 @@
public bool RangeRequiresLos { get; set; } = false;
public bool RangeLinearOnly { get; set; } = false;
public int UsesPerTurn { get; set; } = 1;
// ── ActionGroup logic ────────────────────────────────────────────────
public string ActionGroupLogicOp { get; set; } = "And";
public string ActionGroupChooserRole{ get; set; } = "Self";
// ── CostGroup logic ──────────────────────────────────────────────────
public string CostGroupLogicOp { get; set; } = "And";
public string CostGroupChooserRole { get; set; } = "Self";
public int? AuraRangeMin { get; set; }
public int? AuraRangeMax { get; set; }
public bool AuraClearOnLeave { get; set; } = false;
@@ -2860,6 +3179,8 @@
public string Scope { get; set; } = "Battlefield";
public string TargetType { get; set; } = "Unit";
public string Ownership { get; set; } = "Enemy";
/// <summary>Who makes the target selection (Self/Opponent/Ally/Random).</summary>
public string Chooser { get; set; } = "Self";
public int Count { get; set; } = 1;
public bool All { get; set; }
/// <summary>
@@ -2873,8 +3194,8 @@
private sealed class EffectDraft
{
public string TypeKey { get; set; } = "DealDamage";
public int Amount { get; set; } = 1;
public string TypeKey { get; set; } = "DealDamage";
public int Amount { get; set; } = 1;
public string AmountRef { get; set; } = ""; // "" = use Fixed; non-empty = ValueExpr Ref path
public int N { get; set; } = 1;
public bool BypassDefense{ get; set; } = false;
@@ -2904,7 +3225,16 @@
public int StAmount { get; set; } = 1;
public int? Sp { get; set; }
public int? St { get; set; }
public string RawJson { get; set; } = "{}";
public string RawJson { get; set; } = "{}";
// ── Phase-1 new effect fields ─────────────────────────────────────────
/// <summary>Zone: "Hand" | "Deck" | "Discard" — for AscendFromZone, TransitionFromZone.</summary>
public string Zone { get; set; } = "Hand";
/// <summary>IgnoreCost flag — for AscendFromZone, TransitionFromZone.</summary>
public bool IgnoreCost { get; set; } = false;
/// <summary>DestinationScope — for CloneSpiritAsToken: "NeighborTile" | "RandomInChannelRange" | "TargetTile".</summary>
public string DestinationScope{ get; set; } = "NeighborTile";
/// <summary>AttackType — for ChangeAttackType: "Melee" | "Ranged".</summary>
public string AttackType { get; set; } = "Melee";
// ── SummonToken fields ─────────────────────────────────────────────────
public string TokenMode { get; set; } = "Custom"; // "Custom" | "ExistingCard"
@@ -2953,6 +3283,13 @@
public string Zone { get; set; } = "Hand";
public string CardRef { get; set; } = "";
public string InnerConditionJson { get; set; } = "{\"$type\":\"IsOwnTurn\"}";
// ── Phase-1 extended condition fields ─────────────────────────────────
/// <summary>PropertyName — for UnitPropertyCompare, PlayerPropertyCompare.</summary>
public string PropertyName { get; set; } = "";
/// <summary>Numeric value — for UnitPropertyCompare, PlayerPropertyCompare, SPAccumulationCompare.</summary>
public int Value { get; set; } = 1;
/// <summary>CostType — for CostOfCardsInHand: "SP" | "ST".</summary>
public string CostType { get; set; } = "SP";
}
private sealed class CostDraft