Fix: conditional passive re-evaluation + INSUFFICIENT_TARGETS crash
Issue 1 — ActivationConditions on passives were never checked: - ApplyPassivesForSource and ApplyPassivesToNewTarget now evaluate ActivationConditions against the source unit before executing each passive ability (e.g. IsOnTileWithAffinity: Lake only grants the buff when the unit is actually on a Lake tile). Issue 1 — Passives not re-evaluated on movement / tile changes: - Added ReEvaluateConditionalPassives(state): for every unit with at least one conditional passive, revoke all WhileSourceOnBattlefield effects then reapply with conditions re-checked. Units without conditional passives are skipped with zero overhead. - Called after MoveUnit (unit changes tile affinity), ActivateAbility (ability may change board state), and ChannelCard Terramorpha path (tile affinities change). Issue 2 — INSUFFICIENT_TARGETS thrown from ApplyPassivesToNewTarget: - ResolveTargets: when restrictTargets is set (passive-to-new-target mode only) and filtering produces zero candidates, return [] silently instead of throwing. An ExactSelf source-buff simply has no valid target among the new unit — that is expected, not an error. 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:
@@ -324,6 +324,9 @@ public static class GameEngine
|
||||
ActorId = actorId,
|
||||
CardType = "Terramorpha",
|
||||
});
|
||||
|
||||
// Tile affinities changed — re-evaluate conditional passives for all units.
|
||||
AbilitySystem.ReEvaluateConditionalPassives(state);
|
||||
}
|
||||
else if (card.CardType == "Ruin")
|
||||
{
|
||||
@@ -590,6 +593,9 @@ public static class GameEngine
|
||||
});
|
||||
}
|
||||
|
||||
// A unit changed tiles — re-evaluate tile-affinity (and other) conditional passives.
|
||||
AbilitySystem.ReEvaluateConditionalPassives(state);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -869,6 +875,8 @@ public static class GameEngine
|
||||
Data = new TriggerEventData { SourceId = sourceInstanceId },
|
||||
});
|
||||
|
||||
AbilitySystem.ReEvaluateConditionalPassives(state);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user