Implement phase-3 adjacency, movement-state, and tile-control ability primitives

This commit is contained in:
Shard
2026-03-27 17:58:02 +00:00
parent e887a8c670
commit 8f0ed9d68f
5 changed files with 216 additions and 15 deletions
@@ -350,6 +350,8 @@
<option value="IsSelf">IsSelf — same card definition</option>
<option value="IsExactSelf">IsExactSelf — same instance only</option>
<option value="IsAdjacentToSource">IsAdjacentToSource</option>
<option value="IsAdjacentToUnitMatching">IsAdjacentToUnitMatching</option>
<option value="IsAdjacentToTileMatching">IsAdjacentToTileMatching</option>
</select>
</div>
</div>
@@ -856,6 +858,8 @@
<tr><td>IsSelf</td><td>Target shares the same <em>card definition</em> as the source (matches all copies of this card type on the board)</td></tr>
<tr><td>IsExactSelf</td><td>Target is the exact <em>unit instance</em> that owns this ability (use when only this specific unit should be affected)</td></tr>
<tr><td>IsAdjacentToSource</td><td>Target must be orthogonally adjacent to the ability's source unit</td></tr>
<tr><td>IsAdjacentToUnitMatching</td><td>Target is adjacent to a unit matching ownership/filter defaults</td></tr>
<tr><td>IsAdjacentToTileMatching</td><td>Target is adjacent to a tile matching supplied tile filter(s)</td></tr>
</tbody>
</table>
@@ -916,6 +920,9 @@
<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>IsAdjacentToTileWithAffinity / IsOnOrAdjacentToTileWithAffinity</td><td>Positional affinity checks around the subject unit</td></tr>
<tr><td>IsCurrentlyMoving</td><td>True only inside movement-trigger context for the moving source</td></tr>
<tr><td>ControlledTileCountWithAffinity</td><td>Counts occupied tiles by affinity and compares via comparator/N</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>
@@ -1172,11 +1179,12 @@
new("Turn / Timing", ["IsOwnTurn", "IsOpponentTurn", "IsAllyTurn", "IsActivePlayerTurn"]),
new("Unit", ["HealthBelow", "HealthAbove", "DefenseIs", "HasGenus", "HasAbility",
"IsOnTileWithAffinity", "IsAdjacentTo", "WithinRangeOf", "MovementTypeIs",
"DestinationTileAffinityIs", "PreviousTileAffinityIs", "MovedFromOrIntoAffinity"]),
"DestinationTileAffinityIs", "PreviousTileAffinityIs", "MovedFromOrIntoAffinity",
"IsAdjacentToTileWithAffinity", "IsOnOrAdjacentToTileWithAffinity", "IsCurrentlyMoving"]),
new("Player", ["SPAtLeast", "SPAtMost", "STAtLeast", "STAtMost",
"HandSizeAtLeast", "HandSizeAtMost", "DeckSizeAtLeast", "DiscardSizeAtLeast"]),
new("Tile", ["TileAffinityMatches", "TileIsOccupied", "TileIsUnoccupied"]),
new("Battlefield", ["UnitCountOnBattlefield", "CardInZone"]),
new("Battlefield", ["UnitCountOnBattlefield", "CardInZone", "ControlledTileCountWithAffinity"]),
new("Composite", ["AND", "OR", "XOR", "NOT"]),
];
@@ -1296,6 +1304,7 @@
ab.TriggerCardType = trig["CardType"]?.GetValue<string>() ?? "Spirit";
ab.TriggerDamageType = trig["DamageType"]?.GetValue<string>() ?? "Any";
ab.TriggerAmount = trig["Amount"] is JsonNode amtNode ? amtNode.GetValue<int>() : null;
ab.TriggerSourceFilterType = trig["SourceFilter"]?["$type"]?.GetValue<string>() ?? "";
ab.TriggerStat = trig["Stat"]?.GetValue<string>() ?? "";
ab.TriggerCause = trig["Cause"]?.GetValue<string>() ?? "";
ab.TriggerCausedBy = trig["CausedBy"]?.GetValue<string>() ?? "";
@@ -1732,6 +1741,8 @@
case "DestinationTileAffinityIs":
case "PreviousTileAffinityIs":
case "MovedFromOrIntoAffinity":
case "IsAdjacentToTileWithAffinity":
case "IsOnOrAdjacentToTileWithAffinity":
node["Affinity"] = c.Affinity; break;
case "IsAdjacentTo":
node["UnitType"] = c.UnitType; node["Ownership"] = c.Ownership; break;
@@ -1748,6 +1759,12 @@
node["Comparator"] = c.Comparator; node["N"] = c.N; break;
case "CardInZone":
node["CardRef"] = c.CardRef; node["Zone"] = c.Zone; break;
case "ControlledTileCountWithAffinity":
node["Ownership"] = c.Ownership;
node["Affinity"] = c.Affinity;
node["Comparator"] = c.Comparator;
node["N"] = c.N;
break;
case "NOT":
try
{
@@ -1834,6 +1851,8 @@
n["TargetOwnership"] = ab.TriggerTargetOwnership;
if (ab.TriggerDamageType != "Any") n["DamageType"] = ab.TriggerDamageType;
if (ab.TriggerAmount.HasValue) n["Amount"] = ab.TriggerAmount.Value;
if (!string.IsNullOrWhiteSpace(ab.TriggerSourceFilterType))
n["SourceFilter"] = new JsonObject { ["$type"] = ab.TriggerSourceFilterType };
}
else if (t == "BeforeDamageApplied")
{
@@ -2109,7 +2128,7 @@
this, e => { c.AbilityRef = e.Value?.ToString() ?? ""; Compile(); }));
__builder.CloseElement();
}
else if (t is "IsOnTileWithAffinity" or "TileAffinityMatches" or "DestinationTileAffinityIs" or "PreviousTileAffinityIs" or "MovedFromOrIntoAffinity")
else if (t is "IsOnTileWithAffinity" or "TileAffinityMatches" or "DestinationTileAffinityIs" or "PreviousTileAffinityIs" or "MovedFromOrIntoAffinity" or "IsAdjacentToTileWithAffinity" or "IsOnOrAdjacentToTileWithAffinity")
{
BuildSelect(__builder, AffinityValues, c.Affinity, v => { c.Affinity = v; Compile(); }, 120);
}
@@ -2154,6 +2173,13 @@
__builder.CloseElement();
BuildSelect(__builder, ZoneValues, c.Zone, v => { c.Zone = v; Compile(); }, 110);
}
else if (t == "ControlledTileCountWithAffinity")
{
BuildSelect(__builder, OwnershipValues, c.Ownership, v => { c.Ownership = v; Compile(); }, 100);
BuildSelect(__builder, AffinityValues, c.Affinity, v => { c.Affinity = v; Compile(); }, 120);
BuildSelect(__builder, ComparatorValues, c.Comparator, v => { c.Comparator = v; Compile(); }, 150);
BuildIntInput(__builder, c.N, v => { c.N = v; Compile(); }, 60, "N");
}
else if (t == "NOT")
{
__builder.OpenElement(0, "input");
@@ -2459,6 +2485,10 @@
v => { ab.TriggerDamageType = v; Compile(); }, 100);
BuildOptionalAmountInput(__builder, ab.TriggerAmount,
v => { ab.TriggerAmount = v; Compile(); });
BuildOptionalStringSelect(__builder,
["IsSelf", "IsExactSelf", "IsAdjacentToSource", "IsAdjacentToUnitMatching", "IsAdjacentToTileMatching"],
ab.TriggerSourceFilterType,
v => { ab.TriggerSourceFilterType = v; Compile(); }, 170, "Any source");
}
else if (t == "BeforeDamageApplied")
{
@@ -2709,6 +2739,7 @@
ab.TriggerCardType = "Spirit";
ab.TriggerDamageType = "Any";
ab.TriggerAmount = null;
ab.TriggerSourceFilterType = "";
ab.TriggerStat = "";
ab.TriggerCause = "";
ab.TriggerCausedBy = "";
@@ -2795,6 +2826,7 @@
public string TriggerCardType { get; set; } = "Spirit";
public string TriggerDamageType { get; set; } = "Any";
public int? TriggerAmount { get; set; }
public string TriggerSourceFilterType { get; set; } = "";
public string TriggerStat { get; set; } = "";
public string TriggerCause { get; set; } = "";
public string TriggerCausedBy { get; set; } = "";