Add phase-1 ability primitives and builder support
This commit is contained in:
@@ -207,6 +207,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-2 mt-1">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small mb-0">Trigger Limit / Turn</label>
|
||||
<input type="number" min="1" class="form-control form-control-sm"
|
||||
@bind="ab.TriggerLimitPerTurn" @bind:after="Compile"
|
||||
placeholder="blank = unlimited" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -807,7 +815,7 @@
|
||||
<tr><td><strong>Active</strong></td><td>Player explicitly activates on their turn</td><td>Range, Cost, UsesPerTurn</td></tr>
|
||||
<tr><td><strong>Passive</strong></td><td>Always in effect while unit is on battlefield</td><td>Actions (target=Self)</td></tr>
|
||||
<tr><td><strong>Aura</strong></td><td>Applies Actions to units entering range; fires OnEnterAuraRange / OnLeaveAuraRange triggers. On Leave: <em>Persist</em> = keep effect duration, <em>Clear</em> = revert immediately, <em>Linger</em> = switch to linger duration</td><td>AuraRange, Actions, ClearOnLeave / LingerDuration</td></tr>
|
||||
<tr><td><strong>Triggered</strong></td><td>Fires automatically when a specific game event occurs</td><td>TriggerEvent, Actions</td></tr>
|
||||
<tr><td><strong>Triggered</strong></td><td>Fires automatically when a specific game event occurs</td><td>TriggerEvent, TriggerLimitPerTurn, Actions</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -906,6 +914,8 @@
|
||||
<tr><td>DefenseIs / SPAtLeast / STAtLeast</td><td>Stat comparisons</td></tr>
|
||||
<tr><td>HasGenus / HasAbility</td><td>Subject has a genus tag / named ability</td></tr>
|
||||
<tr><td>IsOnTileWithAffinity</td><td>Subject's tile matches the specified affinity</td></tr>
|
||||
<tr><td>DestinationTileAffinityIs / PreviousTileAffinityIs</td><td>On move-triggered abilities, checks the moved-to / moved-from tile affinity</td></tr>
|
||||
<tr><td>MovedFromOrIntoAffinity</td><td>On move-triggered abilities, passes if either origin or destination tile matches affinity</td></tr>
|
||||
<tr><td>IsAdjacentTo</td><td>Subject is adjacent to a unit matching Ownership</td></tr>
|
||||
<tr><td>WithinRangeOf</td><td>Subject is within N tiles of a unit matching Ownership</td></tr>
|
||||
<tr><td>UnitCountOnBattlefield</td><td>Total matching units on board satisfies comparator</td></tr>
|
||||
@@ -1150,7 +1160,7 @@
|
||||
new("Genus & Affinity", ["AddGenus", "RemoveGenus", "SetAffinity",
|
||||
"SetBaseAffinity1", "SetBaseAffinity2", "PushAffinity", "PushFinalAffinity"]),
|
||||
new("Ability Mgmt", ["AddAbility", "RemoveAbility", "EnableAbility", "DisableAbility"]),
|
||||
new("Displacement", ["PushUnit", "PullUnit", "DisplaceUnit"]),
|
||||
new("Displacement", ["PushUnit", "PullUnit", "DisplaceUnit", "RepositionUnit"]),
|
||||
new("Control", ["TakeControl", "GrantMovementControl", "SetFixedSacrificeReturn"]),
|
||||
new("Token & Deferred", ["SummonToken", "ApplyOnEvent"]),
|
||||
];
|
||||
@@ -1161,12 +1171,13 @@
|
||||
[
|
||||
new("Turn / Timing", ["IsOwnTurn", "IsOpponentTurn", "IsAllyTurn", "IsActivePlayerTurn"]),
|
||||
new("Unit", ["HealthBelow", "HealthAbove", "DefenseIs", "HasGenus", "HasAbility",
|
||||
"IsOnTileWithAffinity", "IsAdjacentTo", "WithinRangeOf", "MovementTypeIs"]),
|
||||
"IsOnTileWithAffinity", "IsAdjacentTo", "WithinRangeOf", "MovementTypeIs",
|
||||
"DestinationTileAffinityIs", "PreviousTileAffinityIs", "MovedFromOrIntoAffinity"]),
|
||||
new("Player", ["SPAtLeast", "SPAtMost", "STAtLeast", "STAtMost",
|
||||
"HandSizeAtLeast", "HandSizeAtMost", "DeckSizeAtLeast", "DiscardSizeAtLeast"]),
|
||||
new("Tile", ["TileAffinityMatches", "TileIsOccupied", "TileIsUnoccupied"]),
|
||||
new("Battlefield", ["UnitCountOnBattlefield", "CardInZone"]),
|
||||
new("Composite", ["AND", "OR", "XOR"]),
|
||||
new("Composite", ["AND", "OR", "XOR", "NOT"]),
|
||||
];
|
||||
|
||||
// ── Effect type categories for rendering ─────────────────────────────────────
|
||||
@@ -1260,6 +1271,7 @@
|
||||
Name = node["Name"]?.GetValue<string>() ?? "",
|
||||
Description = node["Description"]?.GetValue<string>() ?? "",
|
||||
UsesPerTurn = node["UsesPerTurn"]?.GetValue<int>() ?? 1,
|
||||
TriggerLimitPerTurn = node["TriggerLimitPerTurn"]?.GetValue<int?>(),
|
||||
RangeMin = node["Range"]?["Min"]?.GetValue<int>(),
|
||||
RangeMax = node["Range"]?["Max"]?.GetValue<int>(),
|
||||
RangeRequiresLos = node["Range"]?["RequiresLos"]?.GetValue<bool>() ?? false,
|
||||
@@ -1373,6 +1385,7 @@
|
||||
Comparator = c["Comparator"]?.GetValue<string>() ?? "GreaterThanOrEqual",
|
||||
Zone = c["Zone"]?.GetValue<string>() ?? "Hand",
|
||||
CardRef = c["CardRef"]?.GetValue<string>() ?? "",
|
||||
InnerConditionJson = c["Condition"]?.ToJsonString() ?? "{\"$type\":\"IsOwnTurn\"}",
|
||||
};
|
||||
|
||||
private static EffectDraft ParseEffect(JsonObject eff)
|
||||
@@ -1447,6 +1460,14 @@
|
||||
{
|
||||
d.Tiles = ReadInt("Tiles"); d.Direction = ReadStr("Direction", "North");
|
||||
}
|
||||
else if (typeKey == "RepositionUnit")
|
||||
{
|
||||
d.Tiles = ReadInt("Tiles");
|
||||
d.AdjacentToSource = ReadBool("AdjacentToSource");
|
||||
d.RelativeToTargetRef = ReadStr("RelativeToTargetRef", "");
|
||||
d.AdjacentToRelativeTarget = ReadBool("AdjacentToRelativeTarget");
|
||||
d.AllowRelativeTargetTile = ReadBool("AllowRelativeTargetTile");
|
||||
}
|
||||
else if (typeKey == "SetAttackRange")
|
||||
{
|
||||
d.Min = ReadInt("Min"); d.Max = ReadInt("Max", 2);
|
||||
@@ -1606,6 +1627,8 @@
|
||||
else if (ab.TypeStr == "Triggered" && !string.IsNullOrEmpty(ab.TriggerType))
|
||||
{
|
||||
node["TriggerEvent"] = CompileTrigger(ab);
|
||||
if (ab.TriggerLimitPerTurn is > 0)
|
||||
node["TriggerLimitPerTurn"] = ab.TriggerLimitPerTurn.Value;
|
||||
}
|
||||
|
||||
if (ab.Conditions.Count > 0)
|
||||
@@ -1704,6 +1727,9 @@
|
||||
node["AbilityRef"] = c.AbilityRef; break;
|
||||
case "IsOnTileWithAffinity":
|
||||
case "TileAffinityMatches":
|
||||
case "DestinationTileAffinityIs":
|
||||
case "PreviousTileAffinityIs":
|
||||
case "MovedFromOrIntoAffinity":
|
||||
node["Affinity"] = c.Affinity; break;
|
||||
case "IsAdjacentTo":
|
||||
node["UnitType"] = c.UnitType; node["Ownership"] = c.Ownership; break;
|
||||
@@ -1720,6 +1746,19 @@
|
||||
node["Comparator"] = c.Comparator; node["N"] = c.N; break;
|
||||
case "CardInZone":
|
||||
node["CardRef"] = c.CardRef; node["Zone"] = c.Zone; break;
|
||||
case "NOT":
|
||||
try
|
||||
{
|
||||
var inner = JsonNode.Parse(string.IsNullOrWhiteSpace(c.InnerConditionJson)
|
||||
? "{\"$type\":\"IsOwnTurn\"}"
|
||||
: c.InnerConditionJson) as JsonObject;
|
||||
node["Condition"] = inner ?? new JsonObject { ["$type"] = "IsOwnTurn" };
|
||||
}
|
||||
catch
|
||||
{
|
||||
node["Condition"] = new JsonObject { ["$type"] = "IsOwnTurn" };
|
||||
}
|
||||
break;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@@ -1887,6 +1926,14 @@
|
||||
{
|
||||
node["Tiles"] = d.Tiles; node["Direction"] = d.Direction;
|
||||
}
|
||||
else if (d.TypeKey == "RepositionUnit")
|
||||
{
|
||||
node["Tiles"] = d.Tiles;
|
||||
if (d.AdjacentToSource) node["AdjacentToSource"] = true;
|
||||
if (!string.IsNullOrWhiteSpace(d.RelativeToTargetRef)) node["RelativeToTargetRef"] = d.RelativeToTargetRef;
|
||||
if (d.AdjacentToRelativeTarget) node["AdjacentToRelativeTarget"] = true;
|
||||
if (d.AllowRelativeTargetTile) node["AllowRelativeTargetTile"] = true;
|
||||
}
|
||||
else if (d.TypeKey == "SetAttackRange")
|
||||
{
|
||||
node["Min"] = d.Min; node["Max"] = d.Max;
|
||||
@@ -2051,7 +2098,7 @@
|
||||
this, e => { c.AbilityRef = e.Value?.ToString() ?? ""; Compile(); }));
|
||||
__builder.CloseElement();
|
||||
}
|
||||
else if (t is "IsOnTileWithAffinity" or "TileAffinityMatches")
|
||||
else if (t is "IsOnTileWithAffinity" or "TileAffinityMatches" or "DestinationTileAffinityIs" or "PreviousTileAffinityIs" or "MovedFromOrIntoAffinity")
|
||||
{
|
||||
BuildSelect(__builder, AffinityValues, c.Affinity, v => { c.Affinity = v; Compile(); }, 120);
|
||||
}
|
||||
@@ -2096,6 +2143,17 @@
|
||||
__builder.CloseElement();
|
||||
BuildSelect(__builder, ZoneValues, c.Zone, v => { c.Zone = v; Compile(); }, 110);
|
||||
}
|
||||
else if (t == "NOT")
|
||||
{
|
||||
__builder.OpenElement(0, "input");
|
||||
__builder.AddAttribute(1, "class", "form-control form-control-sm font-monospace");
|
||||
__builder.AddAttribute(2, "style", "width:360px");
|
||||
__builder.AddAttribute(3, "placeholder", "Inner condition JSON e.g. {\"$type\":\"IsOwnTurn\"}");
|
||||
__builder.AddAttribute(4, "value", c.InnerConditionJson);
|
||||
__builder.AddAttribute(5, "onchange", EventCallback.Factory.Create<ChangeEventArgs>(
|
||||
this, e => { c.InnerConditionJson = e.Value?.ToString() ?? ""; Compile(); }));
|
||||
__builder.CloseElement();
|
||||
}
|
||||
// AND/OR/XOR + no-field types: no extra inputs
|
||||
};
|
||||
|
||||
@@ -2151,6 +2209,21 @@
|
||||
BuildIntInput(__builder, d.Tiles, v => { d.Tiles = v; Compile(); }, 70, "Tiles");
|
||||
BuildSelect(__builder, DirectionValues, d.Direction, v => { d.Direction = v; Compile(); }, 110);
|
||||
}
|
||||
else if (t == "RepositionUnit")
|
||||
{
|
||||
BuildIntInput(__builder, d.Tiles, v => { d.Tiles = v; Compile(); }, 70, "Tiles");
|
||||
BuildCheckbox(__builder, "Adj Source", d.AdjacentToSource, v => { d.AdjacentToSource = v; Compile(); });
|
||||
BuildCheckbox(__builder, "Adj Ref", d.AdjacentToRelativeTarget, v => { d.AdjacentToRelativeTarget = v; Compile(); });
|
||||
BuildCheckbox(__builder, "Allow Ref Tile", d.AllowRelativeTargetTile, v => { d.AllowRelativeTargetTile = v; Compile(); });
|
||||
__builder.OpenElement(0, "input");
|
||||
__builder.AddAttribute(1, "class", "form-control form-control-sm");
|
||||
__builder.AddAttribute(2, "style", "width:160px");
|
||||
__builder.AddAttribute(3, "placeholder", "RelativeToTargetRef");
|
||||
__builder.AddAttribute(4, "value", d.RelativeToTargetRef);
|
||||
__builder.AddAttribute(5, "onchange", EventCallback.Factory.Create<ChangeEventArgs>(
|
||||
this, e => { d.RelativeToTargetRef = e.Value?.ToString() ?? ""; Compile(); }));
|
||||
__builder.CloseElement();
|
||||
}
|
||||
else if (t == "SetAttackRange")
|
||||
{
|
||||
BuildIntInput(__builder, d.Min, v => { d.Min = v; Compile(); }, 70, "Min");
|
||||
@@ -2703,6 +2776,7 @@
|
||||
public string TriggerOccupantOwnership { get; set; } = "";
|
||||
public string TriggerUnitOwnership { get; set; } = "Any";
|
||||
public string TriggerAuraOwnership { get; set; } = "Owner";
|
||||
public int? TriggerLimitPerTurn { get; set; }
|
||||
// Ability-level duration (overrides per-action Duration when set; "" = per-action)
|
||||
public string DurationStr { get; set; } = "";
|
||||
public int DurationN { get; set; } = 1;
|
||||
@@ -2751,6 +2825,10 @@
|
||||
public int Tiles { get; set; } = 1;
|
||||
public int BlockedDamage{ get; set; } = 0;
|
||||
public string Direction { get; set; } = "North";
|
||||
public bool AdjacentToSource { get; set; } = false;
|
||||
public string RelativeToTargetRef { get; set; } = "";
|
||||
public bool AdjacentToRelativeTarget { get; set; } = false;
|
||||
public bool AllowRelativeTargetTile { get; set; } = false;
|
||||
public int Min { get; set; } = 1;
|
||||
public int Max { get; set; } = 2;
|
||||
public string DurationType { get; set; } = "UntilEndOfTurn";
|
||||
@@ -2816,6 +2894,7 @@
|
||||
public string Comparator { get; set; } = "GreaterThanOrEqual";
|
||||
public string Zone { get; set; } = "Hand";
|
||||
public string CardRef { get; set; } = "";
|
||||
public string InnerConditionJson { get; set; } = "{\"$type\":\"IsOwnTurn\"}";
|
||||
}
|
||||
|
||||
private sealed class CostDraft
|
||||
|
||||
Reference in New Issue
Block a user