Add BlockedDamage, RequiresLos, and LinearOnly to ability schema + builder UI
- PushUnitEffect and PullUnitEffect gain BlockedDamage (int): deals direct HP damage to the displaced unit if it cannot complete the full tile distance (blocked by a boundary or another unit) - AbilityRange gains RequiresLos (bool): engine validates line of sight before allowing ability activation - AbilityRange gains LinearOnly (bool): restricts targeting to cardinal/diagonal straight lines only (suitable for Push/Pull/beam abilities) - AbilityBuilder UI exposes RequiresLos and LinearOnly as inline checkboxes in the Active ability range row - PushUnit/PullUnit effect templates auto-populate with BlockedDamage: 0 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:
@@ -51,7 +51,7 @@
|
||||
<!-- Type-specific fields -->
|
||||
@if (ab.TypeStr == "Active")
|
||||
{
|
||||
<div class="row g-2 mb-3">
|
||||
<div class="row g-2 mb-2">
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small">Range Min</label>
|
||||
<input type="number" class="form-control form-control-sm"
|
||||
@@ -67,7 +67,23 @@
|
||||
<input type="number" min="1" class="form-control form-control-sm"
|
||||
@bind="ab.UsesPerTurn" @bind:after="Compile" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-auto d-flex align-items-end pb-1">
|
||||
<div class="form-check me-3">
|
||||
<input type="checkbox" class="form-check-input"
|
||||
id="los_@idx"
|
||||
@bind="ab.RangeRequiresLos" @bind:after="Compile" />
|
||||
<label class="form-check-label small" for="los_@idx">Requires LoS</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input"
|
||||
id="linear_@idx"
|
||||
@bind="ab.RangeLinearOnly" @bind:after="Compile" />
|
||||
<label class="form-check-label small" for="linear_@idx">Linear Only</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-2 mb-3">
|
||||
<div class="col-12">
|
||||
<label class="form-label small">Cost JSON <small class="text-muted">(CostEntry[] array)</small></label>
|
||||
<input class="form-control form-control-sm font-monospace" @bind="ab.CostJson" @bind:after="Compile"
|
||||
placeholder='e.g. [{"Type":"SpiritPoints","Amount":2}]' />
|
||||
@@ -408,8 +424,8 @@
|
||||
["RemoveAbility"] = """{"AbilityRef":"AbilityName"}""",
|
||||
["EnableAbility"] = """{"AbilityRef":"AbilityName"}""",
|
||||
["DisableAbility"] = """{"AbilityRef":"AbilityName"}""",
|
||||
["PushUnit"] = """{"Tiles":1}""",
|
||||
["PullUnit"] = """{"Tiles":1}""",
|
||||
["PushUnit"] = """{"Tiles":1,"BlockedDamage":0}""",
|
||||
["PullUnit"] = """{"Tiles":1,"BlockedDamage":0}""",
|
||||
["DisplaceUnit"] = """{"Tiles":1,"Direction":"North"}""",
|
||||
["TakeControl"] = """{"Duration":{"Type":"UntilEndOfTurn"}}""",
|
||||
["GrantMovementControl"] = """{"N":1}""",
|
||||
@@ -489,8 +505,10 @@
|
||||
Name = node["Name"]?.GetValue<string>() ?? "",
|
||||
Description = node["Description"]?.GetValue<string>() ?? "",
|
||||
UsesPerTurn = node["UsesPerTurn"]?.GetValue<int>() ?? 1,
|
||||
RangeMin = node["Range"]?["Min"]?.GetValue<int>(),
|
||||
RangeMax = node["Range"]?["Max"]?.GetValue<int>(),
|
||||
RangeMin = node["Range"]?["Min"]?.GetValue<int>(),
|
||||
RangeMax = node["Range"]?["Max"]?.GetValue<int>(),
|
||||
RangeRequiresLos = node["Range"]?["RequiresLos"]?.GetValue<bool>() ?? false,
|
||||
RangeLinearOnly = node["Range"]?["LinearOnly"]?.GetValue<bool>() ?? false,
|
||||
AuraRangeMin = node["AuraRange"]?["Min"]?.GetValue<int>(),
|
||||
AuraRangeMax = node["AuraRange"]?["Max"]?.GetValue<int>(),
|
||||
CostJson = node["Cost"] is JsonNode cost ? cost.ToJsonString() : "",
|
||||
@@ -572,11 +590,16 @@
|
||||
if (ab.TypeStr == "Active")
|
||||
{
|
||||
if (ab.RangeMin.HasValue || ab.RangeMax.HasValue)
|
||||
node["Range"] = new JsonObject
|
||||
{
|
||||
var rangeNode = new JsonObject
|
||||
{
|
||||
["Min"] = ab.RangeMin ?? 1,
|
||||
["Max"] = ab.RangeMax ?? 1,
|
||||
};
|
||||
if (ab.RangeRequiresLos) rangeNode["RequiresLos"] = true;
|
||||
if (ab.RangeLinearOnly) rangeNode["LinearOnly"] = true;
|
||||
node["Range"] = rangeNode;
|
||||
}
|
||||
node["UsesPerTurn"] = ab.UsesPerTurn;
|
||||
if (!string.IsNullOrWhiteSpace(ab.CostJson))
|
||||
try { node["Cost"] = JsonNode.Parse(ab.CostJson); } catch { }
|
||||
@@ -700,18 +723,20 @@
|
||||
|
||||
private sealed class AbilityDraft
|
||||
{
|
||||
public string TypeStr { get; set; } = "Active";
|
||||
public string Name { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
public int? RangeMin { get; set; }
|
||||
public int? RangeMax { get; set; }
|
||||
public int UsesPerTurn { get; set; } = 1;
|
||||
public string CostJson { get; set; } = "";
|
||||
public int? AuraRangeMin { get; set; }
|
||||
public int? AuraRangeMax { get; set; }
|
||||
public string TriggerType { get; set; } = "";
|
||||
public string TriggerJson { get; set; } = "";
|
||||
public string ConditionsJson { get; set; } = "";
|
||||
public string TypeStr { get; set; } = "Active";
|
||||
public string Name { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
public int? RangeMin { get; set; }
|
||||
public int? RangeMax { get; set; }
|
||||
public bool RangeRequiresLos { get; set; } = false;
|
||||
public bool RangeLinearOnly { get; set; } = false;
|
||||
public int UsesPerTurn { get; set; } = 1;
|
||||
public string CostJson { get; set; } = "";
|
||||
public int? AuraRangeMin { get; set; }
|
||||
public int? AuraRangeMax { get; set; }
|
||||
public string TriggerType { get; set; } = "";
|
||||
public string TriggerJson { get; set; } = "";
|
||||
public string ConditionsJson { get; set; } = "";
|
||||
public List<ActionDraft> Actions { get; set; } = new();
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,16 @@ public sealed class CostEntry
|
||||
|
||||
public sealed class AbilityRange
|
||||
{
|
||||
public int Min { get; set; } = 1;
|
||||
public int Max { get; set; } = 1;
|
||||
public int Min { get; set; } = 1;
|
||||
public int Max { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// When true, the engine validates that a clear line of sight exists between the
|
||||
/// caster and the target tile/unit before allowing the ability to be used.
|
||||
/// </summary>
|
||||
public bool RequiresLos { get; set; } = false;
|
||||
/// <summary>
|
||||
/// When true, only targets that lie on a straight cardinal or diagonal line from
|
||||
/// the caster are valid (e.g. Push, Pull, beam-style abilities).
|
||||
/// </summary>
|
||||
public bool LinearOnly { get; set; } = false;
|
||||
}
|
||||
|
||||
@@ -196,8 +196,25 @@ public sealed class HOTEffect : Effect { public ValueExpr Amount {
|
||||
|
||||
// ── §5.9 Displacement ─────────────────────────────────────────────────────────
|
||||
|
||||
public sealed class PushUnitEffect : Effect { public int Tiles { get; set; } = 1; }
|
||||
public sealed class PullUnitEffect : Effect { public int Tiles { get; set; } = 1; }
|
||||
public sealed class PushUnitEffect : Effect
|
||||
{
|
||||
public int Tiles { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// Direct HP damage dealt to the pushed unit if it cannot complete the full push
|
||||
/// (blocked by a boundary or another unit). 0 = no knockback damage.
|
||||
/// </summary>
|
||||
public int BlockedDamage { get; set; } = 0;
|
||||
}
|
||||
|
||||
public sealed class PullUnitEffect : Effect
|
||||
{
|
||||
public int Tiles { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// Direct HP damage dealt to the pulled unit if it cannot complete the full pull
|
||||
/// (blocked by a boundary or another unit). 0 = no knockback damage.
|
||||
/// </summary>
|
||||
public int BlockedDamage { get; set; } = 0;
|
||||
}
|
||||
public sealed class DisplaceUnitEffect : Effect { public int Tiles { get; set; } = 1; public string Direction { get; set; } = "North"; }
|
||||
|
||||
// ── §5.10 Control effects ─────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user