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:
@@ -100,7 +100,7 @@ public static class AbilitySystem
|
||||
|
||||
source.AbilityUsesThisTurn[abilityIndex] = usedThisTurn + 1;
|
||||
|
||||
ExecuteActions(def.Actions, ctx, clientTargets, requireClientTargets: true, activationRange: def.Range);
|
||||
ExecuteActions(def.Actions, ctx, clientTargets, requireClientTargets: true, activationRange: def.Range, forceDuration: def.Duration);
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public static class AbilitySystem
|
||||
if (def.ActivationConditions.Any(c => !EvaluateCondition(c, ctx, unit)))
|
||||
continue;
|
||||
|
||||
ExecuteActions(def.Actions, ctx, clientTargets: null);
|
||||
ExecuteActions(def.Actions, ctx, clientTargets: null, forceDuration: def.Duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1933,9 +1933,10 @@ public static class AbilitySystem
|
||||
if (source is null) return;
|
||||
|
||||
var ctx = new AbilityContext { State = state, ActorId = ownerId, Source = source };
|
||||
var duration = new DurationModel { Type = DurationType.WhileSourceOnBattlefield };
|
||||
var fallback = new DurationModel { Type = DurationType.WhileSourceOnBattlefield };
|
||||
foreach (var def in ParseAbilities(source.AbilitiesJson).Where(d => d.Type == AbilityType.Passive))
|
||||
ExecuteActions(def.Actions, ctx, clientTargets: null, forceDuration: duration);
|
||||
ExecuteActions(def.Actions, ctx, clientTargets: null,
|
||||
forceDuration: def.Duration ?? fallback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1946,7 +1947,7 @@ public static class AbilitySystem
|
||||
public static void ApplyPassivesToNewTarget(GameState state, string newUnitId)
|
||||
{
|
||||
var restrict = new HashSet<string> { newUnitId };
|
||||
var duration = new DurationModel { Type = DurationType.WhileSourceOnBattlefield };
|
||||
var fallback = new DurationModel { Type = DurationType.WhileSourceOnBattlefield };
|
||||
foreach (var (ownerId, player) in state.Players)
|
||||
foreach (var sourceUnit in player.Field.OfType<FieldCard>()
|
||||
.Where(f => f.InstanceId != newUnitId).ToList())
|
||||
@@ -1954,7 +1955,7 @@ public static class AbilitySystem
|
||||
var ctx = new AbilityContext { State = state, ActorId = ownerId, Source = sourceUnit };
|
||||
foreach (var def in ParseAbilities(sourceUnit.AbilitiesJson).Where(d => d.Type == AbilityType.Passive))
|
||||
ExecuteActions(def.Actions, ctx, clientTargets: null,
|
||||
restrictTargets: restrict, forceDuration: duration);
|
||||
restrictTargets: restrict, forceDuration: def.Duration ?? fallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user