diff --git a/Server/src/SOR.Admin/Components/Pages/Cards/AbilityBuilder.razor b/Server/src/SOR.Admin/Components/Pages/Cards/AbilityBuilder.razor
index 81a04e9..97fc42e 100644
--- a/Server/src/SOR.Admin/Components/Pages/Cards/AbilityBuilder.razor
+++ b/Server/src/SOR.Admin/Components/Pages/Cards/AbilityBuilder.razor
@@ -92,7 +92,22 @@
+
+
+
+
+
_amountBypassTypes = ["DealDamage", "DealDamageToSelf"];
private static readonly HashSet _amountOnlyTypes = ["Heal", "ModifyDamage", "ModifySP", "ModifyST", "ModifyCardsDrawnPerTurn", "ModifySPAccumulation",
- "ModifyMinAttackRange", "ModifyMaxAttackRange", "PreventNextDamage"];
+ "ModifyMinAttackRange", "ModifyMaxAttackRange", "PreventNextDamage", "ModifyCardsDrawnThisTurn"];
private static readonly HashSet _amountStatTypes = ["ModifyHealth", "ModifyDefense", "ModifyMP"];
private static readonly HashSet _valueTypes = [
"SetCanMove", "SetCanAttack", "SetCanDefend", "SetCanBeAttacked",
@@ -1203,8 +1265,8 @@
"SetCanChannelTerramorphaMono", "SetCanChannelTerramorphaDi", "SetCanChannelTerramorphaTri",
];
private static readonly HashSet _affinityTypes = ["SetAffinity", "SetBaseAffinity1", "SetBaseAffinity2", "PushAffinity", "PushFinalAffinity"];
- private static readonly HashSet _rawJsonTypes = ["AddAbility", "ApplyOnEvent"];
- private static readonly HashSet _noFieldTypes = ["ReturnToHand", "SendToDiscard"];
+ private static readonly HashSet _rawJsonTypes = ["AddAbility", "ApplyOnEvent", "ChannelCardFromZone", "SearchAndPlace", "ActivateRuinAbility"];
+ private static readonly HashSet _noFieldTypes = ["ReturnToHand", "SendToDiscard", "RelocateRuin", "DestroyToken", "SkipTurn"];
// ── Trigger templates ────────────────────────────────────────────────────────
@@ -1314,7 +1376,20 @@
ab.TriggerAuraOwnership = trig["AuraOwnership"]?.GetValue() ?? "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() ?? "And";
+ ab.CostGroupChooserRole = cg["ChooserRole"]?.GetValue() ?? "Self";
+ if (cg["Entries"] is JsonArray cgEntries)
+ foreach (var c in cgEntries.OfType())
+ ab.Costs.Add(new CostDraft
+ {
+ TypeStr = c["Type"]?.GetValue() ?? "SpiritPoints",
+ Amount = c["Amount"]?.GetValue() ?? 1,
+ });
+ }
+ else if (node["Cost"] is JsonArray costs)
foreach (var c in costs.OfType())
ab.Costs.Add(new CostDraft
{
@@ -1326,8 +1401,20 @@
foreach (var c in aconds.OfType())
ab.Conditions.Add(ParseCondition(c));
- if (node["Actions"] is JsonArray actions)
- foreach (var actionNode in actions.OfType())
+ // ActionGroup (new) or flat Actions array (legacy)
+ JsonArray? actionsSource = null;
+ if (node["ActionGroup"] is JsonObject ag)
+ {
+ ab.ActionGroupLogicOp = ag["LogicOp"]?.GetValue() ?? "And";
+ ab.ActionGroupChooserRole = ag["ChooserRole"]?.GetValue() ?? "Self";
+ actionsSource = ag["Actions"] as JsonArray;
+ }
+ else
+ {
+ actionsSource = node["Actions"] as JsonArray;
+ }
+ if (actionsSource != null)
+ foreach (var actionNode in actionsSource.OfType())
{
var target = actionNode["Target"] as JsonObject;
var firstFilter= (target?["Filters"] as JsonArray)?.OfType().FirstOrDefault();
@@ -1336,6 +1423,7 @@
Scope = target?["Scope"]?.GetValue() ?? "Battlefield",
TargetType = target?["Type"]?.GetValue() ?? "Unit",
Ownership = target?["Ownership"]?.GetValue() ?? "Enemy",
+ Chooser = target?["Chooser"]?.GetValue() ?? "Self",
Count = target?["Count"]?["N"]?.GetValue() ?? 1,
All = target?["Count"]?["All"]?.GetValue() ?? false,
FilterType = firstFilter?["$type"]?.GetValue() ?? "",
@@ -1386,7 +1474,8 @@
N = c["N"]?.GetValue() ?? 1,
Min = c["Min"]?.GetValue() ?? 1,
Max = c["Max"]?.GetValue() ?? 1,
- Tag = c["Tag"]?.GetValue() ?? "",
+ // Tag covers both HasGenus.Tag and HandContainsCount/CostOfCardsInHand CardType
+ Tag = c["Tag"]?.GetValue() ?? c["CardType"]?.GetValue() ?? "",
AbilityRef = c["AbilityRef"]?.GetValue() ?? "",
Affinity = c["Affinity"]?.GetValue() ?? "Aether",
UnitType = c["UnitType"]?.GetValue() ?? "Unit",
@@ -1397,6 +1486,10 @@
Zone = c["Zone"]?.GetValue() ?? "Hand",
CardRef = c["CardRef"]?.GetValue() ?? "",
InnerConditionJson = c["Condition"]?.ToJsonString() ?? "{\"$type\":\"IsOwnTurn\"}",
+ // Phase-1 extended fields
+ PropertyName = c["PropertyName"]?.GetValue() ?? "",
+ Value = c["Value"]?.GetValue() ?? 1,
+ CostType = c["CostType"]?.GetValue() ?? "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";
+ /// Who makes the target selection (Self/Opponent/Ally/Random).
+ public string Chooser { get; set; } = "Self";
public int Count { get; set; } = 1;
public bool All { get; set; }
///
@@ -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 ─────────────────────────────────────────
+ /// Zone: "Hand" | "Deck" | "Discard" — for AscendFromZone, TransitionFromZone.
+ public string Zone { get; set; } = "Hand";
+ /// IgnoreCost flag — for AscendFromZone, TransitionFromZone.
+ public bool IgnoreCost { get; set; } = false;
+ /// DestinationScope — for CloneSpiritAsToken: "NeighborTile" | "RandomInChannelRange" | "TargetTile".
+ public string DestinationScope{ get; set; } = "NeighborTile";
+ /// AttackType — for ChangeAttackType: "Melee" | "Ranged".
+ 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 ─────────────────────────────────
+ /// PropertyName — for UnitPropertyCompare, PlayerPropertyCompare.
+ public string PropertyName { get; set; } = "";
+ /// Numeric value — for UnitPropertyCompare, PlayerPropertyCompare, SPAccumulationCompare.
+ public int Value { get; set; } = 1;
+ /// CostType — for CostOfCardsInHand: "SP" | "ST".
+ public string CostType { get; set; } = "SP";
}
private sealed class CostDraft