Feature: ability-level Duration override + WhileSourceOnBattlefield in duration list
AbilityDefinition gains an optional Duration property. When set it is used as forceDuration for every ExecuteActions call that resolves that ability, overriding whatever per-action Duration individual effects specify. - Active abilities: def.Duration is threaded through as forceDuration - Triggered abilities: same - Passive abilities: def.Duration ?? WhileSourceOnBattlefield (both ApplyPassivesForSource and ApplyPassivesToNewTarget paths) AbilityBuilder admin panel: - Duration row added after type-specific fields (dropdown + N input for ForNTurns) - "WhileSourceOnBattlefield" added to the DurationTypeValues list - Parse and compile paths updated for the new Duration field 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:
@@ -158,6 +158,30 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Duration override -->
|
||||
<div class="row g-2 mb-3 align-items-end">
|
||||
<div class="col-auto">
|
||||
<label class="form-label small mb-0">
|
||||
Duration
|
||||
<small class="text-muted ms-1">overrides per-action duration for all effects</small>
|
||||
</label>
|
||||
<select class="form-select form-select-sm" style="width:230px"
|
||||
@bind="ab.DurationStr" @bind:after="Compile">
|
||||
<option value="">— per-action (no override) —</option>
|
||||
@foreach (var d in DurationTypeValues)
|
||||
{ <option value="@d">@d</option> }
|
||||
</select>
|
||||
</div>
|
||||
@if (ab.DurationStr == "ForNTurns")
|
||||
{
|
||||
<div class="col-auto">
|
||||
<label class="form-label small mb-0">N</label>
|
||||
<input type="number" min="1" class="form-control form-control-sm" style="width:80px"
|
||||
@bind="ab.DurationN" @bind:after="Compile" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Activation Conditions -->
|
||||
<div class="mb-3">
|
||||
<div class="d-flex justify-content-between align-items-center mb-1">
|
||||
@@ -498,7 +522,7 @@
|
||||
private static readonly string[] MovementTypeValues = ["Walk", "Flight", "Jump", "Teleport"];
|
||||
private static readonly string[] DirectionValues = ["North", "South", "East", "West", "NorthEast", "NorthWest", "SouthEast", "SouthWest"];
|
||||
private static readonly string[] ComparatorValues = ["Equal", "NotEqual", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual"];
|
||||
private static readonly string[] DurationTypeValues = ["Instant", "UntilEndOfTurn", "UntilStartOfOwnerTurn", "UntilStartOfSourceOwnerTurn", "ForNTurns", "PermanentInMatch"];
|
||||
private static readonly string[] DurationTypeValues = ["Instant", "UntilEndOfTurn", "UntilStartOfOwnerTurn", "UntilStartOfSourceOwnerTurn", "ForNTurns", "WhileSourceOnBattlefield", "PermanentInMatch"];
|
||||
private static readonly string[] StatTargetValues = ["Current", "Base", "Max"];
|
||||
private static readonly string[] StatValues = ["Damage", "Defense", "Health", "MP"];
|
||||
private static readonly string[] PositionValues = ["Top", "Bottom"];
|
||||
@@ -732,6 +756,12 @@
|
||||
ab.Actions.Add(act);
|
||||
}
|
||||
|
||||
if (node["Duration"] is JsonObject dur)
|
||||
{
|
||||
ab.DurationStr = dur["Type"]?.GetValue<string>() ?? "";
|
||||
ab.DurationN = dur["N"]?.GetValue<int>() ?? 1;
|
||||
}
|
||||
|
||||
if (node["Animation"] is JsonObject anim)
|
||||
{
|
||||
ab.HasAnimation = true;
|
||||
@@ -999,6 +1029,13 @@
|
||||
|
||||
node["Actions"] = actionsArr;
|
||||
|
||||
if (!string.IsNullOrEmpty(ab.DurationStr))
|
||||
{
|
||||
var durNode = new JsonObject { ["Type"] = ab.DurationStr };
|
||||
if (ab.DurationStr == "ForNTurns") durNode["N"] = ab.DurationN;
|
||||
node["Duration"] = durNode;
|
||||
}
|
||||
|
||||
if (ab.HasAnimation)
|
||||
{
|
||||
var animNode = new JsonObject
|
||||
@@ -1931,6 +1968,10 @@
|
||||
public string TriggerOccupantOwnership { get; set; } = "";
|
||||
public string TriggerUnitOwnership { get; set; } = "Any";
|
||||
public string TriggerAuraOwnership { get; set; } = "Owner";
|
||||
// Ability-level duration (overrides per-action Duration when set; "" = per-action)
|
||||
public string DurationStr { get; set; } = "";
|
||||
public int DurationN { get; set; } = 1;
|
||||
|
||||
public List<CostDraft> Costs { get; set; } = new();
|
||||
public List<ConditionDraft> Conditions { get; set; } = new();
|
||||
public List<ActionDraft> Actions { get; set; } = new();
|
||||
|
||||
Reference in New Issue
Block a user