Fix: implement Passive ability execution with per-target conditions
Passive abilities (e.g. 'All Merfolk +1 attack') were never executed
because AbilityType.Passive had no runtime processing.
Three root causes fixed:
1. Passive abilities are now applied when units enter the battlefield
and reversed when they leave (new DurationType.WhileSourceOnBattlefield).
- ApplyPassivesForSource: runs a unit's passives against all current targets
- ApplyPassivesToNewTarget: applies existing passives to a newly-entered unit
- RevokePassivesForSource: reverses all passive effects on source death/leave
- Hooked into GameEngine.Channel, Transition and AbilitySystem
ReturnToBattlefield, SummonToken, KillUnit, SendToDiscard
2. Action conditions with Subject="Target" now filter per-target instead of
aborting the entire action (which evaluated against ctx.Source).
Source-level conditions still gate the whole action; target-level ones
are evaluated individually and skip non-matching targets.
3. ExecuteActions/ResolveTargets gain a restrictTargets parameter used by
ApplyPassivesToNewTarget to avoid double-applying existing passive buffs
to units that already received them when the passive source entered.
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:
@@ -281,6 +281,8 @@ public static class GameEngine
|
||||
Data = new TriggerEventData { SourceId = field.InstanceId },
|
||||
});
|
||||
AbilitySystem.EvaluateAurasOnEnter(state, field.InstanceId);
|
||||
AbilitySystem.ApplyPassivesForSource(state, field.InstanceId, actorId);
|
||||
AbilitySystem.ApplyPassivesToNewTarget(state, field.InstanceId);
|
||||
}
|
||||
else if (card.CardType == "Terramorpha")
|
||||
{
|
||||
@@ -483,6 +485,7 @@ public static class GameEngine
|
||||
|
||||
// Remove current from board; fire aura leave before removal.
|
||||
AbilitySystem.EvaluateAurasOnLeave(state, current.InstanceId);
|
||||
AbilitySystem.RevokePassivesForSource(state, current.InstanceId);
|
||||
board.RemoveUnit(current.InstanceId);
|
||||
player.Discard.Add(current);
|
||||
|
||||
@@ -490,6 +493,8 @@ public static class GameEngine
|
||||
player.ArchSpirit = newArchSpirit;
|
||||
board.PlaceUnit(coord, newArchSpirit.InstanceId, actorId);
|
||||
AbilitySystem.EvaluateAurasOnEnter(state, newArchSpirit.InstanceId);
|
||||
AbilitySystem.ApplyPassivesForSource(state, newArchSpirit.InstanceId, actorId);
|
||||
AbilitySystem.ApplyPassivesToNewTarget(state, newArchSpirit.InstanceId);
|
||||
|
||||
AbilitySystem.FireTrigger(state, new TriggerOccurrence
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user